class Nobel::Country

Attributes

code[R]
name[R]

Public Class Methods

all() click to toggle source
# File lib/nobel/country.rb, line 6
def all
  data.map { |c| new(c) }
end
data() click to toggle source
# File lib/nobel/country.rb, line 15
def data
  @data ||= get_data
end
find(value, key = 'code') click to toggle source
# File lib/nobel/country.rb, line 10
def find(value, key = 'code')
  value = key == 'code' ? value.to_s.upcase : value.to_s
  new data.detect { |c| c[key.to_s] == value }
end
new(data) click to toggle source
# File lib/nobel/country.rb, line 33
def initialize(data)
  data ||= { 'code' => 'ZZ', 'name' => 'Unknown' }

  @name = data['name']
  @code = data['code']
end
reload!() click to toggle source
# File lib/nobel/country.rb, line 19
def reload!
  @data = get_data
  self
end

Private Class Methods

get_data() click to toggle source
# File lib/nobel/country.rb, line 26
def get_data
  Nobel.api.country['countries'] || []
end