Class: Smartfm::User::Study::Result

Inherits:
Base
  • Object
show all
Defined in:
lib/smartfm/models/user.rb

Constant Summary collapse

ATTRIBUTES =
[:timestamp, :seconds, :totals, :seen, :completed, :date]

Instance Method Summary collapse

Methods inherited from Base

attributes, #attributes

Constructor Details

#initialize(params = {}) ⇒ Result

Returns a new instance of Result.



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/smartfm/models/user.rb', line 32

def initialize(params = {})
  @timestamp = (params[:timestamp].to_i   rescue nil)
  @seconds   = (params[:seconds].to_i     rescue nil)
  @totals    = {
    :seconds   => (params[:totals][:seconds].to_i   rescue nil),
    :seen      => (params[:totals][:seen].to_i      rescue nil),
    :completed => (params[:totals][:completed].to_i rescue nil)
  }
  @seen      = (params[:seen].to_i        rescue nil)
  @completed = (params[:completed].to_i   rescue nil)
  @date      = (Date.parse(params[:date]) rescue nil)
end