lib/carbon/emission_estimate/storage.rb in carbon-0.2.5 vs lib/carbon/emission_estimate/storage.rb in carbon-0.2.6

- old
+ new

@@ -2,18 +2,22 @@ class EmissionEstimate class Storage attr_accessor :parent attr_reader :raw_request attr_reader :raw_response + def initialize(parent) @parent = parent end + def url "#{::Carbon::STORAGE_URL}/#{::Digest::SHA1.hexdigest(parent.key+parent.guid)}" end + def present? parent.guid.present? and data.present? end + def data return @data[0] if @data.is_a? ::Array @raw_request = ::REST::Request.new :get, ::URI.parse(url) @raw_response = raw_request.perform if raw_response.success?