Class: RDoc::RubyToken::Token
- Inherits:
-
Object
- Object
- RDoc::RubyToken::Token
- Defined in:
- lib/rdoc/ruby_token.rb
Instance Attribute Summary collapse
-
#char_no ⇒ Object
readonly
Returns the value of attribute char_no.
-
#line_no ⇒ Object
readonly
Returns the value of attribute line_no.
-
#seek ⇒ Object
readonly
Returns the value of attribute seek.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(seek, line_no, char_no, text = nil) ⇒ Token
constructor
A new instance of Token.
-
#inspect ⇒ Object
:nodoc:.
-
#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.
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_no ⇒ Object (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_no ⇒ Object (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 |
#seek ⇒ Object (readonly)
Returns the value of attribute seek
41 42 43 |
# File 'lib/rdoc/ruby_token.rb', line 41 def seek @seek end |
#text ⇒ Object
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 |
#inspect ⇒ Object
: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 |