Class: Yao::Resources::OldSample

Inherits:
Base
  • Object
show all
Includes:
ProjectAssociationable
Defined in:
lib/yao/resources/old_sample.rb

Instance Attribute Summary

Attributes included from RestfullyAccessible

#service

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ProjectAssociationable

included, #project

Methods inherited from Base

#[], #[]=, add_instantiation_name_list, #destroy, friendly_attributes, #initialize, instantiation?, map_attribute_to_attribute, map_attribute_to_resource, map_attribute_to_resources, map_attributes_to_time, #to_hash, #update

Methods included from RestfullyAccessible

#admin=, #api_version, #api_version=, #as_member, #client, #create, #destroy, extended, #find_by_name, #get, #get!, #list, #resources_path, #resources_path=, #return_single_on_querying, #return_single_on_querying=, #update

Constructor Details

This class inherits a constructor from Yao::Resources::Base

Class Method Details

.cacheObject



40
41
42
# File 'lib/yao/resources/old_sample.rb', line 40

def self.cache
  @@_cache ||= {}
end

.list(meter_name, query = {}) ⇒ Object

get /v2/meters/#id returns samples!



34
35
36
37
38
# File 'lib/yao/resources/old_sample.rb', line 34

def self.list(meter_name, query={})
  cache_key = [meter_name, *query].join
  cache[cache_key] = GET("#{self.api_version}/meters/#{meter_name}", query).body unless cache[cache_key]
  cache[cache_key].map{|d| new(d) }
end

Instance Method Details

#idString

Returns:

  • (String)


16
17
18
# File 'lib/yao/resources/old_sample.rb', line 16

def id
  message_id
end

#recorded_atDate Also known as: timestamp

Returns:

  • (Date)


10
11
12
# File 'lib/yao/resources/old_sample.rb', line 10

def recorded_at
  Time.parse(self["recorded_at"] || self["timestamp"])
end

#resourceYao::Resources::Resource



21
22
23
# File 'lib/yao/resources/old_sample.rb', line 21

def resource
  @resource ||= Yao::Resource.get(resource_id)
end

#userYao::Resources::User



26
27
28
# File 'lib/yao/resources/old_sample.rb', line 26

def user
  @user ||= Yao::User.get(user_id)
end