Class: Yoda::Typing::Tree::HashBody
- Defined in:
- lib/yoda/typing/tree/hash_body.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#build_child, #children, #generator, #initialize
Constructor Details
This class inherits a constructor from Yoda::Typing::Tree::Base
Instance Method Details
#infer_hash_node(node) ⇒ Model::TypeExpressions::Base
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/yoda/typing/tree/hash_body.rb', line 11 def infer_hash_node(node) hash = node.children.each_with_object({}) do |node, memo| case node.type when :pair pair_key, pair_value = node.children case pair_key.type when :sym memo[pair_key.children.first.to_sym] = infer(pair_value) when :str memo[pair_key.children.first.to_s] = infer(pair_value) else # TODO: Support other key types. end when :kwsplat content_node = node.children.first content_type = infer(content_node) # TODO: merge infered result end end Types::AssociativeArray.new(contents: hash) end |
#type ⇒ Object
5 6 7 |
# File 'lib/yoda/typing/tree/hash_body.rb', line 5 def type infer_hash_node(node) end |