Class: Rubocop::Cop::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/cop/cop.rb

Overview

A basic wrapper around Parser's tokens.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pos, type, text) ⇒ Token

Returns a new instance of Token.



9
10
11
# File 'lib/rubocop/cop/cop.rb', line 9

def initialize(pos, type, text)
  @pos, @type, @text = pos, type, text
end

Instance Attribute Details

#posObject (readonly)

Returns the value of attribute pos.



7
8
9
# File 'lib/rubocop/cop/cop.rb', line 7

def pos
  @pos
end

#textObject (readonly)

Returns the value of attribute text.



7
8
9
# File 'lib/rubocop/cop/cop.rb', line 7

def text
  @text
end

#typeObject (readonly)

Returns the value of attribute type.



7
8
9
# File 'lib/rubocop/cop/cop.rb', line 7

def type
  @type
end

Instance Method Details

#to_sObject



13
14
15
# File 'lib/rubocop/cop/cop.rb', line 13

def to_s
  "[[#{@pos.line}, #{@pos.column}], #{@type}, #{@text.inspect}]"
end