Class: Yao::Resources::Resource
Instance Attribute Summary
#service
Instance Method Summary
collapse
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
#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
Instance Method Details
#first_sampled_at ⇒ Date
27
28
29
|
# File 'lib/yao/resources/resource.rb', line 27
def first_sampled_at
Time.parse first_sample_timestamp
end
|
#get_meter(name) ⇒ Array<Yao::Sample>
32
33
34
35
36
|
# File 'lib/yao/resources/resource.rb', line 32
def get_meter(name)
if link = links.find{|l| l["rel"] == name }
Yao::Sample.list(link["href"])
end
end
|
#id ⇒ String
12
13
14
|
# File 'lib/yao/resources/resource.rb', line 12
def id
resource_id
end
|
#last_sampled_at ⇒ Date
22
23
24
|
# File 'lib/yao/resources/resource.rb', line 22
def last_sampled_at
Time.parse last_sample_timestamp
end
|
#meters ⇒ Hash
39
40
41
|
# File 'lib/yao/resources/resource.rb', line 39
def meters
links.map{|l| l["rel"] }.delete_if{|n| n == 'self' }
end
|
#user ⇒ Yao::User
17
18
19
|
# File 'lib/yao/resources/resource.rb', line 17
def user
@user ||= Yao::User.get(user_id)
end
|