module ActiveVlc::PipelineDump

Constants

TAB_WIDTH

Public Instance Methods

_dump(depth = 0) click to toggle source
# File lib/activevlc/pipeline_dump.rb, line 18
def _dump(depth = 0)
  name = instance_eval &_find_in_ancestors(:_dump_name)
  childs = instance_eval &_find_in_ancestors(:_dump_childs)

  "#{_dump_depth(depth)}+ #{name}\n" +
    childs.map { |c| c._dump(depth + 1) }.join
end
_dump_depth(depth) click to toggle source
# File lib/activevlc/pipeline_dump.rb, line 26
def _dump_depth(depth)
  ' ' * depth * TAB_WIDTH
end
_find_in_ancestors(sym) click to toggle source

FIXME Find an elegant way to do this :-/ Here we walk the ancestor array to find the one which included us first and therefore has a default _dump_name and _dump_childs. It will stops to the first ancestor which has (re)defined it.

# File lib/activevlc/pipeline_dump.rb, line 34
def _find_in_ancestors(sym)
  klass = self.class
  while klass.respond_to?(sym) and klass.superclass and not klass.send(sym)
    klass = klass.superclass
  end
  klass.send(sym)
end