Class: RubyLexer::NumberToken

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

Overview


Instance Attribute Summary collapse

Attributes inherited from Token

#allow_ooo_offset, #as, #endline, #ident, #offset, #startline, #tag

Instance Method Summary collapse

Methods inherited from Token

#dump, #error, #has_no_block?, #initialize, #inspect, #linecount, #orig_inspect, #ws_munge

Constructor Details

This class inherits a constructor from RubyLexer::Token

Instance Attribute Details

#char_literalObject

Returns the value of attribute char_literal.



206
207
208
# File 'lib/rubylexer/token.rb', line 206

def char_literal
  @char_literal
end

Instance Method Details

#negativeObject



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

def negative; /\A-/ === to_s end

#to_sObject



193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/rubylexer/token.rb', line 193

def to_s
  if defined? @char_literal and @char_literal
    chr=@ident.chr
    '?'+case chr
        when " "; '\s'
        when /[!-~]/; chr 
        else chr.inspect[1...-1]
        end
  else
    @ident.to_s 
  end
end