m9t 0.3.6 → 1.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
- SHA1:
3
- metadata.gz: a5032bc2dee8145116056d99cc84fbaf492c8896
4
- data.tar.gz: f361209c27b67471b1eb410651758141e4bf241e
2
+ SHA256:
3
+ metadata.gz: 1e9e5be154c21f5d10e86c7c6f906f5bdd2287c56797965f8430c12fbcee09b2
4
+ data.tar.gz: c23bd6fe57b417fc46680c9c91dfe7517ea0833e1ec76f6cd959df5466a02028
5
5
  SHA512:
6
- metadata.gz: 17d1116cc4b15a2b1cf7fb7191dbb01ac306f8d0748b6d638ee276263134c5e4d627d9e5e0a5f66e31732821f48c2c66d6122d4d5a23d80f46406ad13caf1b75
7
- data.tar.gz: 6083ab4e3dc37724bf9984e62b0e3a50799e817edf000843e3dd679987e0d14314b97c718557e6043b4029c7323dbe7389a55d3bc8e463abd82e59c2db85c89e
6
+ metadata.gz: 12f3a7e3428384abfa69f90c2d7210dff7ba94494ae82e14b0be892159de160722ad60fd16502e68b699e228a1206af122246ff3c2062c24e14d942d0e90831f
7
+ data.tar.gz: 0b2fd9ec442f4dcaf8d992a3d301404d91c4ce6da76972affe6c40deb152f034cc6cc76a752ad921a7328748d3e4b05a40ee50edfe7675e687856fc5dcac58f1
data/.rspec CHANGED
@@ -1,3 +1,2 @@
1
1
  --color
2
- --format progress
3
-
2
+ --require spec_helper
data/.travis.yml CHANGED
@@ -5,6 +5,7 @@ rvm:
5
5
  - 2.0.0
6
6
  - 2.2.0
7
7
  - 2.3.0
8
+ - 2.4.0
8
9
  - jruby-19mode
9
10
  branches:
10
11
  only:
data/Gemfile CHANGED
@@ -1,4 +1,3 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec :name => 'm9t'
1
+ source "https://rubygems.org"
4
2
 
3
+ gemspec name: "m9t"
data/Rakefile CHANGED
@@ -1,9 +1,10 @@
1
1
  #!/usr/bin/env rake
2
- require 'bundler/gem_tasks'
3
- require 'rspec/core/rake_task'
4
2
 
5
- task :default => :spec
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ task default: :spec
6
7
 
7
8
  RSpec::Core::RakeTask.new do |t|
8
- t.pattern = 'spec/**/*_spec.rb'
9
+ t.pattern = "spec/**/*_spec.rb"
9
10
  end
data/lib/m9t.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2010 Joe Yates
2
+ # Copyright (c) 2010-2021 Joe Yates
3
3
  #
4
4
  # Permission is hereby granted, free of charge, to any person obtaining
5
5
  # a copy of this software and associated documentation files (the
data/lib/m9t/base.rb CHANGED
@@ -1,6 +1,5 @@
1
- # encoding: utf-8
2
- require 'm9t/errors'
3
- require 'm9t/i18n'
1
+ require "m9t/errors"
2
+ require "m9t/i18n"
4
3
 
5
4
  module M9t
6
5
  module Base
@@ -82,15 +81,15 @@ module M9t
82
81
  @options
83
82
  end
84
83
 
85
- # Reloads the class's default options
84
+ # Reloads the class"s default options
86
85
  def reset_options!
87
86
  @options = self::DEFAULT_OPTIONS.clone
88
87
  end
89
88
 
90
89
  # The name used for i18n translations
91
- # M9t::Distance => 'distance'
90
+ # M9t::Distance => "distance"
92
91
  def measurement_name
93
- name.split('::')[-1].downcase
92
+ name.split("::")[-1].downcase
94
93
  end
95
94
 
96
95
  def default_unit
@@ -145,20 +144,20 @@ module M9t
145
144
  key = i18n_key(options)
146
145
  unit = I18n.t(key, count: value_in_units)
147
146
 
148
- "#{localized_value}%s#{unit}" % (options[:abbreviated] ? '' : ' ')
147
+ "#{localized_value}%s#{unit}" % (options[:abbreviated] ? "" : " ")
149
148
  end
150
149
 
151
150
  private
152
151
 
153
152
  def i18n_key(options = {})
154
- key = 'units.' + self.class.measurement_name + '.' + options[:units].to_s
155
- options[:abbreviated] ? key += '.abbreviated' : key += '.full'
153
+ key = "units.#{self.class.measurement_name}.#{options[:units]}"
154
+ key += options[:abbreviated] ? ".abbreviated" : ".full"
156
155
  key
157
156
  end
158
157
 
159
158
  def units_error(units)
160
- known = self.class::CONVERSIONS.keys.collect(&:to_s).join(', ')
161
- fail M9t::UnitError, "Unknown units '#{units}'. Known: #{known}"
159
+ known = self.class::CONVERSIONS.keys.collect(&:to_s).join(", ")
160
+ fail M9t::UnitError, %Q(Unknown units "#{units}". Known: #{known})
162
161
  end
163
162
 
164
163
  def extract_to(name)
data/lib/m9t/direction.rb CHANGED
@@ -1,11 +1,10 @@
1
- # encoding: utf-8
2
- require 'm9t/base'
1
+ require "m9t/base"
3
2
 
4
3
  module M9t
5
4
  # Represents a geographical direction
6
5
  class Direction
7
6
  DEFAULT_OPTIONS = {units: :degrees, abbreviated: false, decimals: 5}
8
- CONVERSIONS = {
7
+ CONVERSIONS = {
9
8
  degrees: 1.0,
10
9
  compass: nil,
11
10
  }
@@ -18,20 +17,20 @@ module M9t
18
17
 
19
18
  class << self
20
19
  # Given a value in degrees, returns the nearest (localized) compass direction
21
- # M9t::Directions.to_compass(42) => 'NE'
20
+ # M9t::Directions.to_compass(42) => "NE"
22
21
  def degrees_to_compass(degrees)
23
22
  sector = (normalize(degrees) / COMPASS_SECTOR_DEGREES).round
24
- I18n.t(self.measurement_name + '.sectors')[sector]
23
+ I18n.t(self.measurement_name + ".sectors")[sector]
25
24
  end
26
25
 
27
26
  def compass_to_degrees(compass_direction)
28
27
  compass(compass_direction).to_f
29
28
  end
30
29
 
31
- # Accepts a localized compass direction (e.g. 'N') and returns the equivalent M9t::Direction
32
- # M9t::Direction.compass('NE') => #<M9t::Direction:0xb76cc750 @value=45.0, @options={:units=>:degrees, :decimals=>5, :abbreviated=>false}>
30
+ # Accepts a localized compass direction (e.g. "N") and returns the equivalent M9t::Direction
31
+ # M9t::Direction.compass("NE") => #<M9t::Direction:0x000000014a438618 @value=45.0>
33
32
  def compass(compass_direction)
34
- sector = I18n.t(self.measurement_name + '.sectors').find_index(compass_direction)
33
+ sector = I18n.t(self.measurement_name + ".sectors").find_index(compass_direction)
35
34
  raise "Compass direction '#{compass_direction}' not recognised" if sector.nil?
36
35
  new(sector.to_f * COMPASS_SECTOR_DEGREES)
37
36
  end
@@ -39,13 +38,11 @@ module M9t
39
38
  # Reduce directions in degrees to the range [0, 360)
40
39
  # M9t::Direction.normalize(1000) => 280.0
41
40
  def normalize(degrees)
42
- case
43
- when degrees < 0
44
- normalize(degrees + CIRCLE)
45
- when degrees >= CIRCLE
46
- normalize(degrees - CIRCLE)
41
+ remainder = degrees.remainder(CIRCLE)
42
+ if remainder < 0
43
+ remainder + CIRCLE
47
44
  else
48
- degrees
45
+ remainder
49
46
  end
50
47
  end
51
48
  end
data/lib/m9t/distance.rb CHANGED
@@ -1,5 +1,4 @@
1
- # encoding: utf-8
2
- require 'm9t/base'
1
+ require "m9t/base"
3
2
 
4
3
  module M9t
5
4
  # Represents a distance
data/lib/m9t/errors.rb CHANGED
@@ -1,7 +1,9 @@
1
- # Base class for all M9t exceptions
2
- class M9t::M9tError < StandardError
3
- end
1
+ module M9t
2
+ # Base class for all M9t exceptions
3
+ class M9tError < StandardError
4
+ end
4
5
 
5
- # Raised when a M9t class receives an unrecogized ':units' value
6
- class M9t::UnitError < M9t::M9tError
6
+ # Raised when a M9t class receives an unrecogized ':units' value
7
+ class UnitError < M9t::M9tError
8
+ end
7
9
  end
data/lib/m9t/i18n.rb CHANGED
@@ -1,8 +1,7 @@
1
- # encoding: utf-8
2
- require 'i18n'
1
+ require "i18n"
3
2
 
4
3
  locales_path = File.expand_path(
5
- File.join('..', '..', 'locales'), File.dirname(__FILE__)
4
+ File.join("..", "..", "locales"), File.dirname(__FILE__)
6
5
  )
7
6
  I18n.load_path += Dir.glob("#{ locales_path }/*.yml")
8
7
  I18n.reload!
@@ -16,19 +15,19 @@ I18n.reload!
16
15
  module I18n
17
16
  # Handle non-English numerical separators
18
17
  # with I18n.locale = :it,
19
- # I18n.localize_float(5.23) => '5,23000'
18
+ # I18n.localize_float(5.23) => "5,23000"
20
19
  def I18n.localize_float(float, options = {})
21
- format = options[:format] || '%f'
20
+ format = options[:format] || "%f"
22
21
  english = format % float
23
- integers, decimal = english.split('.')
24
- integers ||= ''
22
+ integers, decimal = english.split(".")
23
+ integers ||= ""
25
24
 
26
- thousands_separator = I18n.t('numbers.thousands_separator')
27
- integers.gsub(',', thousands_separator)
25
+ thousands_separator = I18n.t("numbers.thousands_separator")
26
+ integers.gsub(",", thousands_separator)
28
27
 
29
28
  return integers if decimal.nil?
30
29
 
31
- decimal_separator = I18n.t('numbers.decimal_separator')
30
+ decimal_separator = I18n.t("numbers.decimal_separator")
32
31
  integers + decimal_separator + decimal
33
32
  end
34
33
  end
data/lib/m9t/pressure.rb CHANGED
@@ -1,5 +1,4 @@
1
- # encoding: utf-8
2
- require 'm9t/base'
1
+ require "m9t/base"
3
2
 
4
3
  module M9t
5
4
  # Represents atmospheric (or other) pressure
data/lib/m9t/speed.rb CHANGED
@@ -1,6 +1,5 @@
1
- # encoding: utf-8
2
- require 'm9t/base'
3
- require 'm9t/distance'
1
+ require "m9t/base"
2
+ require "m9t/distance"
4
3
 
5
4
  module M9t
6
5
  # Represents a speed
@@ -1,5 +1,4 @@
1
- # encoding: utf-8
2
- require 'm9t/base'
1
+ require "m9t/base"
3
2
 
4
3
  module M9t
5
4
  # Represents a temperature
data/lib/m9t/version.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  module M9t
2
2
  module VERSION #:nodoc:
3
- MAJOR = 0
4
- MINOR = 3
5
- TINY = 6
3
+ MAJOR = 1
4
+ MINOR = 0
5
+ TINY = 0
6
6
 
7
- STRING = [MAJOR, MINOR, TINY].join('.')
7
+ STRING = [MAJOR, MINOR, TINY].join(".")
8
8
  end
9
9
  end
data/m9t.gemspec CHANGED
@@ -1,31 +1,30 @@
1
- # -*- encoding: utf-8 -*-
2
- $LOAD_PATH.unshift(File.expand_path('../lib', __FILE__))
3
- require 'm9t/version'
1
+ $LOAD_PATH.unshift(File.expand_path("../lib", __FILE__))
2
+ require "m9t/version"
4
3
 
5
4
  gemspec = Gem::Specification.new do |s|
6
- s.name = 'm9t'
5
+ s.name = "m9t"
7
6
  s.platform = Gem::Platform::RUBY
8
7
  s.version = M9t::VERSION::STRING
9
- s.required_ruby_version = '>= 1.9.3'
8
+ s.required_ruby_version = ">= 2.4.0"
10
9
 
11
- s.summary = 'Measurements and conversions library for Ruby'
12
- s.description = 'Classes for handling basic measurement units: distance, direction, speed, temperature and pressure'
10
+ s.summary = "Measurements and conversions library for Ruby"
11
+ s.description = "Classes for handling basic measurement units: distance, direction, speed, temperature and pressure"
13
12
  s.license = "MIT"
14
13
 
15
- s.homepage = 'https://github.com/joeyates/m9t'
16
- s.author = 'Joe Yates'
17
- s.email = 'joe.g.yates@gmail.com'
14
+ s.homepage = "https://github.com/joeyates/m9t"
15
+ s.author = "Joe Yates"
16
+ s.email = "joe.g.yates@gmail.com"
18
17
 
19
18
  s.files = `git ls-files`.lines.map(&:chomp!)
20
19
  s.test_files = `git ls-files spec`.lines.map(&:chomp!)
21
- s.require_paths = ['lib']
20
+ s.require_paths = ["lib"]
22
21
 
23
- s.rubyforge_project = 'nowarning'
22
+ s.rubyforge_project = "nowarning"
24
23
 
25
- s.add_dependency 'rake'
26
- s.add_dependency 'i18n', '>= 0.3.5'
24
+ s.add_dependency "rake"
25
+ s.add_dependency "i18n", ">= 0.3.5"
27
26
 
28
- s.add_development_dependency 'codeclimate-test-reporter', '~> 0.4.8'
29
- s.add_development_dependency 'rspec', '>= 3.0.0'
30
- s.add_development_dependency 'simplecov' if RUBY_PLATFORM != 'java'
27
+ s.add_development_dependency "codeclimate-test-reporter", "~> 0.4.8"
28
+ s.add_development_dependency "rspec", ">= 3.0.0"
29
+ s.add_development_dependency "simplecov" if RUBY_PLATFORM != "java"
31
30
  end
data/spec/base_spec.rb CHANGED
@@ -1,6 +1,4 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
- require 'm9t/base'
1
+ require "m9t/base"
4
2
 
5
3
  class SomeMeasurement
6
4
  DEFAULT_OPTIONS = {
@@ -19,62 +17,62 @@ end
19
17
  class SomeDerivedMeasurement < SomeMeasurement; end
20
18
 
21
19
  describe M9t::Base do
22
- describe '.respond_to?' do
23
- it 'is true for conversion between known units' do
20
+ describe ".respond_to?" do
21
+ it "is true for conversion between known units" do
24
22
  expect(SomeMeasurement.respond_to?(:foos_to_bars)).to be_truthy
25
23
  end
26
24
 
27
- it 'is false for unknown units' do
25
+ it "is false for unknown units" do
28
26
  expect(SomeMeasurement.respond_to?(:bazs_to_bars)).to be_falsey
29
27
  end
30
28
  end
31
29
 
32
- describe '.method_missing' do
33
- it 'handles conversion between known units' do
30
+ describe ".method_missing" do
31
+ it "handles conversion between known units" do
34
32
  expect(SomeMeasurement.foos_to_bars(3.0)).to be_a(Float)
35
33
  end
36
34
 
37
- it 'fails for unknown units' do
35
+ it "fails for unknown units" do
38
36
  expect {
39
37
  SomeMeasurement.bazs_to_bars(3.0)
40
38
  }.to raise_error(NoMethodError)
41
39
  end
42
40
  end
43
41
 
44
- describe '#respond_to?' do
42
+ describe "#respond_to?" do
45
43
  subject { SomeMeasurement.new(3.0) }
46
44
 
47
- it 'is true for conversion to known units' do
45
+ it "is true for conversion to known units" do
48
46
  expect(subject.respond_to?(:to_bars)).to be_truthy
49
47
  end
50
48
 
51
- it 'is false for unknown units' do
49
+ it "is false for unknown units" do
52
50
  expect(subject.respond_to?(:to_bazs)).to be_falsey
53
51
  end
54
52
 
55
- context 'for unrecognized calls' do
56
- it 'calls super' do
53
+ context "for unrecognized calls" do
54
+ it "calls super" do
57
55
  expect(subject.respond_to?(:ciao)).to be_falsey
58
56
  end
59
57
  end
60
58
  end
61
59
 
62
- describe '#method_missing' do
60
+ describe "#method_missing" do
63
61
  subject { SomeMeasurement.new(3.0) }
64
62
 
65
- it 'handles conversion to known units' do
63
+ it "handles conversion to known units" do
66
64
  expect(subject.to_bars).to be_a(Float)
67
65
  end
68
66
 
69
- it 'fails for unknown units' do
67
+ it "fails for unknown units" do
70
68
  expect {
71
69
  subject.to_bazs(3.0)
72
70
  }.to raise_error(NoMethodError)
73
71
  end
74
72
  end
75
73
 
76
- describe 'derived class' do
77
- it 'inherits options' do
74
+ describe "derived class" do
75
+ it "inherits options" do
78
76
  expect(SomeDerivedMeasurement.options).to eq(SomeMeasurement.options)
79
77
  end
80
78
  end
@@ -1,64 +1,74 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
- require 'm9t/direction'
1
+ require "m9t/direction"
4
2
 
5
3
  describe M9t::Direction do
6
4
  before do
7
5
  I18n.locale = :en
8
6
  end
9
7
 
10
- describe '.measurement_name' do
8
+ describe ".measurement_name" do
11
9
  it "is 'direction'" do
12
- expect(M9t::Direction.measurement_name).to eq('direction')
10
+ expect(M9t::Direction.measurement_name).to eq("direction")
13
11
  end
14
12
  end
15
13
 
16
- describe '.options' do
17
- it 'is set' do
14
+ describe ".options" do
15
+ it "is set" do
18
16
  expect(M9t::Direction.options).not_to be_nil
19
17
  end
20
18
 
21
- context 'abbreviated' do
22
- it 'is false' do
19
+ context "abbreviated" do
20
+ it "is false" do
23
21
  expect(M9t::Direction.options[:abbreviated]).to be_falsey
24
22
  end
25
23
  end
26
24
 
27
- context 'units' do
28
- it 'is degrees' do
25
+ context "units" do
26
+ it "is degrees" do
29
27
  expect(M9t::Direction.options[:units]).to eq(:degrees)
30
28
  end
31
29
  end
32
30
  end
33
31
 
34
- describe '.normalize' do
35
- it 'handles values > 360' do
32
+ describe ".normalize" do
33
+ it "reduces number greater than 360" do
36
34
  expect(M9t::Direction.normalize(725)).to eq(5)
37
35
  end
38
36
 
39
- it 'handles values < 0' do
37
+ it "reduces 360" do
38
+ expect(M9t::Direction.normalize(360)).to eq(0)
39
+ end
40
+
41
+ it "increases numbers less than zero" do
40
42
  expect(M9t::Direction.normalize(-355)).to eq(5)
41
43
  end
44
+
45
+ it "handles values with decimals" do
46
+ expect(M9t::Direction.normalize(360.5)).to eq(0.5)
47
+ end
48
+
49
+ it "handles large values" do
50
+ M9t::Direction.normalize(1000000000)
51
+ end
42
52
  end
43
53
 
44
- context 'conversion class methods' do
45
- describe '.degrees_to_degrees' do
46
- it 'returns the identity' do
54
+ context "conversion class methods" do
55
+ describe ".degrees_to_degrees" do
56
+ it "returns the identity" do
47
57
  expect(M9t::Direction.degrees_to_degrees(45)).to eq(45)
48
58
  end
49
59
  end
50
60
 
51
- describe '.degrees_to_compass' do
61
+ describe ".degrees_to_compass" do
52
62
  before do
53
63
  I18n.locale = :en
54
64
  end
55
65
 
56
- context 'exact' do
66
+ context "exact" do
57
67
  [
58
- 'N', 'NNE', 'NE', 'ENE',
59
- 'E', 'ESE', 'SE', 'SSE',
60
- 'S', 'SSW', 'SW', 'WSW',
61
- 'W', 'WNW', 'NW', 'NNW'
68
+ "N", "NNE", "NE", "ENE",
69
+ "E", "ESE", "SE", "SSE",
70
+ "S", "SSW", "SW", "WSW",
71
+ "W", "WNW", "NW", "NNW"
62
72
  ].each.with_index do |result, i|
63
73
  it "recognizes #{result}" do
64
74
  expect(M9t::Direction.degrees_to_compass(i * 22.5)).to eq(result)
@@ -66,121 +76,120 @@ describe M9t::Direction do
66
76
  end
67
77
  end
68
78
 
69
- context 'rounding' do
70
- specify 'up' do
71
- expect(M9t::Direction.degrees_to_compass(42)).to eq('NE')
79
+ context "rounding" do
80
+ specify "up" do
81
+ expect(M9t::Direction.degrees_to_compass(42)).to eq("NE")
72
82
  end
73
83
 
74
- specify 'down' do
75
- expect(M9t::Direction.degrees_to_compass(93)).to eq('E')
84
+ specify "down" do
85
+ expect(M9t::Direction.degrees_to_compass(93)).to eq("E")
76
86
  end
77
87
  end
78
88
 
79
- context 'i18n' do
89
+ context "i18n" do
80
90
  before do
81
91
  I18n.locale = :it
82
92
  end
83
93
 
84
- it 'translates' do
85
- expect(M9t::Direction.degrees_to_compass(270)).to eq('O')
94
+ it "translates" do
95
+ expect(M9t::Direction.degrees_to_compass(270)).to eq("O")
86
96
  end
87
97
  end
88
98
  end
89
99
 
90
- describe 'compass_to_degrees' do
91
- it 'converts correctly' do
92
- expect(M9t::Direction.compass_to_degrees('WSW')).to eq(247.5)
100
+ describe "compass_to_degrees" do
101
+ it "converts correctly" do
102
+ expect(M9t::Direction.compass_to_degrees("WSW")).to eq(247.5)
93
103
  end
94
104
  end
95
105
  end
96
106
 
97
- describe '.new' do
98
- context 'strings' do
99
- it 'works' do
100
- expect(M9t::Direction.new('35').value).to eq(35)
107
+ describe ".new" do
108
+ context "strings" do
109
+ it "works" do
110
+ expect(M9t::Direction.new("35").value).to eq(35)
101
111
  end
102
112
 
103
- it 'handles leading zeroes' do
104
- expect(M9t::Direction.new('010').value).to eq(10)
113
+ it "handles leading zeroes" do
114
+ expect(M9t::Direction.new("010").value).to eq(10)
105
115
  end
106
116
  end
107
117
  end
108
118
 
109
- describe '.compass' do
110
- it 'converts cardinals' do
111
- expect(M9t::Direction.compass('N').value).to eq(0)
119
+ describe ".compass" do
120
+ it "converts cardinals" do
121
+ expect(M9t::Direction.compass("N").value).to eq(0)
112
122
  end
113
123
 
114
- it 'handles 16ths' do
115
- expect(M9t::Direction.compass('WSW').value).to eq(247.5)
124
+ it "handles 16ths" do
125
+ expect(M9t::Direction.compass("WSW").value).to eq(247.5)
116
126
  end
117
127
  end
118
128
 
119
- describe '#value' do
129
+ describe "#value" do
120
130
  let(:degrees) { M9t::Direction.new(45) }
121
131
 
122
- it 'returns the supplied value' do
132
+ it "returns the supplied value" do
123
133
  expect(degrees.value).to eq(45)
124
134
  end
125
135
  end
126
136
 
127
- describe '#to_s' do
128
- context 'not abbreviated' do
129
- context 'singular' do
137
+ describe "#to_s" do
138
+ context "not abbreviated" do
139
+ context "singular" do
130
140
  subject { M9t::Direction.new(1) }
131
141
 
132
- it 'returns the full unit name' do
133
- expect(subject.to_s).to eq('1 degree')
142
+ it "returns the full unit name" do
143
+ expect(subject.to_s).to eq("1 degree")
134
144
  end
135
145
 
136
- it 'translates' do
146
+ it "translates" do
137
147
  I18n.locale = :it
138
- expect(subject.to_s).to eq('1 grado')
148
+ expect(subject.to_s).to eq("1 grado")
139
149
  end
140
150
  end
141
151
 
142
- context 'plural' do
152
+ context "plural" do
143
153
  subject { M9t::Direction.new(135) }
144
154
 
145
- it 'returns the full unit name' do
146
- expect(subject.to_s).to eq('135 degrees')
155
+ it "returns the full unit name" do
156
+ expect(subject.to_s).to eq("135 degrees")
147
157
  end
148
158
 
149
- it 'translates' do
159
+ it "translates" do
150
160
  I18n.locale = :it
151
- expect(subject.to_s).to eq('135 gradi')
161
+ expect(subject.to_s).to eq("135 gradi")
152
162
  end
153
163
  end
154
164
  end
155
165
 
156
- context 'abbreviated' do
166
+ context "abbreviated" do
157
167
  subject { M9t::Direction.new(135) }
158
168
 
159
- it 'uses the symbol' do
160
- expect(subject.to_s(abbreviated: true)).to eq('135°')
169
+ it "uses the symbol" do
170
+ expect(subject.to_s(abbreviated: true)).to eq("135°")
161
171
  end
162
172
  end
163
173
 
164
- context 'compass units' do
174
+ context "compass units" do
165
175
  subject { M9t::Direction.new(225) }
166
176
 
167
- it 'works' do
168
- expect(subject.to_s(units: :compass)).to eq('SW')
177
+ it "works" do
178
+ expect(subject.to_s(units: :compass)).to eq("SW")
169
179
  end
170
180
 
171
- it 'translates' do
181
+ it "translates" do
172
182
  I18n.locale = :it
173
- expect(subject.to_s(units: :compass)).to eq('SO')
183
+ expect(subject.to_s(units: :compass)).to eq("SO")
174
184
  end
175
185
  end
176
186
  end
177
187
 
178
- describe '#to_compass' do
188
+ describe "#to_compass" do
179
189
  subject { M9t::Direction.new(0) }
180
190
 
181
- it 'is correct' do
182
- expect(subject.to_compass).to eq('N')
191
+ it "is correct" do
192
+ expect(subject.to_compass).to eq("N")
183
193
  end
184
194
  end
185
195
  end
186
-