Class: Arrayish::String
- Inherits:
-
String
- Object
- String
- Arrayish::String
- Defined in:
- lib/arrayish/string.rb
Instance Method Summary collapse
- #+(something) ⇒ Object
- #[](*args) ⇒ Object
-
#initialize(*args) ⇒ String
constructor
A new instance of String.
- #to_a ⇒ Object
Constructor Details
#initialize(*args) ⇒ String
Returns a new instance of String.
4 5 6 7 8 9 10 |
# File 'lib/arrayish/string.rb', line 4 def initialize(*args) if args.respond_to? :each super(args.join(separator)) else super end end |
Instance Method Details
#+(something) ⇒ Object
16 17 18 |
# File 'lib/arrayish/string.rb', line 16 def +(something) new_string( self.to_a + coerce_to_array(something) ) end |
#[](*args) ⇒ Object
20 21 22 |
# File 'lib/arrayish/string.rb', line 20 def [](*args) new_string( self.to_a.send(:[],*args) ) end |
#to_a ⇒ Object
12 13 14 |
# File 'lib/arrayish/string.rb', line 12 def to_a self.split(separator) end |