Class: MarshalParser::Parser::HashWithDefaultValueNode

Inherits:
Node
  • Object
show all
Defined in:
lib/marshal-parser/parser.rb

Instance Method Summary collapse

Methods inherited from Node

#always_leaf?, #children, #decoded_value, #literal_token, #tokens

Methods included from Assertable

#assert

Constructor Details

#initialize(prefix, size, key_and_value_nodes, default_value_node) ⇒ HashWithDefaultValueNode

Returns a new instance of HashWithDefaultValueNode.



623
624
625
626
627
628
629
630
631
632
# File 'lib/marshal-parser/parser.rb', line 623

def initialize(prefix, size, key_and_value_nodes, default_value_node)
  super()
  assert_token_type prefix, Lexer::HASH_WITH_DEFAULT_VALUE_PREFIX
  assert_token_type size, Lexer::INTEGER

  @prefix = prefix
  @size = size
  @key_and_value_nodes = key_and_value_nodes
  @default_value_node = default_value_node
end

Instance Method Details

#attributesObject



638
639
640
641
642
# File 'lib/marshal-parser/parser.rb', line 638

def attributes
  {
    @size => { name: :size, value: @size.value }
  }
end

#child_entitiesObject



634
635
636
# File 'lib/marshal-parser/parser.rb', line 634

def child_entities
  [@prefix, @size] + @key_and_value_nodes + [@default_value_node]
end