Skip to content

Commit

Permalink
Rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
zverok committed Jan 15, 2018
1 parent dff05cb commit 6036370
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
inherit_from: .rubocop_todo.yml

AllCops:
Include:
- 'lib/**/*'
Expand Down Expand Up @@ -48,3 +50,6 @@ Metrics/MethodLength:

Gemspec/OrderedDependencies:
Enabled: false

Style/FormatStringToken:
Enabled: false
12 changes: 5 additions & 7 deletions lib/geo/coord.rb
Original file line number Diff line number Diff line change
Expand Up @@ -583,17 +583,15 @@ def endpoint(distance, azimuth)

private

LAT_RANGE_ERROR = 'Expected latitude to be between -90 and 90, %p received'.freeze
LNG_RANGE_ERROR = 'Expected longitude to be between -180 and 180, %p received'.freeze

def _init(lat, lng)
lat = lat.to_f
lng = lng.to_f

unless (-90..90).cover?(lat)
raise ArgumentError, "Expected latitude to be between -90 and 90, #{lat} received"
end

unless (-180..180).cover?(lng)
raise ArgumentError, "Expected longitude to be between -180 and 180, #{lng} received"
end
raise ArgumentError, LAT_RANGE_ERROR % lat unless (-90..90).cover?(lat)
raise ArgumentError, LNG_RANGE_ERROR % lng unless (-180..180).cover?(lng)

@lat = lat
@lng = lng
Expand Down
4 changes: 4 additions & 0 deletions spec/geo/coord_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@
Geo::Coord.new(latd: 50, latm: 0, lats: 16, lath: 'N',
lngd: 36, lngm: 13, lngs: 53, lngh: 'E')

# TODO:
# Geo::Coord.parse_dms(%{22°12'00" 33°18'00"}).should ==
# Geo::Coord.new(latd: 22, latm: 12, lngd: 33, lngm: 18)

lambda{Geo::Coord.parse_dms('50 36 80')}.should raise_error(ArgumentError)
end

Expand Down

0 comments on commit 6036370

Please sign in to comment.