class Uncomtrade::Options
Attributes
options[R]
Public Class Methods
new(opts={})
click to toggle source
# File lib/uncomtrade/options.rb, line 9 def initialize(opts={}) set_options(opts) end
Public Instance Methods
list_options()
click to toggle source
# File lib/uncomtrade/options.rb, line 27 def list_options options end
reset()
click to toggle source
# File lib/uncomtrade/options.rb, line 23 def reset set_options end
update(opts={})
click to toggle source
# File lib/uncomtrade/options.rb, line 13 def update(opts={}) opts.each do |key, value| if [:p,:r].include?(key) self.options[key] = iso_code(value) else self.options[key] = value if key != :fmt # don't let user update :fmt end end end
Private Instance Methods
iso_code(country)
click to toggle source
# File lib/uncomtrade/options.rb, line 47 def iso_code(country) Helpers::Country.iso_code(country) end
set_options(options={})
click to toggle source
# File lib/uncomtrade/options.rb, line 33 def set_options(options={}) options[:max] ||= 500 options[:fmt] = 'json' # only support json options[:r] = options[:r].nil? ? 'all': iso_code(options[:r]) options[:freq] ||= 'A' options[:ps] ||= 'now' options[:px] ||= 'HS' options[:p] = options[:p].nil? ? 0 : iso_code(options[:p]) options[:rg] ||= 'all' options[:cc] ||= 'TOTAL' options[:type] ||= 'C' @options = options end