method

on_heredoc_dedent

Importance_0
v2_6_3 - Show latest stable - 0 notes - Class: Lexer
on_heredoc_dedent(v, w) private

No documentation

This method has no description. You can help the Ruby community by adding new notes.

Hide source
# File ext/ripper/lib/ripper/lexer.rb, line 92
    def on_heredoc_dedent(v, w)
      ignored_sp = []
      heredoc = @buf.last
      heredoc.each_with_index do |e, i|
        if Elem === e and e.event == :on_tstring_content and e.pos[1].zero?
          tok = e.tok.dup if w > 0 and /\A\s/ =~ e.tok
          if (n = dedent_string(e.tok, w)) > 0
            if e.tok.empty?
              e.tok = tok[0, n]
              e.event = :on_ignored_sp
              next
            end
            ignored_sp << [i, Elem.new(e.pos.dup, :on_ignored_sp, tok[0, n], e.state)]
            e.pos[1] += n
          end
        end
      end
      ignored_sp.reverse_each do |i, e|
        heredoc[i, 0] = [e]
      end
      v
    end
Register or log in to add new notes.