Class: SAU::Region
- Inherits:
-
Object
- Object
- SAU::Region
- Defined in:
- lib/sau/region.rb
Instance Method Summary collapse
- #get_data(params) ⇒ Object
- #get_detail ⇒ Object
-
#initialize(props) ⇒ Region
constructor
A new instance of Region.
- #method_missing(meth, *args) ⇒ Object
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 |