Class: JsonToTableDisplayer
- Inherits:
-
Object
- Object
- JsonToTableDisplayer
- Defined in:
- lib/json_to_table_displayer.rb
Instance Method Summary collapse
-
#initialize(json) ⇒ JsonToTableDisplayer
constructor
A new instance of JsonToTableDisplayer.
- #print_terminal_child_tables ⇒ Object
- #print_terminal_table ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(json) ⇒ JsonToTableDisplayer
Returns a new instance of JsonToTableDisplayer.
5 6 7 8 |
# File 'lib/json_to_table_displayer.rb', line 5 def initialize(json) @object = JSON.parse(json) @table = JsonToTable::Table.new(@object) end |
Instance Method Details
#print_terminal_child_tables ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/json_to_table_displayer.rb', line 20 def print_terminal_child_tables @table.child_hashes.each do |child_hash| key = child_hash.keys.first puts "\n#{key}" child_table = JsonToTable::Table.new(child_hash[key]) puts child_table.terminal_table @table.child_hashes.concat child_table.child_hashes end end |
#print_terminal_table ⇒ Object
16 17 18 |
# File 'lib/json_to_table_displayer.rb', line 16 def print_terminal_table puts @table.terminal_table end |
#run ⇒ Object
10 11 12 13 14 |
# File 'lib/json_to_table_displayer.rb', line 10 def run print_terminal_table print_terminal_child_tables end |