Class: Geonames::PostalCodeSearchCriteria

Inherits:
Object
  • Object
show all
Defined in:
lib/geonames/postal_code_search_criteria.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ PostalCodeSearchCriteria

Returns a new instance of PostalCodeSearchCriteria.



28
29
30
31
32
33
34
# File 'lib/geonames/postal_code_search_criteria.rb', line 28

def initialize(params={})
  params.each do |attr, value|
    self.public_send("#{attr}=", value)
  end if params

  @is_or_operator = false
end

Instance Attribute Details

#country_codeObject

Returns the value of attribute country_code.



24
25
26
# File 'lib/geonames/postal_code_search_criteria.rb', line 24

def country_code
  @country_code
end

#is_or_operatorObject

Returns the value of attribute is_or_operator.



24
25
26
# File 'lib/geonames/postal_code_search_criteria.rb', line 24

def is_or_operator
  @is_or_operator
end

#latitudeObject

Returns the value of attribute latitude.



24
25
26
# File 'lib/geonames/postal_code_search_criteria.rb', line 24

def latitude
  @latitude
end

#longitudeObject

Returns the value of attribute longitude.



24
25
26
# File 'lib/geonames/postal_code_search_criteria.rb', line 24

def longitude
  @longitude
end

#max_rowsObject

Returns the value of attribute max_rows.



24
25
26
# File 'lib/geonames/postal_code_search_criteria.rb', line 24

def max_rows
  @max_rows
end

#place_nameObject

Returns the value of attribute place_name.



24
25
26
# File 'lib/geonames/postal_code_search_criteria.rb', line 24

def place_name
  @place_name
end

#postal_codeObject

Returns the value of attribute postal_code.



24
25
26
# File 'lib/geonames/postal_code_search_criteria.rb', line 24

def postal_code
  @postal_code
end

#radiusObject

Returns the value of attribute radius.



24
25
26
# File 'lib/geonames/postal_code_search_criteria.rb', line 24

def radius
  @radius
end

#styleObject

Returns the value of attribute style.



24
25
26
# File 'lib/geonames/postal_code_search_criteria.rb', line 24

def style
  @style
end

Instance Method Details

#to_query_params_stringObject



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/geonames/postal_code_search_criteria.rb', line 36

def to_query_params_string
  url = ''
  url << "&postalcode=" + CGI.escape(@postal_code)    unless @postal_code.nil?
  url << "&placename="  + CGI.escape(@place_name)     unless @place_name.nil?
  url << "&lat="        + CGI.escape(@latitude.to_s)  unless @latitude.nil?
  url << "&lng="        + CGI.escape(@longitude.to_s) unless @longitude.nil?
  url << "&style="      + CGI.escape(@style)          unless @style.nil?
  url << "&country="    + CGI.escape(@country_code)   unless @country_code.nil?
  url << "&maxRows="    + CGI.escape(@max_rows.to_s)  unless @max_rows.nil?
  url << "&radius="     + CGI.escape(@radius.to_s)    unless @radius.nil?
  url << "&operator=OR" if @is_or_operator
  url
end