Class: ActivityLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/activity-logger.rb

Instance Method Summary collapse

Constructor Details

#initialize(path = nil) ⇒ ActivityLogger

Returns a new instance of ActivityLogger.



9
10
11
# File 'lib/activity-logger.rb', line 9

def initialize(path=nil)
  Dir.chdir(path) if path    
end

Instance Method Details

#create(desc = '', time = Time.now) ⇒ Object



13
14
15
16
# File 'lib/activity-logger.rb', line 13

def create(desc='', time=Time.now)
  
  DynarexDaily.new.create(time: time.to_s, desc: desc).save
end

#expired?Boolean

Returns true if the time from the last entry exceeds 45 minutes.

Returns:

  • (Boolean)


20
21
22
23
24
25
26
27
# File 'lib/activity-logger.rb', line 20

def expired?()
  records = DynarexDaily.new.to_h
  if records and !records.empty? then
    (Time.now - Time.parse(records.last[:time])) / 60 >= 45  
  else
    true
  end
end