sugarcube 1.5.4 → 1.5.5

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
2
  SHA1:
3
- metadata.gz: 741a9f9b789c05eb8ad6b99f579ae571401faf73
4
- data.tar.gz: abc4c71c5bbf61b4efc1ba21fb5b62496714ed67
3
+ metadata.gz: a5bd88350a86ee4e4bedb8382ae815b7a6f593f3
4
+ data.tar.gz: bee437d228cd18da4bb87a69ded96ac42ae5c7fe
5
5
  SHA512:
6
- metadata.gz: 40fb96d9a125f15272b70cd1872d305bfdcf187cb8cec9e58f37f1bdff5478c51e81b93e0b768585760f7f8f500c4a981ced8553eb502fda0d4592d5bfe7f517
7
- data.tar.gz: 8b20303cf731e9e64596c6595a43de7f8e9cdafbf53440122c4ec6a7455ec9188af5f257e9af72bc5f44872fc31a0f6cae2ec87c4311157cabc5e5c60784ac81
6
+ metadata.gz: 08fc26e8d84dfd3a5b83f27f1da1f3fc349eb93b822efe693615164afe2e65c16c27402a1bc53f716db4d3dc153648e79ec088b8005358eeeaf82751b95d4fee
7
+ data.tar.gz: 54b8fc6295e7bc12375a98e13291506bd6f368ef8e1964beacbfa6e91f9b0154f5b5bc1bb852a203492a3659da54b47c2b740a115f64120e4b4f1dde7269b6ff
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sugarcube (1.5.4)
4
+ sugarcube (1.5.5)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -984,6 +984,10 @@ if input.nan?
984
984
  UIAlertView.alert('not a number!')
985
985
  else
986
986
  number = input.to_number
987
+ # convert a currency
988
+ number = input.to_number(NSNumberFormatterCurrencyStyle)
989
+ # convert from symbol, requires 'sugarcube-constants'
990
+ number = input.to_number(:currency)
987
991
  end
988
992
  ```
989
993
 
@@ -1,12 +1,16 @@
1
1
  class NSString
2
2
 
3
3
  # @return boolean
4
- def nan?
5
- self.to_number.nil?
4
+ def nan?(style=NSNumberFormatterDecimalStyle)
5
+ self.to_number(style).nil?
6
6
  end
7
7
 
8
- def to_number
8
+ def to_number(style=NSNumberFormatterDecimalStyle)
9
+ if style.respond_to?(:nsnumberstyle)
10
+ style = style.nsnumberstyle
11
+ end
9
12
  number_formatter = NSNumberFormatter.new
13
+ number_formatter.numberStyle = style
10
14
  number_formatter.numberFromString(self)
11
15
  end
12
16
 
@@ -1,3 +1,3 @@
1
1
  module SugarCube
2
- Version = '1.5.4'
2
+ Version = '1.5.5'
3
3
  end
@@ -93,9 +93,42 @@ describe "NSString" do
93
93
  'hello'._.should == 'howdy'
94
94
  end
95
95
 
96
- it "should have a #nan? method" do
97
- "pi".nan?.should.equal true
98
- "3.12159".nan?.should.equal false
96
+ describe "should have a #nan? method" do
97
+ it 'should return true for non-numbers' do
98
+ "pi".nan?.should.equal true
99
+ end
100
+
101
+ it 'should return false for numbers' do
102
+ "3.12159".nan?.should.equal false
103
+ end
104
+
105
+ it 'should not detect currencies' do
106
+ "$3.12159".nan?.should.equal true
107
+ end
108
+
109
+ it 'should return false for valid currencies' do
110
+ "$3.12159".nan?(:currency).should.equal false
111
+ end
112
+ end
113
+
114
+ describe "should have a #to_number method" do
115
+ it 'should detect simple integers' do
116
+ '123'.to_number.should == 123
117
+ '1,000'.to_number.should == 1000
118
+ end
119
+
120
+ it 'should detect simple floats' do
121
+ '1.25'.to_number.should == 1.25
122
+ '1,000.25'.to_number.should == 1000.25
123
+ end
124
+
125
+ it 'should return nil for non-numbers' do
126
+ 'pi'.to_number.should == nil
127
+ end
128
+
129
+ it 'should parse currencies' do
130
+ '$123.25'.to_number(:currency).should == 123.25
131
+ end
99
132
  end
100
133
 
101
134
  it "should have a #remove_accents method" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sugarcube
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.4
4
+ version: 1.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Colin T.A. Gray
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-03-05 00:00:00.000000000 Z
14
+ date: 2014-03-18 00:00:00.000000000 Z
15
15
  dependencies: []
16
16
  description: |
17
17
  == Description