Class: Arrayish::String

Inherits:
String
  • Object
show all
Defined in:
lib/arrayish/string.rb

Instance Method Summary collapse

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_aObject



12
13
14
# File 'lib/arrayish/string.rb', line 12

def to_a
  self.split(separator)
end