Class: Lifeapi::Range

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

Overview

contains a range of days, condensed start_date: date that the earliest day in range was recorded end_date: date that the latest day in range was recorded activities: array of activities that belongs to the range

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start_date, end_date, activities) ⇒ Range

Returns a new instance of Range.



51
52
53
54
55
# File 'lib/lifeapi.rb', line 51

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

Instance Attribute Details

#activitiesObject

Returns the value of attribute activities.



49
50
51
# File 'lib/lifeapi.rb', line 49

def activities
  @activities
end

#end_dateObject

Returns the value of attribute end_date.



49
50
51
# File 'lib/lifeapi.rb', line 49

def end_date
  @end_date
end

#start_dateObject

Returns the value of attribute start_date.



49
50
51
# File 'lib/lifeapi.rb', line 49

def start_date
  @start_date
end

Class Method Details

.parse_activities(activities) ⇒ Object



57
58
59
60
61
62
63
64
# File 'lib/lifeapi.rb', line 57

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