Class: AocCli::Progress

Inherits:
Kangaru::Model
  • Object
show all
Defined in:
lib/aoc_cli/models/progress.rb

Instance Method Summary collapse

Instance Method Details

#complete!Object



17
18
19
# File 'lib/aoc_cli/models/progress.rb', line 17

def complete!
  update(completed_at: Time.now)
end

#complete?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/aoc_cli/models/progress.rb', line 9

def complete?
  !incomplete?
end

#incomplete?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/aoc_cli/models/progress.rb', line 13

def incomplete?
  completed_at.nil?
end

#reset!Object



21
22
23
# File 'lib/aoc_cli/models/progress.rb', line 21

def reset!
  update(started_at: Time.now)
end

#time_takenObject



25
26
27
28
29
30
31
# File 'lib/aoc_cli/models/progress.rb', line 25

def time_taken
  if complete?
    completed_at - started_at
  else
    Time.now - started_at
  end
end