Class: Google::Maps::PlaceDetails::AddressComponentsProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/google_maps/place.rb

Instance Method Summary collapse

Constructor Details

#initialize(address_components) ⇒ AddressComponentsProxy

Returns a new instance of AddressComponentsProxy.



87
88
89
# File 'lib/google_maps/place.rb', line 87

def initialize(address_components)
  @address_components = address_components
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object

Raises:

  • (ArgumentError)


91
92
93
94
95
96
97
# File 'lib/google_maps/place.rb', line 91

def method_missing(method_name, *args)
  raise ArgumentError unless args.empty?

  @address_components.find do |component|
    component.types.first == method_name.to_s
  end
end

Instance Method Details

#respond_to_missing?(method_name, _include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


99
100
101
102
103
# File 'lib/google_maps/place.rb', line 99

def respond_to_missing?(method_name, _include_private = false)
  @address_components.any? do |component|
    component.types.first == method_name.to_s
  end
end