Class: Postsvg::Model::Token
- Inherits:
-
Object
- Object
- Postsvg::Model::Token
- Defined in:
- lib/postsvg/model/token.rb
Overview
Lexical token. Type is one of:
:number, :operator, :name, :string, :hexstring,
:proc_open, :proc_close, :array_open, :array_close,
:dict_open, :dict_close, :dsc.
literal is true when a :name was written with a leading slash
(i.e. it is a literal name, not an operator-style name reference).
Instance Attribute Summary collapse
-
#column ⇒ Object
readonly
Returns the value of attribute column.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#literal ⇒ Object
readonly
Returns the value of attribute literal.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(type, value, line: nil, column: nil, literal: false) ⇒ Token
constructor
A new instance of Token.
- #position ⇒ Object
Constructor Details
#initialize(type, value, line: nil, column: nil, literal: false) ⇒ Token
Returns a new instance of Token.
15 16 17 18 19 20 21 22 |
# File 'lib/postsvg/model/token.rb', line 15 def initialize(type, value, line: nil, column: nil, literal: false) @type = type @value = value @line = line @column = column @literal = literal freeze end |
Instance Attribute Details
#column ⇒ Object (readonly)
Returns the value of attribute column.
13 14 15 |
# File 'lib/postsvg/model/token.rb', line 13 def column @column end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
13 14 15 |
# File 'lib/postsvg/model/token.rb', line 13 def line @line end |
#literal ⇒ Object (readonly)
Returns the value of attribute literal.
13 14 15 |
# File 'lib/postsvg/model/token.rb', line 13 def literal @literal end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
13 14 15 |
# File 'lib/postsvg/model/token.rb', line 13 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
13 14 15 |
# File 'lib/postsvg/model/token.rb', line 13 def value @value end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
28 29 30 31 32 33 34 35 |
# File 'lib/postsvg/model/token.rb', line 28 def ==(other) other.is_a?(Token) && other.type == @type && other.value == @value && other.line == @line && other.column == @column && other.literal == @literal end |
#hash ⇒ Object
38 39 40 |
# File 'lib/postsvg/model/token.rb', line 38 def hash [@type, @value, @line, @column, @literal].hash end |
#position ⇒ Object
24 25 26 |
# File 'lib/postsvg/model/token.rb', line 24 def position [line, column] end |