Class: Contraction::HashType
- Inherits:
-
Object
- Object
- Contraction::HashType
- Defined in:
- lib/parser/type_parser.rb
Instance Attribute Summary collapse
-
#key_type ⇒ Object
readonly
Returns the value of attribute key_type.
-
#value_type ⇒ Object
readonly
Returns the value of attribute value_type.
Instance Method Summary collapse
- #check(thing) ⇒ Object
-
#initialize(key_type, value_type) ⇒ HashType
constructor
A new instance of HashType.
Constructor Details
#initialize(key_type, value_type) ⇒ HashType
Returns a new instance of HashType.
93 94 95 96 |
# File 'lib/parser/type_parser.rb', line 93 def initialize(key_type, value_type) @key_type = key_type @value_type = value_type end |
Instance Attribute Details
#key_type ⇒ Object (readonly)
Returns the value of attribute key_type.
92 93 94 |
# File 'lib/parser/type_parser.rb', line 92 def key_type @key_type end |
#value_type ⇒ Object (readonly)
Returns the value of attribute value_type.
92 93 94 |
# File 'lib/parser/type_parser.rb', line 92 def value_type @value_type end |
Instance Method Details
#check(thing) ⇒ Object
98 99 100 101 102 |
# File 'lib/parser/type_parser.rb', line 98 def check(thing) thing.is_a?(Hash) && thing.keys.all? { |k| key_type.check(k) } && thing.values.all? { |v| value_type.check(v) } end |