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

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

Constructor Details

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

Returns a new instance of HerePlaceholderToken.



516
517
518
519
520
521
522
523
524
525
# File 'lib/rubylexer/token.rb', line 516

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.



513
514
515
# File 'lib/rubylexer/token.rb', line 513

def bodyclass
  @bodyclass
end

#closeObject

Returns the value of attribute close.



514
515
516
# File 'lib/rubylexer/token.rb', line 514

def close
  @close
end

#dashObject (readonly)

Returns the value of attribute dash.



511
512
513
# File 'lib/rubylexer/token.rb', line 511

def dash
  @dash
end

#enderObject (readonly)

Returns the value of attribute ender.



511
512
513
# File 'lib/rubylexer/token.rb', line 511

def ender
  @ender
end

#openObject

Returns the value of attribute open.



514
515
516
# File 'lib/rubylexer/token.rb', line 514

def open
  @open
end

#quoteObject (readonly)

Returns the value of attribute quote.



511
512
513
# File 'lib/rubylexer/token.rb', line 511

def quote
  @quote
end

#stringObject

Returns the value of attribute string.



512
513
514
# File 'lib/rubylexer/token.rb', line 512

def string
  @string
end

#termexObject (readonly)

Returns the value of attribute termex.



511
512
513
# File 'lib/rubylexer/token.rb', line 511

def termex
  @termex
end

#unsafe_to_useObject

Returns the value of attribute unsafe_to_use.



512
513
514
# File 'lib/rubylexer/token.rb', line 512

def unsafe_to_use
  @unsafe_to_use
end

Instance Method Details

#===(bogus) ⇒ Object



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

def ===(bogus); false end

#append(s) ⇒ Object



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

def append s; @string.append s end

#append_token(tok) ⇒ Object



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

def append_token tok; @string.append_token tok  end

#lineObject

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



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

def line; @line || @string.line end

#line=(line) ⇒ Object



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

def line=line; @line=line end

#startlineObject Also known as: endline



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

def startline; @line end

#startline=(x) ⇒ Object Also known as: endline=



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

def startline=x; end

#to_sObject



529
530
531
532
533
534
535
536
537
538
539
540
541
# File 'lib/rubylexer/token.rb', line 529

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