Module: Doro::Entries

Defined in:
lib/doro/entries.rb

Class Method Summary collapse

Class Method Details

.add_entry(doro_file: "#{Dir.home}/.doro", task_name: 'none', minutes: 25, start_time:, tag: 'untagged') ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/doro/entries.rb', line 23

def self.add_entry(
  doro_file: "#{Dir.home}/.doro",
  task_name: 'none',
  minutes: 25,
  start_time:,
  tag: 'untagged')
  CSV.open(doro_file, "ab") do |csv|
    csv << [task_name, minutes, start_time.to_s, tag]
  end
end

.display_entries(doro_file: "#{Dir.home}/.doro", num_entries: 10) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/doro/entries.rb', line 6

def self.display_entries(doro_file: "#{Dir.home}/.doro", num_entries: 10)
  rows = []
  start_index = num_entries

  CSV.foreach doro_file do |row|
    rows << row
  end

  if rows.size < num_entries
    start_index = rows.size
  end

  start_index *= -1

  pp rows[start_index..-1]
end