Class: FLV::Edit::Processor::Printer

Inherits:
Object
  • Object
show all
Defined in:
lib/flv/edit/processor/printer.rb

Instance Method Summary collapse

Constructor Details

#initialize(io, options = {}) ⇒ Printer

Returns a new instance of Printer.



6
7
8
9
10
# File 'lib/flv/edit/processor/printer.rb', line 6

def initialize(io, options={})
  @io = io
  @options = {:width => 50, :column_width => 15, :separator => "| "}.merge(options)
  @margin_left = ""
end

Instance Method Details

#header(left, right) ⇒ Object



12
13
14
15
# File 'lib/flv/edit/processor/printer.rb', line 12

def header(left, right)
  @io.puts left + @options[:separator] + right
  @margin_left = " "*left.length + @options[:separator]
end

#values(hash) ⇒ Object

Prints out a hash (or any list of key-value pairs) in two columns



18
19
20
21
22
# File 'lib/flv/edit/processor/printer.rb', line 18

def values(hash)
  hash.map{|k,v| [k.to_s, v] }.sort.each do |key, value|
    @io.puts "#{@margin_left}#{key.to_s.ljust(@options[:column_width])}: #{value.inspect.delete(':"')}"
  end
end