aeonscope-number_to_fraction 1.0.0 → 1.0.1

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.
@@ -1,3 +1,7 @@
1
+ = v1.0.1
2
+
3
+ * Fixed a display bug with a fractional that was zero.
4
+
1
5
  = v1.0.0
2
6
 
3
7
  * Initial version.
@@ -1,6 +1,6 @@
1
1
  = Overview
2
2
 
3
- A helper that can format a number into a fraction. Unfortunately, this only handles the "pretty printing" of factions less than 1/10th at the moment (as a better algorithm needs to be used for more complex number cases).
3
+ A helper that can format a number into a fraction. Unfortunately, this only handles the "pretty printing" of fractions less than 1/10th at the moment (as a better algorithm needs to be used for more complex number cases).
4
4
 
5
5
  = License
6
6
 
@@ -19,18 +19,18 @@ See the CHANGELOG file for more info.
19
19
 
20
20
  Type the following from the command line to install:
21
21
 
22
- * *UNIX*: sudo gem install aeonscope-number_to_function
23
- * *Windows*: gem install aeonscope-number_to_function
22
+ * *UNIX*: sudo gem install aeonscope-number_to_fraction
23
+ * *Windows*: gem install aeonscope-number_to_fraction
24
24
 
25
25
  Update your environment.rb file to include the new gem:
26
26
 
27
- * config.gem "aeonscope-number_to_function", :lib => "number_to_function", :source => "http://gems.github.com"
27
+ * config.gem "aeonscope-number_to_fraction", :lib => "number_to_fraction", :source => "http://gems.github.com"
28
28
 
29
29
  = Usage
30
30
 
31
31
  Example:
32
32
 
33
- number_to_function 3.75
33
+ number_to_fraction 3.75
34
34
 
35
35
  Result:
36
36
 
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 1
3
3
  :minor: 0
4
- :patch: 0
4
+ :patch: 1
@@ -18,6 +18,7 @@ module ActionView
18
18
  number = number.to_s.strip
19
19
  options.reverse_merge! :precision => 3
20
20
  whole, numerator, denominator = nil
21
+ number.chomp!(".0") if number.end_with? ".0" # Remove zero fractionals.
21
22
  if number.include? '.'
22
23
  whole, numerator = number.split '.'
23
24
  rational = Rational(numerator.ljust(options[:precision], '0').to_i, (10 ** options[:precision]))
@@ -19,6 +19,14 @@ describe "Number to Fraction" do
19
19
  number_to_fraction(1).should == '1'
20
20
  end
21
21
 
22
+ it "should be 10" do
23
+ number_to_fraction(10).should == "10"
24
+ end
25
+
26
+ it "should be 10 even when the fractional is zero" do
27
+ number_to_fraction(10.0).should == "10"
28
+ end
29
+
22
30
  it "should be 1/3" do
23
31
  number_to_fraction(0.33).should == "1/3"
24
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aeonscope-number_to_fraction
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann