Class: Bake::Types::Hash
- Inherits:
-
Object
- Object
- Bake::Types::Hash
- Includes:
- Type
- Defined in:
- lib/bake/types/hash.rb
Instance Method Summary collapse
- #composite? ⇒ Boolean
-
#initialize(key_type, value_type) ⇒ Hash
constructor
A new instance of Hash.
- #parse(input) ⇒ Object
Methods included from Type
Constructor Details
#initialize(key_type, value_type) ⇒ Hash
Returns a new instance of Hash.
28 29 30 31 |
# File 'lib/bake/types/hash.rb', line 28 def initialize(key_type, value_type) @key_type = key_type @value_type = value_type end |
Instance Method Details
#parse(input) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/bake/types/hash.rb', line 37 def parse(input) hash = {} input.split(',').each do |pair| key, value = pair.split(':', 2) key = @key_type.parse(key) value = @value_type.parse(value) hash[key] = value end return hash end |