speedtest_net 0.4.2 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 00f2bcab94d4afb99bc644a70be8578f1ee02d0e955ee666fb7c6e36af0f252b
4
- data.tar.gz: 5c9c24d982b104678f851542b2a7c51a17708a488413d2b809841a1d9212e41c
3
+ metadata.gz: e96f1e3dfc288c7a9203f575420bc6b25d5077c8dbde6e3822851f54296fff5f
4
+ data.tar.gz: 8019fba56eae4047eab3ae84b6afbaa4979262e3ed59395a6394c1ad466e013c
5
5
  SHA512:
6
- metadata.gz: a02a821d47348411a9aaafccb3d434bfe7d545a6e0e186b64e604fd2e45175f26067cfc72e0ca6899956dc7d2171d52de4abbd8faa7ce2bc3a817002150a6c13
7
- data.tar.gz: e1cfcd400e2d6cfd84cd5dc9e15f2f97c81c471cbf2dcc6d659bb3c5859a107d1fb66746d7590b069b5fa0b5a8600f69aaf9c0e0437bcafccdf106153075cfb2
6
+ metadata.gz: 6bcfdd411e38e6e6a602ce61a41f32ed5f27ee1723269502e8d80cedc08a8d5ccad1bcd61874f3621287024463bce1d6466b92834a999f639f04ebae529b856a
7
+ data.tar.gz: d535e32474576a614709b33b67bc836cc32bf32021ee8d1a38eaf202817cacfd0e223c1f8c4d9efd7a3ce17ef3ad605fbb37832100bfcff3ae6b87905f27b9df
data/lib/geo.rb CHANGED
@@ -1,10 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Geo
4
- RADIUS_PER_DEGREE = Math::PI / 180
5
- RADIUS_METER = 6_371_000
6
-
7
- attr_reader :lat, :long
4
+ RADIAN_PER_DEGREE = Math::PI / 180
5
+ EARTH_RADIUS = 6_371_000
8
6
 
9
7
  def initialize(lat, long)
10
8
  @lat = lat
@@ -12,17 +10,18 @@ class Geo
12
10
  end
13
11
 
14
12
  def distance(other) # rubocop:disable Metrics/AbcSize
15
- delta_lat = (@lat - other.lat) * RADIUS_PER_DEGREE
16
- delta_long = (@long - other.long) * RADIUS_PER_DEGREE
13
+ a = Math.sin(radian_lat) * Math.sin(other.radian_lat) +
14
+ Math.cos(radian_lat) * Math.cos(other.radian_lat) *
15
+ Math.cos(radian_long - other.radian_long)
17
16
 
18
- lat_radius = @lat * RADIUS_PER_DEGREE
19
- other_lat_radius = other.lat * RADIUS_PER_DEGREE
17
+ Math.acos(a) * EARTH_RADIUS
18
+ end
20
19
 
21
- a = Math.sin(delta_lat / 2)**2 +
22
- Math.cos(lat_radius) *
23
- Math.cos(other_lat_radius) *
24
- Math.sin(delta_long / 2)**2
20
+ def radian_lat
21
+ @lat * RADIAN_PER_DEGREE
22
+ end
25
23
 
26
- Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)) * 2 * RADIUS_METER
24
+ def radian_long
25
+ @long * RADIAN_PER_DEGREE
27
26
  end
28
27
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SpeedtestNet
4
- VERSION = '0.4.2'
4
+ VERSION = '0.5.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: speedtest_net
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakano
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-21 00:00:00.000000000 Z
11
+ date: 2019-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler