Class: Lifeapi::Day

Inherits:
Object
  • Object
show all
Defined in:
lib/lifeapi.rb

Overview

contains a single day record_date: date the day was recorded (or logged) activites: array of activites that belong to the day

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(record_date, activities) ⇒ Day

Returns a new instance of Day.



15
16
17
18
# File 'lib/lifeapi.rb', line 15

def initialize(record_date, activities)
  self.record_date = record_date
  self.activities = Day.parse_activities(activities)
end

Instance Attribute Details

#activitiesObject

Returns the value of attribute activities.



13
14
15
# File 'lib/lifeapi.rb', line 13

def activities
  @activities
end

#record_dateObject

Returns the value of attribute record_date.



13
14
15
# File 'lib/lifeapi.rb', line 13

def record_date
  @record_date
end

Class Method Details

.parse_activities(activities) ⇒ Object



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

def self.parse_activities(activities)
  activities_arr = []
  activities.each do |a|
    @a = Activity.new(a["self_type"], a["duration"])
    activities_arr.push(@a)
  end
  return activities_arr
end