Class: Tempo::Controllers::End

Inherits:
Base
  • Object
show all
Defined in:
lib/tempo/controllers/end_controller.rb

Class Method Summary collapse

Methods inherited from Base

filter_projects_by_title, fuzzy_match, reassemble_the

Class Method Details

.end_timer(options, args) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/tempo/controllers/end_controller.rb', line 11

def end_timer(options, args)

  return Views.project_assistance if Model::Project.index.empty?

  if not options[:at]
    time_out = Time.new().round
  else
    time_out = Time.parse options[:at]
  end

  return Views.no_match_error( "valid timeframe", options[:at], false ) if not time_out

  options[:end_time] = time_out
  options[:description] = reassemble_the args

  @time_records.load_last_day options
  record = @time_records.current
  return Views.no_items( "running time records", :error ) if ! record

  record.end_time = time_out
  record.description = options[:description] if options[:description]
  @time_records.save_to_file options

  Views.end_time_record_view record

end