Sha256: 01417597c44e2eb5f80b1eae4c696fb9be241cb6f3bc6858e222b5023d25947f

Contents?: true

Size: 497 Bytes

Versions: 3

Compression:

Stored size: 497 Bytes

Contents

module Esha
  class Nutrient < Api
    def initialize(attributes)
      @attributes = attributes
    end

    def name
      result = self.class.get('/nutrients').find {|n|n['id'] == @attributes['nutrient']}
      "#{result['unit']} #{result['description']}"
    end

    def food_unit
      result = self.class.get('/food-units').find {|n|n['id'] == @attributes['unit']}
      result['description']
    end

    def summary
      "#{quantity} #{food_unit} -> #{value} #{name}"
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
esha-0.0.3 lib/esha/nutrient.rb
esha-0.0.2 lib/esha/nutrient.rb
esha-0.0.1 lib/esha/nutrient.rb