Sha256: 0ec5d355c136da47ee0891f66046d067755e62f80cfe94e50d0ac0d590ca7b44

Contents?: true

Size: 869 Bytes

Versions: 1

Compression:

Stored size: 869 Bytes

Contents

module YARD
  module Parser
    class Statement 
      attr_reader :tokens, :comments, :block

      def initialize(tokens, block = nil, comments = nil)
        @tokens = tokens
        @block  = block
        @comments = comments
      end
      
      def inspect(lines = nil)
        flineno = tokens.first.line_no
        buf = [""]
        tokens.each do |tk|
          if tk.is_a?(RubyToken::TkNL)
            buf.push ""
          else
            buf.last << tk.text
          end
        end
        buf.map {|line| "\t#{flineno}: #{line}" }.join("\n")
      end

      private
        def clean_tokens(tokens)
          last_tk = nil
          tokens.reject do |tk| 
            tk.is_a?(RubyToken::TkNL) || 
            (last_tk.is_a?(RubyToken::TkSPACE) && 
            last_tk.class == tk.class) && last_tk = tk 
          end
        end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yard-0.2.2 lib/yard/parser/statement.rb