Class: SAU::Region
- Inherits:
-
Object
show all
- Defined in:
- lib/sau/region.rb
Instance Method Summary
collapse
Constructor Details
#initialize(props) ⇒ Region
Returns a new instance of Region.
3
4
5
|
# File 'lib/sau/region.rb', line 3
def initialize(props)
@props = props
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args) ⇒ Object
19
20
21
22
23
|
# File 'lib/sau/region.rb', line 19
def method_missing(meth, *args)
return @props[meth] if @props.include?(meth)
super(meth, args) unless meth.to_s =~ /=$/
@props[meth.to_s[0...-1].to_sym] = args.first
end
|
Instance Method Details
#get_data(params) ⇒ Object
12
13
14
15
16
17
|
# File 'lib/sau/region.rb', line 12
def get_data(params)
url = "#{region}/#{params[:measure]}/#{params[:dimension]}/?region_id=#{id}&"
url += params.select { |param| !i(measure dimension).include?(param) }.map { |k,v| "#{k}=#{v}" }.join('&')
@props[:data] = SAU.call_api(url)
self
end
|
#get_detail ⇒ Object
7
8
9
10
|
# File 'lib/sau/region.rb', line 7
def get_detail
@props.merge!(SAU.call_api("#{region}/#{id}"))
self
end
|