Class: UserSessions
- Inherits:
-
Object
- Object
- UserSessions
- Defined in:
- lib/ft_42.rb
Instance Attribute Summary collapse
-
#user_sessions ⇒ Object
readonly
Returns the value of attribute user_sessions.
Instance Method Summary collapse
-
#initialize(user_sessions_response) ⇒ UserSessions
constructor
A new instance of UserSessions.
- #sessions ⇒ Object
- #total_hours_this_week ⇒ Object
Constructor Details
#initialize(user_sessions_response) ⇒ UserSessions
Returns a new instance of UserSessions.
344 345 346 |
# File 'lib/ft_42.rb', line 344 def initialize(user_sessions_response) @user_sessions = user_sessions_response end |
Instance Attribute Details
#user_sessions ⇒ Object (readonly)
Returns the value of attribute user_sessions.
342 343 344 |
# File 'lib/ft_42.rb', line 342 def user_sessions @user_sessions end |
Instance Method Details
#sessions ⇒ Object
348 349 350 |
# File 'lib/ft_42.rb', line 348 def sessions user_sessions.map { |session| Session.new(session) } end |
#total_hours_this_week ⇒ Object
352 353 354 355 356 357 358 |
# File 'lib/ft_42.rb', line 352 def total_hours_this_week total_duration = 0 sessions.each do |session| total_duration += session.duration || 0 end (total_duration / 60 / 60).round end |