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



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

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



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

def char_no
  @char_no
end

#line_noObject (readonly)

Returns the value of attribute line_no



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

def line_no
  @line_no
end

#seekObject (readonly)

Returns the value of attribute seek



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

def seek
  @seek
end

#textObject

Returns the value of attribute text



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

def text
  @text
end

Instance Method Details

#==(other) ⇒ Object



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

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:



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

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



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

def set_text(text)
  @text = text
  self
end