Class: String

Inherits:
Object
  • Object
show all
Defined in:
documented/deprecated.rb,
documented/common/class_exts/string.rb

Overview

Represents a string object with additional functionality.

Instance Method Summary collapse

Instance Method Details

#silentBoolean

Returns false, indicating that the string is not silent.

Returns:

  • (Boolean)

    always returns false.



94
95
96
# File 'documented/deprecated.rb', line 94

def silent
  false
end

#split_as_listArray<String>

Splits the string into a list based on specific patterns.

Returns:

  • (Array<String>)

    an array of non-empty trimmed strings.



101
102
103
104
105
# File 'documented/deprecated.rb', line 101

def split_as_list
  string = self
  string.sub!(/^You (?:also see|notice) |^In the .+ you see /, ',')
  string.sub('.', '').sub(/ and (an?|some|the)/, ', \1').split(',').reject { |str| str.strip.empty? }.collect { |str| str.lstrip }
end

#streamObject?

Retrieves the current stream associated with the string.

Returns:

  • (Object, nil)

    the current stream or nil if not set.



14
15
16
# File 'documented/common/class_exts/string.rb', line 14

def stream
  @stream
end

#stream=(val) ⇒ Object

Sets the stream for the string if it is not already set.

Parameters:

  • val (Object)

    the stream to associate with the string.

Returns:

  • (Object)

    the stream that was set.



21
22
23
# File 'documented/common/class_exts/string.rb', line 21

def stream=(val)
  @stream ||= val
end

#to_aArray<String>

Converts the string to an array containing the string itself.

Returns:

  • (Array<String>)

    an array with the string as its only element.



87
88
89
# File 'documented/deprecated.rb', line 87

def to_a # for compatibility with Ruby 1.8
  [self]
end

#to_sString

Returns a string representation of the object.

Returns:

  • (String)

    the string itself.



8
9
10
# File 'documented/common/class_exts/string.rb', line 8

def to_s
  self.dup
end