m9t 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/lib/m9t.rb CHANGED
@@ -37,7 +37,7 @@ module M9t
37
37
  module VERSION #:nodoc:
38
38
  MAJOR = 0
39
39
  MINOR = 1
40
- TINY = 4
40
+ TINY = 5
41
41
 
42
42
  STRING = [MAJOR, MINOR, TINY].join('.')
43
43
  end
data/lib/m9t/speed.rb CHANGED
@@ -14,6 +14,7 @@ module M9t
14
14
  SECONDS_PER_HOUR = 60.0 * 60
15
15
  MS_TO_KMH = SECONDS_PER_HOUR / M9t::Distance::METERS_PER_KILOMETER
16
16
  MS_TO_MPH = SECONDS_PER_HOUR / M9t::Distance::METERS_PER_MILE
17
+ MS_TO_KNOTS = 1.852 / SECONDS_PER_HOUR * M9t::Distance::METERS_PER_KILOMETER
17
18
 
18
19
  include M9t::Base
19
20
 
@@ -44,6 +45,11 @@ module M9t
44
45
  mps.to_f / MS_TO_MPH
45
46
  end
46
47
 
48
+ # Converts meters per second to knots
49
+ def to_knots(mps)
50
+ mps.to_f / MS_TO_KNOTS
51
+ end
52
+
47
53
  end
48
54
 
49
55
  alias :to_meters_per_second :value
data/test/speed_test.rb CHANGED
@@ -59,6 +59,8 @@ class TestM9tSpeed < Test::Unit::TestCase
59
59
 
60
60
  def test_to_s
61
61
  assert_equal '135.00000 meters per second', M9t::Speed.new(135).to_s
62
+ I18n.locale = :it
63
+ assert_equal '135,00000 metri al second', M9t::Speed.new(135).to_s
62
64
  end
63
65
 
64
66
  def test_to_s_precision
@@ -69,4 +71,10 @@ class TestM9tSpeed < Test::Unit::TestCase
69
71
  assert_equal '135m/s', M9t::Speed.new(135, :abbreviated => true, :precision => 0).to_s
70
72
  end
71
73
 
74
+ def test_to_s_knots
75
+ assert_equal '262 knots', M9t::Speed.new(135, {:units => :knots, :precision => 0}).to_s
76
+ I18n.locale = :it
77
+ assert_equal '262 nodi', M9t::Speed.new(135, {:units => :knots, :precision => 0}).to_s
78
+ end
79
+
72
80
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 4
9
- version: 0.1.4
8
+ - 5
9
+ version: 0.1.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Joe Yates