class SheepAst::NodeBuf
log buffer corresponded to the Node
@api private
Attributes
action[RW]
match[RW]
Public Class Methods
buffer_init()
click to toggle source
# File lib/sheep_ast/node_buf.rb, line 82 def buffer_init @@buffer = +'' end
new(matches, match, chain_id, group)
click to toggle source
Calls superclass method
SheepAst::Log::new
# File lib/sheep_ast/node_buf.rb, line 29 def initialize(matches, match, chain_id, group) @@buffer = +'' @@dump_width = 20 @matches = matches @match = match @chain_id = chain_id @my_group = group super() end
Public Instance Methods
dump_buffer(logs)
click to toggle source
# File lib/sheep_ast/node_buf.rb, line 69 def dump_buffer(logs) logf = method(logs) @@buffer.each_line do |line| unless /^\s*$/ =~ line logf.call line.chomp, :cyan end end end
reg_action(action)
click to toggle source
# File lib/sheep_ast/node_buf.rb, line 40 def reg_action(action) application_error 'Action duplicated' unless @action.nil? @action = action end
save_tree_from_here()
click to toggle source
# File lib/sheep_ast/node_buf.rb, line 46 def save_tree_from_here if !@match.nil? expr = "(#{@match.kind_name})#{@match.key.inspect}" end if !expr.nil? @@buffer << expr.ljust(@@dump_width).slice(0, @@dump_width) @@buffer << ' -> ' end @matches.each do |_, a_node| a_node.node_buffer.save_tree_from_here @@buffer << "\n" @@buffer << ' '.dup * (@@dump_width + 4) * @chain_id end unless @action.nil? @@buffer << @action.description @@buffer << " [name: #{@my_group}]" end end