Class: MarshalParser::Parser::ArrayNode

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(marker_token, length_token, elements_nodes) ⇒ ArrayNode

Returns a new instance of ArrayNode.



314
315
316
317
318
319
320
321
322
# File 'lib/marshal-parser/parser.rb', line 314

def initialize(marker_token, length_token, elements_nodes)
  super()
  assert_token_type marker_token, Lexer::ARRAY_PREFIX
  assert_token_type length_token, Lexer::INTEGER

  @marker_token = marker_token
  @length_token = length_token
  @elements_nodes = elements_nodes
end

Instance Method Details

#attributesObject



328
329
330
331
332
# File 'lib/marshal-parser/parser.rb', line 328

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

#child_entitiesObject



324
325
326
# File 'lib/marshal-parser/parser.rb', line 324

def child_entities
  [@marker_token, @length_token] + @elements_nodes
end