Module: Ripper::RubyBuilder::String
- Included in:
- Ripper::RubyBuilder
- Defined in:
- lib/ripper/ruby_builder/events/string.rb
Instance Method Summary collapse
- #on_heredoc_beg(*args) ⇒ Object
- #on_heredoc_end(token) ⇒ Object
- #on_heredoc_literal(*args) ⇒ Object
- #on_heredoc_new ⇒ Object
- #on_regexp_literal(string, rdelim) ⇒ Object
- #on_string_add(string, content) ⇒ Object
- #on_string_concat(*strings) ⇒ Object
- #on_string_content(*args) ⇒ Object
- #on_string_dvar(variable) ⇒ Object
- #on_string_embexpr(expression) ⇒ Object
- #on_string_literal(string) ⇒ Object
- #on_word_add(string, word) ⇒ Object
- #on_word_new ⇒ Object
- #on_xstring_add(string, content) ⇒ Object
- #on_xstring_literal(string, type = :@tstring_end) ⇒ Object
- #on_xstring_new(*args) ⇒ Object
Instance Method Details
#on_heredoc_beg(*args) ⇒ Object
71 72 73 74 |
# File 'lib/ripper/ruby_builder/events/string.rb', line 71 def on_heredoc_beg(*args) token = push(super) on_heredoc_new end |
#on_heredoc_end(token) ⇒ Object
76 77 78 79 |
# File 'lib/ripper/ruby_builder/events/string.rb', line 76 def on_heredoc_end(token) string_stack.last.rdelim = Ruby::Token.new(token, position) nil end |
#on_heredoc_literal(*args) ⇒ Object
63 64 65 |
# File 'lib/ripper/ruby_builder/events/string.rb', line 63 def on_heredoc_literal(*args) string_stack.flush.each { |heredoc| push([:@heredoc, heredoc]) } end |
#on_heredoc_new ⇒ Object
67 68 69 |
# File 'lib/ripper/ruby_builder/events/string.rb', line 67 def on_heredoc_new string_stack << Ruby::Heredoc.new end |
#on_regexp_literal(string, rdelim) ⇒ Object
36 37 38 |
# File 'lib/ripper/ruby_builder/events/string.rb', line 36 def on_regexp_literal(string, rdelim) on_xstring_literal(string, rdelim.type) end |
#on_string_add(string, content) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/ripper/ruby_builder/events/string.rb', line 14 def on_string_add(string, content) content = pop_string_content unless content target = heredoc? ? string_stack.last : string target << content string end |
#on_string_concat(*strings) ⇒ Object
4 5 6 |
# File 'lib/ripper/ruby_builder/events/string.rb', line 4 def on_string_concat(*strings) Ruby::StringConcat.new(strings) end |
#on_string_content(*args) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/ripper/ruby_builder/events/string.rb', line 21 def on_string_content(*args) if token = pop_token(:@heredoc_beg) Ruby::HeredocBegin.new(token.token, token.position, token.prolog) else string_stack << Ruby::String.new(nil, pop_token(:@tstring_beg)) string_stack.last end end |
#on_string_dvar(variable) ⇒ Object
87 88 89 90 91 92 |
# File 'lib/ripper/ruby_builder/events/string.rb', line 87 def on_string_dvar(variable) variable = Ruby::DelimitedVariable.new(variable.to_identifier) ldelim = pop_token(:@embvar) variable.ldelim = ldelim variable end |
#on_string_embexpr(expression) ⇒ Object
81 82 83 84 85 |
# File 'lib/ripper/ruby_builder/events/string.rb', line 81 def on_string_embexpr(expression) expression.ldelim = pop_token(:@embexpr_beg) expression.rdelim = pop_token(:@rbrace) expression end |
#on_string_literal(string) ⇒ Object
8 9 10 11 12 |
# File 'lib/ripper/ruby_builder/events/string.rb', line 8 def on_string_literal(string) string_stack.pop if string == string_stack.last string.rdelim = pop_token(:@tstring_end) if string.respond_to?(:rdelim) string end |
#on_word_add(string, word) ⇒ Object
58 59 60 61 |
# File 'lib/ripper/ruby_builder/events/string.rb', line 58 def on_word_add(string, word) word = pop_string_content unless word string << word end |
#on_word_new ⇒ Object
54 55 56 |
# File 'lib/ripper/ruby_builder/events/string.rb', line 54 def on_word_new Ruby::String.new end |
#on_xstring_add(string, content) ⇒ Object
50 51 52 |
# File 'lib/ripper/ruby_builder/events/string.rb', line 50 def on_xstring_add(string, content) on_string_add(string, content) end |
#on_xstring_literal(string, type = :@tstring_end) ⇒ Object
30 31 32 33 34 |
# File 'lib/ripper/ruby_builder/events/string.rb', line 30 def on_xstring_literal(string, type = :@tstring_end) string_stack.pop if string == string_stack.last string.rdelim = pop_token(type) if string.respond_to?(:rdelim) string end |
#on_xstring_new(*args) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/ripper/ruby_builder/events/string.rb', line 40 def on_xstring_new(*args) if token = pop_token(:@heredoc_beg) Ruby::HeredocBegin.new(token.token, token.position, token.prolog) else ldelim = pop(:@symbeg, :@backtick, :@regexp_beg, :max => 1, :pass => true).first string_stack << build_xstring(ldelim) string_stack.last end end |