Class: RubyLexer::Token
- Inherits:
-
Object
- Object
- RubyLexer::Token
- Defined in:
- lib/rubylexer/token.rb,
lib/rubylexer/tokenprinter.rb
Overview
Direct Known Subclasses
EoiToken, IgnoreToken, MethNameToken, NewlineToken, NumberToken, RubyCode, StringToken, SubitemToken, SymbolToken, WToken
Instance Attribute Summary collapse
-
#allow_ooo_offset ⇒ Object
hack.
-
#as ⇒ Object
if defined, a KeywordToken which this token stands in for.
-
#endline ⇒ Object
Returns the value of attribute endline.
-
#ident ⇒ Object
Returns the value of attribute ident.
-
#offset ⇒ Object
file offset of start of this token.
- #startline ⇒ Object
-
#tag ⇒ Object
Returns the value of attribute tag.
Instance Method Summary collapse
- #dump ⇒ Object
- #error ⇒ Object
- #has_no_block? ⇒ Boolean
-
#initialize(ident, offset = nil) ⇒ Token
constructor
A new instance of Token.
-
#inspect ⇒ Object
this is merely the normal definition of inspect and is unneeded in ruby 1.8 but in 1.9, defining to_s seemingly overrides the built-in Object#inspect and you can’t get it back, no matter what.
- #linecount ⇒ Object
- #orig_inspect ⇒ Object
- #to_s ⇒ Object
- #ws_munge(tp) ⇒ Object
Constructor Details
#initialize(ident, offset = nil) ⇒ Token
Returns a new instance of Token.
34 35 36 37 |
# File 'lib/rubylexer/token.rb', line 34 def initialize(ident,offset=nil) @ident=ident @offset=offset end |
Instance Attribute Details
#allow_ooo_offset ⇒ Object
hack
31 32 33 |
# File 'lib/rubylexer/token.rb', line 31 def allow_ooo_offset @allow_ooo_offset end |
#as ⇒ Object
if defined, a KeywordToken which this token stands in for.
30 31 32 |
# File 'lib/rubylexer/token.rb', line 30 def as @as end |
#endline ⇒ Object
Returns the value of attribute endline.
32 33 34 |
# File 'lib/rubylexer/token.rb', line 32 def endline @endline end |
#ident ⇒ Object
Returns the value of attribute ident.
25 26 27 |
# File 'lib/rubylexer/token.rb', line 25 def ident @ident end |
#offset ⇒ Object
file offset of start of this token
29 30 31 |
# File 'lib/rubylexer/token.rb', line 29 def offset @offset end |
#startline ⇒ Object
46 47 48 49 |
# File 'lib/rubylexer/token.rb', line 46 def startline return @startline if defined? @startline return endline end |
#tag ⇒ Object
Returns the value of attribute tag.
43 44 45 |
# File 'lib/rubylexer/token.rb', line 43 def tag @tag end |
Instance Method Details
#dump ⇒ Object
54 |
# File 'lib/rubylexer/token.rb', line 54 alias dump inspect |
#error ⇒ Object
39 |
# File 'lib/rubylexer/token.rb', line 39 def error; end |
#has_no_block? ⇒ Boolean
41 |
# File 'lib/rubylexer/token.rb', line 41 def has_no_block?; false end |
#inspect ⇒ Object
this is merely the normal definition of inspect and is unneeded in ruby 1.8 but in 1.9, defining to_s seemingly overrides the built-in Object#inspect and you can’t get it back, no matter what. fucking 1.9
61 62 63 64 65 66 |
# File 'lib/rubylexer/token.rb', line 61 def inspect ivars=instance_variables.map{|ivar| ivar.to_s+'='+instance_variable_get(ivar).inspect }.join(' ') %[#<#{self.class}: #{ivars}>] end |
#linecount ⇒ Object
51 |
# File 'lib/rubylexer/token.rb', line 51 def linecount; 0 end |
#orig_inspect ⇒ Object
53 |
# File 'lib/rubylexer/token.rb', line 53 alias orig_inspect inspect |
#to_s ⇒ Object
26 27 28 |
# File 'lib/rubylexer/token.rb', line 26 def to_s @ident || "<#{self.class.name}>" end |
#ws_munge(tp) ⇒ Object
99 100 101 |
# File 'lib/rubylexer/tokenprinter.rb', line 99 def ws_munge(tp) nil end |