sapoci 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/sapoci/item.rb +15 -7
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d426c30a6441b9b931f9f2b9119cb6ccac57d58e3cfba2d1be8d673b9a1df474
4
- data.tar.gz: '08b54350cf9bfa69ce4611ecb5cc0195f95ec60ab50c773b42e1909d5048c474'
3
+ metadata.gz: 553cb3599fb64e68ced3a9a151ca91c2e9ab27d3a8e0e070fcac952da54678c5
4
+ data.tar.gz: ec979e67665aef6f011842486544b1f31aba19290adb02ec658e84f0b282a5ba
5
5
  SHA512:
6
- metadata.gz: 1627887f2808c3c7b9d363645a965e5ee88620e175bde3fb9fcebb97aa72b134797dc87fe5461e4e8941ebe44ea18f1d8b13e1b84320c02a2b81f99975dd1499
7
- data.tar.gz: f0cd979671e24dae931d067b005ad8aa43dc5d7fd9e72bc59b15d289c933ad56bba5686285ce1964df930adaaa65c1538ad27faf953de1f5e1cf67fc5de4f017
6
+ metadata.gz: d578ae5120f30234132178ffb15f8bc2071371ee84c3e5e536eb3797c69d5f9d6058a2274ad51a09dc80f9aab1b5be66c5702d7f6320d2b3d303d1895223292e
7
+ data.tar.gz: 283200ef21c82abab10c52da87e7972a4134208e13b02cc0df3e85adf5c7eceee597676f5468d52ee480dd346dffc3623027770e79ed2ec75b19dae78a56298c
@@ -73,11 +73,19 @@ module SAPOCI
73
73
  @index = index
74
74
  end
75
75
 
76
+ def decimal(s)
77
+ if RUBY_VERSION >= '2.5'
78
+ BigDecimal(s)
79
+ else
80
+ BigDecimal.new(s)
81
+ end
82
+ end
83
+
76
84
  def quantity
77
85
  if defined?(@quantity)
78
- BigDecimal.new("0#{@quantity.to_s.strip.gsub(/,/,'.')}")
86
+ decimal("0#{@quantity.to_s.strip.gsub(/,/,'.')}")
79
87
  else
80
- BigDecimal.new("0.0")
88
+ decimal("0.0")
81
89
  end
82
90
  end
83
91
 
@@ -91,9 +99,9 @@ module SAPOCI
91
99
 
92
100
  def price
93
101
  if defined?(@price)
94
- BigDecimal.new("0#{@price.to_s.strip.gsub(/,/,'.')}")
102
+ decimal("0#{@price.to_s.strip.gsub(/,/,'.')}")
95
103
  else
96
- BigDecimal.new("0.0")
104
+ decimal("0.0")
97
105
  end
98
106
  end
99
107
 
@@ -107,7 +115,7 @@ module SAPOCI
107
115
 
108
116
  def priceunit
109
117
  if defined?(@priceunit)
110
- BigDecimal.new("0#{@priceunit.to_s.strip.gsub(/,/,'.')}").nonzero? || 1
118
+ decimal("0#{@priceunit.to_s.strip.gsub(/,/,'.')}").nonzero? || 1
111
119
  else
112
120
  1
113
121
  end
@@ -143,9 +151,9 @@ module SAPOCI
143
151
 
144
152
  def tax_rate
145
153
  if defined?(@tax_rate)
146
- BigDecimal.new("0#{@tax_rate.to_s.strip.gsub(/,/,'.')}")
154
+ decimal("0#{@tax_rate.to_s.strip.gsub(/,/,'.')}")
147
155
  else
148
- BigDecimal.new("0.0")
156
+ decimal("0.0")
149
157
  end
150
158
  end
151
159
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sapoci
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oliver Eilhard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-03 00:00:00.000000000 Z
11
+ date: 2018-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri