class Nobel::Prize
Attributes
category[R]
data[R]
motivation[R]
year[R]
Public Class Methods
all(params = {})
click to toggle source
# File lib/nobel/prize.rb, line 6 def all(params = {}) get_data(params).map { |c| new(c) } end
Also aliased as: query
get_data(params = {})
click to toggle source
# File lib/nobel/prize.rb, line 12 def get_data(params = {}) Nobel.api.prize(params)['prizes'] || [] end
new(data)
click to toggle source
# File lib/nobel/prize.rb, line 19 def initialize(data) @data = data || {} @data.tap do |d| @year = Integer(d['year']) @category = d['category'] @share = Integer(d['share']) if d['share'] @motivation = d['motivation'] end end
Public Instance Methods
affiliations()
click to toggle source
# File lib/nobel/prize.rb, line 30 def affiliations @affiliations ||= (data['affiliations'] || []).map do |a| Affiliation.new(a) if a.respond_to?(:has_key?) end.compact end
laureates()
click to toggle source
# File lib/nobel/prize.rb, line 36 def laureates @laureates ||= (data['laureates'] || []).map do |l| Laureate.new(l) end end