Class: Types::Tuple
Instance Attribute Summary collapse
-
#item_types ⇒ Object
readonly
Returns the value of attribute item_types.
Instance Method Summary collapse
- #composite? ⇒ Boolean
-
#initialize(item_types) ⇒ Tuple
constructor
A new instance of Tuple.
- #parse(input) ⇒ Object
- #to_s ⇒ Object
Methods included from Generic
Constructor Details
#initialize(item_types) ⇒ Tuple
Returns a new instance of Tuple.
30 31 32 |
# File 'lib/types/tuple.rb', line 30 def initialize(item_types) @item_types = item_types end |
Instance Attribute Details
#item_types ⇒ Object (readonly)
Returns the value of attribute item_types.
34 35 36 |
# File 'lib/types/tuple.rb', line 34 def item_types @item_types end |
Instance Method Details
#parse(input) ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/types/tuple.rb', line 40 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 tuple!" end end |
#to_s ⇒ Object
51 52 53 |
# File 'lib/types/tuple.rb', line 51 def to_s "Tuple(#{@item_types.join(', ')})" end |