class FlameChannelParser::Inspector

Prints out a viewable tree of channel metadata. Useful when you need to inspect comparable setups for small differentces in channel ordering and animation.

Public Class Methods

new(channels_arr) click to toggle source
# File lib/inspector.rb, line 5
def initialize(channels_arr)
  @branches = OH.new
  channels_arr.each {|c| cluster(c) }
end

Public Instance Methods

pretty_print(output = $stdout) click to toggle source
# File lib/inspector.rb, line 10
def pretty_print(output = $stdout)
  @out = output
  print_branch(@branches, initial_indent = 0)
end

Private Instance Methods

channel_metadata(channel) click to toggle source
# File lib/inspector.rb, line 49
def channel_metadata(channel)
  if channel.length.zero?
    "no animations, value %s" % [channel.base_value]
  elsif channel.length > 1
    first_key = channel[0].frame
    last_key = channel[-1].frame
    "animated, %d keys, first at %d last at %d" % [channel.length, first_key, last_key]
  else
    first_key = channel[0].frame
    "animated, 1 key at %d, value %s" % [first_key, channel[0].value]
  end
end
cluster(channel) click to toggle source
# File lib/inspector.rb, line 62
def cluster(channel)
  path_parts = channel.name.split('/')
  leaf_name = path_parts.pop

  current = @branches
  path_parts.each do | path_part |
    current[path_part] ||= OH.new
    current = current[path_part]
  end
  current[leaf_name] = channel
end
print_branch(branch, indent) click to toggle source
puts(string) click to toggle source
# File lib/inspector.rb, line 34
def puts(string)
  @out.puts(string)
end