Class: RuboCop::Token
- Inherits:
-
Object
- Object
- RuboCop::Token
- Defined in:
- lib/rubocop/token.rb
Overview
A basic wrapper around Parser’s tokens.
Instance Attribute Summary collapse
-
#pos ⇒ Object
readonly
Returns the value of attribute pos.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(pos, type, text) ⇒ Token
constructor
A new instance of Token.
- #to_s ⇒ Object
Constructor Details
#initialize(pos, type, text) ⇒ Token
Returns a new instance of Token.
15 16 17 18 19 20 |
# File 'lib/rubocop/token.rb', line 15 def initialize(pos, type, text) @pos = pos @type = type # Parser token "text" may be a Fixnum @text = text.to_s end |
Instance Attribute Details
#pos ⇒ Object (readonly)
Returns the value of attribute pos.
7 8 9 |
# File 'lib/rubocop/token.rb', line 7 def pos @pos end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
7 8 9 |
# File 'lib/rubocop/token.rb', line 7 def text @text end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/rubocop/token.rb', line 7 def type @type end |
Class Method Details
.from_parser_token(parser_token) ⇒ Object
9 10 11 12 13 |
# File 'lib/rubocop/token.rb', line 9 def self.from_parser_token(parser_token) type, details = parser_token text, range = details new(range, type, text) end |
Instance Method Details
#to_s ⇒ Object
22 23 24 |
# File 'lib/rubocop/token.rb', line 22 def to_s "[[#{@pos.line}, #{@pos.column}], #{@type}, #{@text.inspect}]" end |