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