Class: RDoc::RubyToken::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/rdoc/ruby_token.rb

Direct Known Subclasses

TkError, TkId, TkNode, TkOp, TkUnknownChar, TkVal

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(seek, line_no, char_no, text = nil) ⇒ Token

Returns a new instance of Token.



35
36
37
38
39
40
# File 'lib/rdoc/ruby_token.rb', line 35

def initialize(seek, line_no, char_no, text = nil)
  @seek = seek
  @line_no = line_no
  @char_no = char_no
  @text = text
end

Instance Attribute Details

#char_noObject (readonly)

Returns the value of attribute char_no



44
45
46
# File 'lib/rdoc/ruby_token.rb', line 44

def char_no
  @char_no
end

#line_noObject (readonly)

Returns the value of attribute line_no



43
44
45
# File 'lib/rdoc/ruby_token.rb', line 43

def line_no
  @line_no
end

#seekObject (readonly)

Returns the value of attribute seek



42
43
44
# File 'lib/rdoc/ruby_token.rb', line 42

def seek
  @seek
end

#textObject

Returns the value of attribute text



46
47
48
# File 'lib/rdoc/ruby_token.rb', line 46

def text
  @text
end

Instance Method Details

#==(other) ⇒ Object



48
49
50
51
52
53
# File 'lib/rdoc/ruby_token.rb', line 48

def ==(other)
  self.class == other.class and
  other.line_no == @line_no and
  other.char_no == @char_no and
  other.text == @text
end

#inspectObject

:nodoc:



64
65
66
67
# File 'lib/rdoc/ruby_token.rb', line 64

def inspect # :nodoc:
  klass = self.class.name.split('::').last
  "{%s %d, %d:%d %p}" % [klass, @seek, @line_no, @char_no, @text]
end

#set_text(text) ⇒ Object

Because we’re used in contexts that expect to return a token, we set the text string and then return ourselves



59
60
61
62
# File 'lib/rdoc/ruby_token.rb', line 59

def set_text(text)
  @text = text
  self
end