Class: MarshalParser::Parser::StringNode

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(marker_token, length_token, content_token) ⇒ StringNode

Returns a new instance of StringNode.



336
337
338
339
340
341
342
343
344
345
# File 'lib/marshal-parser/parser.rb', line 336

def initialize(marker_token, length_token, content_token)
  super()
  assert_token_type marker_token, Lexer::STRING_PREFIX
  assert_token_type length_token, Lexer::INTEGER
  assert_token_type content_token, Lexer::STRING

  @marker_token = marker_token
  @length_token = length_token
  @content_token = content_token
end

Instance Method Details

#attributesObject



355
356
357
358
359
360
# File 'lib/marshal-parser/parser.rb', line 355

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

#child_entitiesObject



347
348
349
# File 'lib/marshal-parser/parser.rb', line 347

def child_entities
  [@marker_token, @length_token, @content_token]
end

#literal_tokenObject



351
352
353
# File 'lib/marshal-parser/parser.rb', line 351

def literal_token
  @content_token
end