fractional 1.1.0 → 1.2.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 +4 -4
- data/README.rdoc +3 -1
- data/VERSION +1 -1
- data/fractional.gemspec +1 -1
- data/lib/fractional.rb +7 -3
- data/spec/fractional_spec.rb +2 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf16c52b37e110020de5ba81093c8c32dbb8c252
|
4
|
+
data.tar.gz: df91e571f26e25d8b7d182625dbd4b194a3970ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8475b78b70e2cb066ed13d0471c20d91fd06f55ae7182d7d9fff8825c0b8acaed8eb6d7a3446cdbe88d548d4557e7fbff5ed45b6f622190759ef98d466fbe4cb
|
7
|
+
data.tar.gz: 9f038a12f72a85ecbd796573c1f2f06a76a5c165df1b5adc5b207945528ba7a6d9d4c4989a052e03a44bc1714d834c98f038a7d0254ece9e744fbaeaa0adc54a
|
data/README.rdoc
CHANGED
@@ -67,7 +67,9 @@ Joey Aghion https://github.com/joeyAghion
|
|
67
67
|
|
68
68
|
muff1nman https://github.com/muff1nman
|
69
69
|
|
70
|
+
Alex Nigomatulin https://github.com/GeNiuS69
|
71
|
+
|
70
72
|
|
71
73
|
== Copyright
|
72
74
|
|
73
|
-
Copyright (c) 2009-
|
75
|
+
Copyright (c) 2009-2016 Chris O'Sullivan. See LICENSE for details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.2.0
|
data/fractional.gemspec
CHANGED
data/lib/fractional.rb
CHANGED
@@ -39,7 +39,11 @@ class Fractional < Numeric
|
|
39
39
|
to_join << whole_part.to_s
|
40
40
|
end
|
41
41
|
if fractional_part != 0
|
42
|
-
|
42
|
+
if whole_part != 0
|
43
|
+
to_join << fractional_part.abs.to_s
|
44
|
+
else
|
45
|
+
to_join << fractional_part.to_s
|
46
|
+
end
|
43
47
|
end
|
44
48
|
to_join.join(" ")
|
45
49
|
else
|
@@ -241,8 +245,8 @@ class Fractional < Numeric
|
|
241
245
|
end
|
242
246
|
end
|
243
247
|
|
244
|
-
# Display numbers in human-readable manner.
|
245
|
-
# Examples: 0.5 -> 1/2, 2.333 -> 2 1/3, 0.666 -> 2/3 etc.
|
248
|
+
# Display numbers in human-readable manner.
|
249
|
+
# Examples: 0.5 -> 1/2, 2.333 -> 2 1/3, 0.666 -> 2/3 etc.
|
246
250
|
#
|
247
251
|
def self.round_to_human_fraction(value)
|
248
252
|
numeric_to_mixed_number value.rationalize(Rational('0.01'))
|
data/spec/fractional_spec.rb
CHANGED
@@ -381,7 +381,9 @@ describe "Fractional#to_s" do
|
|
381
381
|
Fractional.new(Rational(-3,2)).to_s(mixed_number: true).should == "-1 1/2"
|
382
382
|
Fractional.new(1.00).to_s(mixed_number: true).should == "1"
|
383
383
|
Fractional.new(0.75).to_s(mixed_number: true).should == "3/4"
|
384
|
+
Fractional.new('-1/2').to_s(mixed_number: true).should == "-1/2"
|
384
385
|
end
|
386
|
+
|
385
387
|
end
|
386
388
|
|
387
389
|
describe "Fractional#to_f" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fractional
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris O'Sullivan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
105
|
version: '0'
|
106
106
|
requirements: []
|
107
107
|
rubyforge_project:
|
108
|
-
rubygems_version: 2.
|
108
|
+
rubygems_version: 2.5.1
|
109
109
|
signing_key:
|
110
110
|
specification_version: 4
|
111
111
|
summary: 'You can use fractional to convert decimal numbers to string representations
|
@@ -113,3 +113,4 @@ summary: 'You can use fractional to convert decimal numbers to string representa
|
|
113
113
|
test_files:
|
114
114
|
- spec/fractional_spec.rb
|
115
115
|
- spec/spec_helper.rb
|
116
|
+
has_rdoc:
|