Class: Yahoo::GeoPlanet::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/yahoo-geoplanet/base.rb

Direct Known Subclasses

Place

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ Base

Returns a new instance of Base.

Raises:

  • (ArgumentError)


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.extract_options!
  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, options = {})      
  raise YahooWebServiceError, "No App ID specified" if connection.nil?    
  return Hpricot::XML(connection.get(resource, options))
end

.name_with_demodulizationObject



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