class KakaxiParse::IntervalPhoto
Attributes
device_id[RW]
taken_at[RW]
url[RW]
Public Class Methods
new( id: nil, name: nil, url: nil, device_id: nil, taken_at: nil, updated_at: nil, created_at: nil )
click to toggle source
Calls superclass method
KakaxiParse::BaseModel::new
# File lib/kakaxi_parse/interval_photo.rb, line 14 def initialize( id: nil, name: nil, url: nil, device_id: nil, taken_at: nil, updated_at: nil, created_at: nil ) @url = url @device_id = Datatype::Pointer.new(KakaxiDevice, device_id) @taken_at = DateTime.strptime(taken_at, '%Y-%m-%dT%H:%M:%S.%LZ') super(id, name, updated_at, created_at) end
short_name()
click to toggle source
# File lib/kakaxi_parse/interval_photo.rb, line 33 def self.short_name 'photo' end
where(hash, limit: DEFUALT_LIMIT)
click to toggle source
Calls superclass method
KakaxiParse::BaseModel::where
# File lib/kakaxi_parse/interval_photo.rb, line 29 def self.where(hash, limit: DEFUALT_LIMIT) to_objects(super(self, hash, limit, @@belongs_to)) if valid_key?(hash) end
Private Class Methods
to_objects(photos)
click to toggle source
# File lib/kakaxi_parse/interval_photo.rb, line 50 def self.to_objects(photos) photos.map do |photo| new( id: photo['objectId'], name: photo['photo'] && photo['photo']['name'], url: photo['photo'] && photo['photo']['url'], device_id: photo['device'] && photo['device']['objectId'], taken_at: photo['takenAt']['iso'], updated_at: photo['updatedAt'], created_at: photo['createdAt'] ) end end
valid_key?(hash)
click to toggle source
# File lib/kakaxi_parse/interval_photo.rb, line 46 def self.valid_key?(hash) hash.keys.all? { |key| %i(id name url device_id taken_at updated_at created_at).include? key } end
Public Instance Methods
device_id=(id)
click to toggle source
# File lib/kakaxi_parse/interval_photo.rb, line 41 def device_id=(id) @device_id.id = id end