Sha256: 277e637fbddebd5e9ddf2f9a07448df92033235d7d6803871cfd9fb53b34dbb6

Contents?: true

Size: 510 Bytes

Versions: 3

Compression:

Stored size: 510 Bytes

Contents

require "hashie"
module DutyCalculator
  class Response < Hash
    include ::Hashie::Extensions::Coercion
    coerce_value Hash, Response

    def initialize(hash = {})
      super
      hash.each_pair do |k,v|
        if k == '__content__' && v.to_s == 0.to_s
          self['value'] = v.to_f
        elsif k == '__content__' && v.to_i > 0
          self['value'] = v.to_f
        elsif k == '__content__'
          self['value'] = v
        else
          self[k] = v
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
duty_calculator-0.0.8 lib/duty_calculator/response.rb
duty_calculator-0.0.7 lib/duty_calculator/response.rb
duty_calculator-0.0.6 lib/duty_calculator/response.rb