Class: Yap::Shell::Parser::Lexer::Token
- Inherits:
-
Object
- Object
- Yap::Shell::Parser::Lexer::Token
- Includes:
- Comparable
- Defined in:
- lib/yap/shell/parser/lexer.rb
Instance Attribute Summary collapse
-
#attrs ⇒ Object
readonly
Returns the value of attribute attrs.
-
#lineno ⇒ Object
readonly
Returns the value of attribute lineno.
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(tag, value, lineno:, attrs: {}) ⇒ Token
constructor
A new instance of Token.
- #inspect ⇒ Object
- #length ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(tag, value, lineno:, attrs: {}) ⇒ Token
Returns a new instance of Token.
15 16 17 18 19 20 |
# File 'lib/yap/shell/parser/lexer.rb', line 15 def initialize(tag, value, lineno:,attrs:{}) @tag = tag @value = value @lineno = lineno @attrs = attrs end |
Instance Attribute Details
#attrs ⇒ Object (readonly)
Returns the value of attribute attrs.
13 14 15 |
# File 'lib/yap/shell/parser/lexer.rb', line 13 def attrs @attrs end |
#lineno ⇒ Object (readonly)
Returns the value of attribute lineno.
13 14 15 |
# File 'lib/yap/shell/parser/lexer.rb', line 13 def lineno @lineno end |
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
13 14 15 |
# File 'lib/yap/shell/parser/lexer.rb', line 13 def tag @tag end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
13 14 15 |
# File 'lib/yap/shell/parser/lexer.rb', line 13 def value @value end |
Instance Method Details
#<=>(other) ⇒ Object
22 23 24 25 26 |
# File 'lib/yap/shell/parser/lexer.rb', line 22 def <=>(other) return -1 if self.class != other.class return 0 if [tag, value, lineno, attrs] == [other.tag, other.value, other.lineno, other.attrs] -1 end |
#inspect ⇒ Object
28 29 30 |
# File 'lib/yap/shell/parser/lexer.rb', line 28 def inspect "#{tag.inspect} '#{value}' #{attrs.inspect}" end |
#length ⇒ Object
36 37 38 |
# File 'lib/yap/shell/parser/lexer.rb', line 36 def length to_s.length end |
#to_s ⇒ Object
32 33 34 |
# File 'lib/yap/shell/parser/lexer.rb', line 32 def to_s "Token(#{tag.inspect} #{value.inspect} on #{lineno} with #{attrs.inspect})" end |