Class: Ratis::Landmark

Inherits:
Object
  • Object
show all
Defined in:
lib/ratis/landmark.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(landmark) ⇒ Landmark

Returns a new instance of Landmark.



7
8
9
10
11
12
# File 'lib/ratis/landmark.rb', line 7

def initialize(landmark)
  @type     = landmark[:type]
  @verbose  = landmark[:verbose]
  @location = landmark[:location]
  @locality = landmark[:locality]
end

Instance Attribute Details

#localityObject

Returns the value of attribute locality.



5
6
7
# File 'lib/ratis/landmark.rb', line 5

def locality
  @locality
end

#locationObject

Returns the value of attribute location.



5
6
7
# File 'lib/ratis/landmark.rb', line 5

def location
  @location
end

#typeObject

Returns the value of attribute type.



5
6
7
# File 'lib/ratis/landmark.rb', line 5

def type
  @type
end

#verboseObject

Returns the value of attribute verbose.



5
6
7
# File 'lib/ratis/landmark.rb', line 5

def verbose
  @verbose
end

Class Method Details

.where(conditions) ⇒ Object

Raises:

  • (ArgumentError)


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ratis/landmark.rb', line 14

def self.where(conditions)
  type    = conditions.delete(:type).to_s.upcase
  zipcode = conditions.delete(:zipcode)

  raise ArgumentError.new('You must provide a type') if type.blank?
  Ratis.all_conditions_used? conditions

  response = Request.get 'Getlandmarks', { 'Type' => type, 'Zipcode' => zipcode }

  return [] unless response.success?

  response.to_array(:getlandmarks_response, :landmark).map do |landmark|
    Landmark.new(landmark)
  end

end