Class: Yahoo::GeoPlanet::Base
- Inherits:
-
Object
- Object
- Yahoo::GeoPlanet::Base
- Defined in:
- lib/yahoo-geoplanet/base.rb
Direct Known Subclasses
Class Method Summary collapse
- .api_path(resource, id, collection, *args) ⇒ Object
- .fetch_and_parse(resource, options = {}) ⇒ Object
- .name_with_demodulization ⇒ Object
Instance Method Summary collapse
-
#initialize(xml) ⇒ Base
constructor
A new instance of Base.
- #initialize_with_polymorphism(arg) ⇒ Object
Constructor Details
#initialize(xml) ⇒ Base
Returns a new instance of Base.
31 32 33 |
# File 'lib/yahoo-geoplanet/base.rb', line 31 def initialize(xml) raise ArgumentError unless xml.kind_of?(Hpricot) end |
Class Method Details
.api_path(resource, id, collection, *args) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/yahoo-geoplanet/base.rb', line 18 def api_path(resource, id, collection, *args) args = args. count = args.delete(:count) start = args.delete(:start) collection += ";count=#{count}" if count collection += ";start=#{start}" if start parameters = [resource, id, collection, *args].compact # return parameters.collect!{|param| CGI::escape(param.to_s).downcase}.join('/') return parameters.collect!{|param| param.to_s.downcase}.join('/') end |
.fetch_and_parse(resource, options = {}) ⇒ Object
13 14 15 16 |
# File 'lib/yahoo-geoplanet/base.rb', line 13 def fetch_and_parse(resource, = {}) raise YahooWebServiceError, "No App ID specified" if connection.nil? return Hpricot::XML(connection.get(resource, )) end |
.name_with_demodulization ⇒ Object
7 8 9 |
# File 'lib/yahoo-geoplanet/base.rb', line 7 def name_with_demodulization self.name_without_demodulization.demodulize end |
Instance Method Details
#initialize_with_polymorphism(arg) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/yahoo-geoplanet/base.rb', line 35 def initialize_with_polymorphism(arg) case arg when Integer initialize_without_polymorphism(query_by_id(arg)) when Hpricot initialize_without_polymorphism(arg) end end |