Class: Timekeeper::Viewer

Inherits:
Object
  • Object
show all
Defined in:
lib/timekeeper/viewer.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.export(records, name = "timekeeper", type = :csv) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/timekeeper/viewer.rb', line 17

def self.export(records, name="timekeeper", type= :csv)
  if records.any?
    case type.to_s
    when "csv"
      FasterCSV.open("#{name}.#{type}", "w") do |csv|    
        csv << records[0].keys
        records.each do |record|
          csv << record.values
        end
      end
    end
  end
end

Instance Method Details

#allObject



9
10
11
# File 'lib/timekeeper/viewer.rb', line 9

def all
  tables.collect{|table| table.query.collect{|attrs| Keep.new(attrs)}}.flatten!
end

#closeObject



13
14
15
# File 'lib/timekeeper/viewer.rb', line 13

def close
  tables.each {|table| table.close}
end

#config(file = "timekeeper.yml") ⇒ Object



5
6
7
# File 'lib/timekeeper/viewer.rb', line 5

def config(file="timekeeper.yml")
  @config ||= YAML.load_file(file)
end