Class: ActivityLogger
- Inherits:
-
Object
- Object
- ActivityLogger
- Defined in:
- lib/activity-logger.rb
Instance Method Summary collapse
- #create(desc = '', time = Time.now) ⇒ Object
-
#expired? ⇒ Boolean
Returns true if the time from the last entry exceeds 45 minutes.
-
#initialize(path = nil) ⇒ ActivityLogger
constructor
A new instance of ActivityLogger.
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.
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 |