Class: Session

Inherits:
Sequel::Model
  • Object
show all
Defined in:
lib/kale/session.rb

Instance Method Summary collapse

Constructor Details

#initializeSession

Returns a new instance of Session.



5
6
7
8
9
10
# File 'lib/kale/session.rb', line 5

def initialize
  @stopwatch = Stopwatch.new
  @stopwatch.start
  
  super
end

Instance Method Details

#earnedObject



23
24
25
# File 'lib/kale/session.rb', line 23

def earned
  "$" + sprintf("%.2f", self.project.rate_per_hour.to_f * (self.elapsed_time.to_f / 3600))
end

#stop(opts) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/kale/session.rb', line 12

def stop opts
  @stopwatch.stop

  self.start_time   = @stopwatch.start_time
  self.end_time     = @stopwatch.end_time
  self.elapsed_time = @stopwatch.elapsed_time
  self.description  = opts[:description]
  self.project      = opts[:project]
  self.save
end