Sha256: 57ed7d94b77d7d7c005d1e4226d20c9d0c5988583387fe685b95b907eb8cb5f3
Contents?: true
Size: 1023 Bytes
Versions: 1
Compression:
Stored size: 1023 Bytes
Contents
## this class holds a block of carrot source code tokenized by the parser. class Token attr_accessor :ln, :line, :indent_level, # raw line and line number :processor_name, :line_code, :blocks, :indent_level def initialize ln, line, indent_level, processor_name, line_code = '', block_open = false @ln, @line, @indent_level, @processor_name, @line_code = ln, line, indent_level, processor_name, line_code @blocks = Array.new if block_open end # add a line to current block args, separate each line with "\n" def add_block_code line raise "block not opened in line #{:ln}" unless block_open? line.chomp.split("\n").each do |ln| @blocks << ln end end def has_block? (@blocks and @blocks.size > 0) ? true : false end def block_open? @blocks.is_a?(Array) end def block_code has_block? ? @blocks.join("\n") : "" end def block_args YAML.load(block_code) end def line_args YAML.load(line_code) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
luobo-0.1.0 | lib/luobo/token.rb |