Class: SyntaxTree::JSON::Parser::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/syntax_tree/json/parser.rb

Overview

This represents a parsed token from the source.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, value: nil) ⇒ Token

Returns a new instance of Token.



31
32
33
34
# File 'lib/syntax_tree/json/parser.rb', line 31

def initialize(type:, value: nil)
  @type = type
  @value = value
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



29
30
31
# File 'lib/syntax_tree/json/parser.rb', line 29

def type
  @type
end

#valueObject (readonly)

Returns the value of attribute value.



29
30
31
# File 'lib/syntax_tree/json/parser.rb', line 29

def value
  @value
end

Instance Method Details

#deconstruct_keys(keys) ⇒ Object



36
37
38
# File 'lib/syntax_tree/json/parser.rb', line 36

def deconstruct_keys(keys)
  { type: type, value: value }
end