cartesian_for_geo 1.1.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: de9f77f6042b8cdd0a342c1b32247afc62b35cb2c4fe681ad53031258ca2d2b9
4
- data.tar.gz: 4a5932e6739a6397539898bf2c42a318b55730ab394767f0ca43001356aa924b
3
+ metadata.gz: d5815b13b033fea94b353ea63a41909a024b624d0d89dddb33154a5535904b2f
4
+ data.tar.gz: 1c7484349baf363c29f79e9263ab2ce2a57c9dc85f23f764230e62435a25e117
5
5
  SHA512:
6
- metadata.gz: 3a77589c417c46815a997d40f1ea2a1794c5146856e9c879f4737c8c35136f910c2ef7649ee8d128907e12d5abf6aa0145c4d83722c518dfe1b77d31d9321b45
7
- data.tar.gz: 5112e1c13405bcd1c75c76e68784cceaf74fb5934dbbcb60a927256847d9a19b89b42af2f2eb3441302e60fa817eec6149a5da73b13afdf64d6c4bb5829d4408
6
+ metadata.gz: 14d4d03fb3d5287bef11734e34b1894ac296ce4dce7d9ece2b539e53d2d6682de8340ba1130db92cdd59c6fc4ecb03ab1f1bd6b9737b528adc634494b99703b9
7
+ data.tar.gz: cc924ea13ba9c4f4d7e4a555965a419b9362cc1f6017d469561b3884291b76425507fb82e85754fe5a412ce7c1befa6dae43a820ebd820705844dd1b82d302d3
@@ -23,10 +23,9 @@ module CartesianForGeo
23
23
  include Comparable
24
24
 
25
25
  attr_accessor :lat, :lng
26
- attr_reader :coords
26
+ attr_reader :coords, :order
27
27
 
28
28
  alias to_a coords
29
- alias lat_lng coords
30
29
 
31
30
  class << self
32
31
  alias [] new
@@ -39,6 +38,7 @@ module CartesianForGeo
39
38
  def initialize(*coords)
40
39
  @coords = coords.flatten
41
40
  @lat, @lng = @coords
41
+ @order = :lat_lng
42
42
  end
43
43
 
44
44
  def side
@@ -54,11 +54,19 @@ module CartesianForGeo
54
54
  end
55
55
 
56
56
  def to_s
57
- empty? ? '' : "(#{lat},#{lng})"
57
+ empty? ? '' : "(#{coords.join(',')})"
58
58
  end
59
59
 
60
- def lng_lat
61
- coords.reverse
60
+ def lng_lat!
61
+ @order = :lng_lat
62
+ @coords = [@lng, @lat]
63
+ self
64
+ end
65
+
66
+ def lat_lng!
67
+ @order = :lat_lng
68
+ @coords = [@lat, @lng]
69
+ self
62
70
  end
63
71
 
64
72
  def to_json(*)
@@ -70,7 +78,10 @@ module CartesianForGeo
70
78
  end
71
79
 
72
80
  def <=>(other)
73
- [to_a, other.to_a].map { |cord| cord.map { |f| f.round 9 } }.reduce(:<=>)
81
+ [
82
+ to_a,
83
+ other.to_a.public_send(order == other.order ? :itself : :reverse)
84
+ ].map { |cord| cord.map { |f| f.round 9 } }.reduce(:<=>)
74
85
  end
75
86
  end
76
87
 
@@ -1,3 +1,3 @@
1
1
  module CartesianForGeo
2
- VERSION = '1.1.1'.freeze
2
+ VERSION = '2.0.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cartesian_for_geo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Tyurin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-09 00:00:00.000000000 Z
11
+ date: 2021-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gorilla_patch