Class: Aspen::List

Inherits:
Object
  • Object
show all
Defined in:
lib/aspen/list.rb

Constant Summary collapse

REGEX =
/\s*,?\s*and\s*/i

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(array = []) ⇒ List

Returns a new instance of List.



6
7
8
# File 'lib/aspen/list.rb', line 6

def initialize(array = [])
  @elements = Array(array)
end

Class Method Details

.from_text(text) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/aspen/list.rb', line 10

def self.from_text(text)
  new text.
        gsub(REGEX, ', ').
        split(',').
        map(&:strip)

end