Sha256: fdf319e118db38600b90cf3b94882da8d28a0bf03b8ddeab4345ca7a4af51e63

Contents?: true

Size: 698 Bytes

Versions: 8

Compression:

Stored size: 698 Bytes

Contents

module Yao::Resources
  class Sample < Base
    friendly_attributes :id, :metadata, :meter,
                        :source, :type, :unit, :volume,
                        :resource_id, :user_id

    # @return [Date]
    def recorded_at
      Time.parse(self["recorded_at"])
    end

    # @return [Date]
    def timestamp
      Time.parse(self["timestamp"])
    end

    # @return [Yao::Resources::Resource]
    def resource
      @resource ||= Yao::Resource.get(resource_id)
    end

    # @return [Yao::Resources::User]
    def user
      @user ||= Yao::User.get(user_id)
    end

    self.service        = "metering"
    self.api_version    = "v2"
    self.resources_name = "samples"
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
yao-0.21.0 lib/yao/resources/sample.rb
yao-0.20.0 lib/yao/resources/sample.rb
yao-0.19.0 lib/yao/resources/sample.rb
yao-0.18.0 lib/yao/resources/sample.rb
yao-0.17.0 lib/yao/resources/sample.rb
yao-0.16.0 lib/yao/resources/sample.rb
yao-0.15.0 lib/yao/resources/sample.rb
yao-0.14.0 lib/yao/resources/sample.rb