Class: MarshalParser::Parser::ClassNode

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, #tokens

Methods included from Assertable

#assert

Constructor Details

#initialize(prefix, length, name) ⇒ ClassNode

Returns a new instance of ClassNode.



677
678
679
680
681
682
683
684
685
686
# File 'lib/marshal-parser/parser.rb', line 677

def initialize(prefix, length, name)
  super()
  assert_token_type prefix, Lexer::CLASS_PREFIX
  assert_token_type length, Lexer::INTEGER
  assert_token_type name, Lexer::STRING

  @prefix = prefix
  @length = length
  @name = name
end

Instance Method Details

#attributesObject



696
697
698
699
700
701
# File 'lib/marshal-parser/parser.rb', line 696

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

#child_entitiesObject



688
689
690
# File 'lib/marshal-parser/parser.rb', line 688

def child_entities
  [@prefix, @length, @name]
end

#literal_tokenObject



692
693
694
# File 'lib/marshal-parser/parser.rb', line 692

def literal_token
  @name
end