Class: RubyLexer::HerePlaceholderToken

Inherits:
WToken show all
Defined in:
lib/rubylexer/token.rb

Overview


Instance Attribute Summary collapse

Attributes inherited from Token

#allow_ooo_offset, #as, #ident, #offset, #tag

Instance Method Summary collapse

Methods inherited from Token

#error, #has_no_block?, #ws_munge

Constructor Details

#initialize(dash, quote, ender, quote_real = true) ⇒ HerePlaceholderToken

Returns a new instance of HerePlaceholderToken.



441
442
443
444
445
446
447
448
449
450
# File 'lib/rubylexer/token.rb', line 441

def initialize(dash,quote,ender,quote_real=true)
   @dash,@quote,@ender,@quote_real=dash,quote,ender,quote_real
   @unsafe_to_use=true
   @string=StringToken.new

   #@termex=/^#{'[\s\v]*' if dash}#{Regexp.escape ender}$/
   @termex=Regexp.new \
      ["^", ('[\s\v]*' if dash), Regexp.escape(ender), "$"].join
   @bodyclass=HereBodyToken
end

Instance Attribute Details

#bodyclassObject

Returns the value of attribute bodyclass.



438
439
440
# File 'lib/rubylexer/token.rb', line 438

def bodyclass
  @bodyclass
end

#closeObject

Returns the value of attribute close.



439
440
441
# File 'lib/rubylexer/token.rb', line 439

def close
  @close
end

#dashObject (readonly)

Returns the value of attribute dash.



436
437
438
# File 'lib/rubylexer/token.rb', line 436

def dash
  @dash
end

#enderObject (readonly)

Returns the value of attribute ender.



436
437
438
# File 'lib/rubylexer/token.rb', line 436

def ender
  @ender
end

#openObject

Returns the value of attribute open.



439
440
441
# File 'lib/rubylexer/token.rb', line 439

def open
  @open
end

#quoteObject (readonly)

Returns the value of attribute quote.



436
437
438
# File 'lib/rubylexer/token.rb', line 436

def quote
  @quote
end

#stringObject

Returns the value of attribute string.



437
438
439
# File 'lib/rubylexer/token.rb', line 437

def string
  @string
end

#termexObject (readonly)

Returns the value of attribute termex.



436
437
438
# File 'lib/rubylexer/token.rb', line 436

def termex
  @termex
end

#unsafe_to_useObject

Returns the value of attribute unsafe_to_use.



437
438
439
# File 'lib/rubylexer/token.rb', line 437

def unsafe_to_use
  @unsafe_to_use
end

Instance Method Details

#===(bogus) ⇒ Object



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

def ===(bogus); false end

#append(s) ⇒ Object



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

def append s; @string.append s end

#append_token(tok) ⇒ Object



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

def append_token tok; @string.append_token tok  end

#lineObject

def with_line(line) @string.line=line; self end



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

def line; @string.line end

#line=(line) ⇒ Object



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

def line=line; @string.line=line end

#to_sObject



454
455
456
457
458
459
460
461
462
463
464
465
466
# File 'lib/rubylexer/token.rb', line 454

def to_s
#      if @bodyclass==OutlinedHereBodyToken
     result=if/[^a-z_0-9]/i===@ender
       @ender.gsub(/[\\"]/, '\\\\'+'\\&')
     else
       @ender
     end
     return ["<<",@dash,@quote_real&&@quote,result,@quote_real&&@quote].join
#      else
#        assert !unsafe_to_use
#        return @string.to_s
#      end
end