numerology 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -23,4 +23,8 @@ Feature: Formatting a number
23
23
  | 12345 | 01111 | 12345 |
24
24
  | 12345 | 01,111 | 12,345 |
25
25
  | 1234 | 01,111 | 01,234 |
26
- | 123 | 01,111 | 00,123 |
26
+ | 123 | 01,111 | 00,123 |
27
+ | 123 | 100 | 100 |
28
+ | 12345 | 11000 | 12000 |
29
+ | 12345 | 11,000 | 12,000 |
30
+ | 15555 | 11,000 | 16,000 |
@@ -2,10 +2,17 @@ require "numerology/version"
2
2
 
3
3
  module Numerology
4
4
  def format_like(example)
5
+ if example.gsub(/\D/,'') =~ /(0+$)/
6
+ sig_fig = $1.length
7
+ temp = self.round(sig_fig*-1)
8
+ else
9
+ temp = self
10
+ end
11
+
5
12
  if example =~ /^[0\s]/
6
- formatted_string = "%#{example[0]}#{example.gsub(/\D/,'').length}d" % self
13
+ formatted_string = "%#{example[0]}#{example.gsub(/\D/,'').length}d" % temp
7
14
  else
8
- formatted_string = self.to_s
15
+ formatted_string = temp.to_s
9
16
  end
10
17
 
11
18
  formatted_string = separate_thousands(formatted_string, example[-4]) if example =~ /(\D)\d{3}$/
@@ -1,3 +1,3 @@
1
1
  module Numerology
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: numerology
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-08 00:00:00.000000000 Z
12
+ date: 2013-03-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake