Class: RubyLexer::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/rubylexer/token.rb,
lib/rubylexer/tokenprinter.rb

Overview


Instance Attribute Summary collapse

Instance Method Summary collapse

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_offsetObject

hack



31
32
33
# File 'lib/rubylexer/token.rb', line 31

def allow_ooo_offset
  @allow_ooo_offset
end

#asObject

if defined, a KeywordToken which this token stands in for.



30
31
32
# File 'lib/rubylexer/token.rb', line 30

def as
  @as
end

#endlineObject

Returns the value of attribute endline.



32
33
34
# File 'lib/rubylexer/token.rb', line 32

def endline
  @endline
end

#identObject

Returns the value of attribute ident.



25
26
27
# File 'lib/rubylexer/token.rb', line 25

def ident
  @ident
end

#offsetObject

file offset of start of this token



29
30
31
# File 'lib/rubylexer/token.rb', line 29

def offset
  @offset
end

#startlineObject



46
47
48
49
# File 'lib/rubylexer/token.rb', line 46

def startline
  return @startline if defined? @startline
  return endline
end

#tagObject

Returns the value of attribute tag.



43
44
45
# File 'lib/rubylexer/token.rb', line 43

def tag
  @tag
end

Instance Method Details

#dumpObject



54
# File 'lib/rubylexer/token.rb', line 54

alias dump inspect

#errorObject



39
# File 'lib/rubylexer/token.rb', line 39

def error; end

#has_no_block?Boolean

Returns:

  • (Boolean)


41
# File 'lib/rubylexer/token.rb', line 41

def has_no_block?; false end

#inspectObject

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

#linecountObject



51
# File 'lib/rubylexer/token.rb', line 51

def linecount; 0 end

#orig_inspectObject



53
# File 'lib/rubylexer/token.rb', line 53

alias orig_inspect inspect

#to_sObject



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