Sha256: a9e0c06bde201a1cf4cc23c292b4a14871bc482add53546cf68df780b9b83b3d

Contents?: true

Size: 942 Bytes

Versions: 4

Compression:

Stored size: 942 Bytes

Contents

module Luobo
  ## this class holds a block of carrot source code tokenized by the parser.
  class Token
    attr_accessor :ln, :line, :indent_level, :processor_name, :line_code, :block_code

    def initialize ln, line, indent_level, processor_name, line_code, block_code, proc_head = ''
      @ln, @line, @indent_level, @processor_name, @line_code, @block_code, @proc_head = ln, line, indent_level, processor_name, line_code, block_code, proc_head
    end
  
    # add a line to current block args, separate each line with "\n"
    def add_block_code line
      line.chomp!
      unless processor_name == '_raw'
        line.gsub!(/^#{@proc_head}/, '')
      end

      if self.block_code 
        self.block_code += "\n" + line
      else
        self.block_code = line
      end
    end

    def block_args
      YAML.load(block_code)
    end

    def line_args
      YAML.load(line_code)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
luobo-0.1.3 backup/lib/luobo/token.rb
luobo-0.1.2 backup/lib/luobo/token.rb
luobo-0.0.5 backup/lib/luobo/token.rb
luobo-0.1.0 backup/lib/luobo/token.rb