Class: Types::Array
Instance Method Summary collapse
- #composite? ⇒ Boolean
-
#initialize(item_type) ⇒ Array
constructor
A new instance of Array.
- #map(values) ⇒ Object
- #parse(input) ⇒ Object
- #to_s ⇒ Object
Methods included from Generic
Constructor Details
#initialize(item_type) ⇒ Array
Returns a new instance of Array.
29 30 31 |
# File 'lib/types/array.rb', line 29 def initialize(item_type) @item_type = item_type end |
Instance Method Details
#map(values) ⇒ Object
37 38 39 |
# File 'lib/types/array.rb', line 37 def map(values) values.map{|value| @item_type.parse(value)} end |
#parse(input) ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/types/array.rb', line 41 def parse(input) case input when ::String return parse_values(parse_string(input)) when ::Array return parse_values(input) else raise ArgumentError, "Cannot coerce #{input.inspect} into Array!" end end |
#to_s ⇒ Object
52 53 54 |
# File 'lib/types/array.rb', line 52 def to_s "Array(#{@item_type})" end |