Class: Hocon::Impl::Token
- Inherits:
-
Object
- Object
- Hocon::Impl::Token
- Defined in:
- lib/hocon/impl/token.rb
Instance Attribute Summary collapse
-
#origin ⇒ Object
readonly
Returns the value of attribute origin.
-
#token_text ⇒ Object
readonly
Returns the value of attribute token_text.
-
#token_type ⇒ Object
readonly
Returns the value of attribute token_type.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #hash ⇒ Object
-
#initialize(token_type, origin, token_text = nil, debug_string = nil) ⇒ Token
constructor
A new instance of Token.
- #line_number ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(token_type, origin, token_text = nil, debug_string = nil) ⇒ Token
Returns a new instance of Token.
12 13 14 15 16 17 |
# File 'lib/hocon/impl/token.rb', line 12 def initialize(token_type, origin, token_text = nil, debug_string = nil) @token_type = token_type @origin = origin @token_text = token_text @debug_string = debug_string end |
Instance Attribute Details
#origin ⇒ Object (readonly)
Returns the value of attribute origin.
19 20 21 |
# File 'lib/hocon/impl/token.rb', line 19 def origin @origin end |
#token_text ⇒ Object (readonly)
Returns the value of attribute token_text.
7 8 9 |
# File 'lib/hocon/impl/token.rb', line 7 def token_text @token_text end |
#token_type ⇒ Object (readonly)
Returns the value of attribute token_type.
7 8 9 |
# File 'lib/hocon/impl/token.rb', line 7 def token_type @token_type end |
Class Method Details
Instance Method Details
#==(other) ⇒ Object
37 38 39 40 |
# File 'lib/hocon/impl/token.rb', line 37 def ==(other) # @origin deliberately left out other.is_a?(Hocon::Impl::Token) && @token_type == other.token_type end |
#hash ⇒ Object
42 43 44 |
# File 'lib/hocon/impl/token.rb', line 42 def hash @token_type.hash end |
#line_number ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/hocon/impl/token.rb', line 21 def line_number if @origin @origin.line_number else -1 end end |
#to_s ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/hocon/impl/token.rb', line 29 def to_s if !@debug_string.nil? @debug_string else Hocon::Impl::TokenType.token_type_name(@token_type) end end |