Class: UserSessions

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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_sessionsObject (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

#sessionsObject



348
349
350
# File 'lib/ft_42.rb', line 348

def sessions
  user_sessions.map { |session| Session.new(session) }
end

#total_hours_this_weekObject



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