Class: UkCountyLocator::ArgumentValidator
- Inherits:
-
Object
- Object
- UkCountyLocator::ArgumentValidator
- Defined in:
- lib/uk_county_locator/argument_validator.rb
Overview
Class that encompasses all validations on user input
Constant Summary collapse
- VALID_COUNTY_TYPES =
i[current ceremonial historic].freeze
Instance Attribute Summary collapse
-
#county ⇒ Object
readonly
Returns the value of attribute county.
-
#lat ⇒ Object
readonly
Returns the value of attribute lat.
-
#lng ⇒ Object
readonly
Returns the value of attribute lng.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(request:, type:, lat: nil, lng: nil, county: nil) ⇒ ArgumentValidator
constructor
A new instance of ArgumentValidator.
Constructor Details
#initialize(request:, type:, lat: nil, lng: nil, county: nil) ⇒ ArgumentValidator
Returns a new instance of ArgumentValidator.
10 11 12 13 14 15 16 |
# File 'lib/uk_county_locator/argument_validator.rb', line 10 def initialize(request:, type:, lat: nil, lng: nil, county: nil) @request = request @type = verified_type(type) @lat = parse_coordinate(lat, 'lat') if @request == :county @lng = parse_coordinate(lng, 'lat') if @request == :county @county = validated_county(county) if @request == :polygon end |
Instance Attribute Details
#county ⇒ Object (readonly)
Returns the value of attribute county.
6 7 8 |
# File 'lib/uk_county_locator/argument_validator.rb', line 6 def county @county end |
#lat ⇒ Object (readonly)
Returns the value of attribute lat.
6 7 8 |
# File 'lib/uk_county_locator/argument_validator.rb', line 6 def lat @lat end |
#lng ⇒ Object (readonly)
Returns the value of attribute lng.
6 7 8 |
# File 'lib/uk_county_locator/argument_validator.rb', line 6 def lng @lng end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/uk_county_locator/argument_validator.rb', line 6 def type @type end |