Class: SyntaxTree::ERB::Token
Overview
A Token is any kind of lexical token from the source. It has a type, a value which is a subset of the source, and an index where it starts in the source.
Instance Attribute Summary collapse
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(type:, value:, location:) ⇒ Token
constructor
A new instance of Token.
Methods inherited from Node
#format, #pretty_print, #skip?, #without_new_line
Constructor Details
#initialize(type:, value:, location:) ⇒ Token
Returns a new instance of Token.
30 31 32 33 34 |
# File 'lib/syntax_tree/erb/nodes.rb', line 30 def initialize(type:, value:, location:) @type = type @value = value @location = location end |
Instance Attribute Details
#location ⇒ Object (readonly)
Returns the value of attribute location.
28 29 30 |
# File 'lib/syntax_tree/erb/nodes.rb', line 28 def location @location end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
28 29 30 |
# File 'lib/syntax_tree/erb/nodes.rb', line 28 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
28 29 30 |
# File 'lib/syntax_tree/erb/nodes.rb', line 28 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
36 37 38 |
# File 'lib/syntax_tree/erb/nodes.rb', line 36 def accept(visitor) visitor.visit_token(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
40 41 42 |
# File 'lib/syntax_tree/erb/nodes.rb', line 40 def child_nodes [] end |
#deconstruct_keys(keys) ⇒ Object
46 47 48 |
# File 'lib/syntax_tree/erb/nodes.rb', line 46 def deconstruct_keys(keys) { type: type, value: value, location: location } end |