lib/TokiCLI/view.rb in TokiCLI-0.0.2 vs lib/TokiCLI/view.rb in TokiCLI-0.0.3
- old
+ new
@@ -2,22 +2,31 @@
module TokiCLI
class View
def total_table(list)
table = init_table
table.title = "Your apps monitored by Toki"
- list.each do |k,v|
- table << ["#{k}", "#{v}"]
- end
- table
+ table_2(list, table)
end
+ def day_table(day, list)
+ table = init_table
+ table.title = "Your apps monitored by Toki on #{day}"
+ table_2(list, table)
+ end
+ def range_table(day1, day2, list)
+ table = init_table
+ table.title = "Your apps monitored by Toki between #{day1} and #{day2}"
+ table_2(list, table)
+ end
+ def hours_table(hour1, hour2, list)
+ table = init_table
+ table.title = "Your apps monitored by Toki between #{hour1} and #{hour2}"
+ table_2(list, table)
+ end
def hits_table(list)
table = init_table
table.title = "Your top apps monitored by Toki"
- list.each.with_index(1) do |obj,index|
- table << ["#{index}", "#{obj[0]}", "#{obj[1]}"]
- end
- table
+ table2_index(list, table)
end
def app_table(asked, app_data)
table = init_table
table.style = { :width => 100 }
table.title = "Toki time tracking for '#{asked}' => #{app_data.first[1][:name]}"
@@ -42,8 +51,20 @@
def init_table
Terminal::Table.new do |t|
t.style = { :width => 75 }
end
+ end
+ def table_2(list, table)
+ list.each do |k,v|
+ table << ["#{k}", "#{v}"]
+ end
+ table
+ end
+ def table2_index(list, table)
+ list.each.with_index(1) do |obj,index|
+ table << ["#{index}", "#{obj[0]}", "#{obj[1]}"]
+ end
+ table
end
end
end