Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/deprecated.rb,
lib/common/class_exts/string.rb
Overview
Carve out from lich.rbw extension to String class
Instance Method Summary collapse
-
#silent ⇒ Boolean
Returns false, indicating that the string is not silent.
-
#split_as_list ⇒ Array<String>
Splits the string into a list based on specific patterns.
-
#stream ⇒ Object?
Returns the current stream value.
-
#stream=(val) ⇒ Object
Sets the stream value if it is not already set.
-
#to_a ⇒ Array<String>
Converts the string to an array for compatibility with Ruby 1.8.
-
#to_s ⇒ String
Returns a duplicate of the string.
Instance Method Details
#silent ⇒ Boolean
Returns false, indicating that the string is not silent.
105 106 107 |
# File 'lib/deprecated.rb', line 105 def silent false end |
#split_as_list ⇒ Array<String>
Splits the string into a list based on specific patterns.
114 115 116 117 118 |
# File 'lib/deprecated.rb', line 114 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 |
#stream ⇒ Object?
Returns the current stream value.
22 23 24 |
# File 'lib/common/class_exts/string.rb', line 22 def stream @stream end |
#stream=(val) ⇒ Object
Note:
This method will only set the stream if it is currently nil.
Sets the stream value if it is not already set.
36 37 38 |
# File 'lib/common/class_exts/string.rb', line 36 def stream=(val) @stream ||= val end |
#to_a ⇒ Array<String>
Converts the string to an array for compatibility with Ruby 1.8.
96 97 98 |
# File 'lib/deprecated.rb', line 96 def to_a # for compatibility with Ruby 1.8 [self] end |
#to_s ⇒ String
Returns a duplicate of the string.
11 12 13 |
# File 'lib/common/class_exts/string.rb', line 11 def to_s self.dup end |