Sha256: 5c3400d85b0dda9e4754a3b450a1adaabeeeb202307bbd814653aaa8107fa04b
Contents?: true
Size: 1.98 KB
Versions: 1
Compression:
Stored size: 1.98 KB
Contents
# encoding: utf-8 module TokiCLI class View def total_table(list) table = init_table table.title = "Your apps monitored by Toki" 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" 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]}" table.headings = ['From', 'To', 'Duration', 'Sync id'] @index = 0 @length = app_data.length - 1 @total = app_data.select {|k,v| k == 'total'} app_data.delete('total') data = app_data.to_a data.sort_by! {|k,v| v[:raw_from] } data.each do |id, log| @index += 1 table << ["#{log[:from]}", "#{log[:to]}", "#{log[:duration]}", "#{id}"] table << :separator unless @index == @length end table << :separator table << [{ :value => "Total: #{@total['total']}", :colspan => 4, :alignment => :center }] table end private 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
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
TokiCLI-0.0.3 | lib/TokiCLI/view.rb |