class Mat::Nutrient
Attributes
data[R]
Public Class Methods
all()
click to toggle source
# File lib/mat/nutrient.rb, line 10 def all Mat.api.nutrients.map { |d| new(d) } end
find(slug)
click to toggle source
# File lib/mat/nutrient.rb, line 6 def find(slug) new get_data(slug) end
get_data(slug)
click to toggle source
# File lib/mat/nutrient.rb, line 14 def get_data(slug) Mat.api.nutrient(slug) end
new(data)
click to toggle source
# File lib/mat/nutrient.rb, line 21 def initialize(data) @data = data || {} end
Public Instance Methods
get_data!()
click to toggle source
# File lib/mat/nutrient.rb, line 37 def get_data! initialize self.class.get_data(slug) self end
name()
click to toggle source
# File lib/mat/nutrient.rb, line 29 def name @data['name'] end
slug()
click to toggle source
# File lib/mat/nutrient.rb, line 25 def slug @data['slug'] end
unit()
click to toggle source
# File lib/mat/nutrient.rb, line 33 def unit @data['unit'] end