Class: FLV::Edit::Processor::Printer
- Inherits:
-
Object
- Object
- FLV::Edit::Processor::Printer
- Defined in:
- lib/flvedit/processor/printer.rb
Overview
Printer is a small utility class to print out FLV chunks.
Instance Method Summary collapse
- #header(left, right) ⇒ Object
-
#initialize(io, options = {}) ⇒ Printer
constructor
A new instance of Printer.
-
#values(hash) ⇒ Object
Prints out a hash (or any list of key-value pairs) in two columns.
Constructor Details
#initialize(io, options = {}) ⇒ Printer
Returns a new instance of Printer.
7 8 9 10 11 |
# File 'lib/flvedit/processor/printer.rb', line 7 def initialize(io, ={}) @io = io @options = {:width => 50, :column_width => 15, :separator => "| "}.merge() @margin_left = "" end |
Instance Method Details
#header(left, right) ⇒ Object
13 14 15 16 |
# File 'lib/flvedit/processor/printer.rb', line 13 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
19 20 21 22 23 |
# File 'lib/flvedit/processor/printer.rb', line 19 def values(hash) hash.each do |key, value| @io.puts "#{@margin_left}#{key.to_s.ljust(@options[:column_width])}: #{value.inspect.delete(':"')}" end end |