class Yao::Resources::Resource
Private Class Methods
resource_from_json(json)
click to toggle source
override Yao::Resources::RestfullyAccessible.resource_from_json
@param json [Hash] @return [Yao::Resources::Resource]
# File lib/yao/resources/resource.rb, line 53 def resource_from_json(json) new(json) end
resources_from_json(json)
click to toggle source
override Yao::Resources::RestfullyAccessible.resources_from_json
@param json [Hash] @return [Yao::Resources::Resource]
# File lib/yao/resources/resource.rb, line 60 def resources_from_json(json) new(json) end
Public Instance Methods
first_sampled_at()
click to toggle source
@return [Date]
# File lib/yao/resources/resource.rb, line 27 def first_sampled_at Time.parse first_sample_timestamp end
get_meter(name)
click to toggle source
@return [Array<Yao::Sample>]
# 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()
click to toggle source
@return [String]
# File lib/yao/resources/resource.rb, line 12 def id resource_id end
last_sampled_at()
click to toggle source
@return [Date]
# File lib/yao/resources/resource.rb, line 22 def last_sampled_at Time.parse last_sample_timestamp end
meters()
click to toggle source
@return [Hash]
# File lib/yao/resources/resource.rb, line 39 def meters links.map{|l| l["rel"] }.delete_if{|n| n == 'self' } end
user()
click to toggle source
@return [Yao::User]
# File lib/yao/resources/resource.rb, line 17 def user @user ||= Yao::User.get(user_id) end