formatted-money 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +11 -9
- data/Rakefile +14 -13
- data/lib/formatted-money.rb +128 -122
- data/test/test_all.rb +95 -83
- metadata +14 -35
- data/doc/FormattedMoney.html +0 -1144
- data/doc/FormattedMoney/American.html +0 -255
- data/doc/FormattedMoney/European.html +0 -255
- data/doc/FormattedMoney/NumberNotInFloatFormat.html +0 -123
- data/doc/FormattedMoney/NumberNotInIntegerFormat.html +0 -123
- data/doc/_index.html +0 -162
- data/doc/class_list.html +0 -53
- data/doc/css/common.css +0 -1
- data/doc/css/full_list.css +0 -57
- data/doc/css/style.css +0 -328
- data/doc/file.README.html +0 -108
- data/doc/file_list.html +0 -55
- data/doc/frames.html +0 -28
- data/doc/index.html +0 -108
- data/doc/js/app.js +0 -214
- data/doc/js/full_list.js +0 -173
- data/doc/js/jquery.js +0 -4
- data/doc/method_list.html +0 -196
- data/doc/top-level-namespace.html +0 -112
metadata
CHANGED
@@ -1,73 +1,52 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: formatted-money
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Josef Strzibny
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2016-08-15 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
|
-
description:
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
description: |2
|
14
|
+
For all Rubyist that use Integer for storing money values as cents.
|
15
|
+
This is a dead simple gem for converting money from user inputs to Integer values
|
16
|
+
for storing and fast precise calculations (and back). Does everything you need
|
17
|
+
and nothing else. Well tested.
|
19
18
|
email: strzibny@strzibny.name
|
20
19
|
executables: []
|
21
20
|
extensions: []
|
22
21
|
extra_rdoc_files: []
|
23
22
|
files:
|
24
23
|
- LICENSE
|
25
|
-
- Rakefile
|
26
24
|
- README.md
|
27
|
-
-
|
28
|
-
- doc/FormattedMoney/American.html
|
29
|
-
- doc/FormattedMoney/European.html
|
30
|
-
- doc/FormattedMoney/NumberNotInFloatFormat.html
|
31
|
-
- doc/FormattedMoney/NumberNotInIntegerFormat.html
|
32
|
-
- doc/_index.html
|
33
|
-
- doc/class_list.html
|
34
|
-
- doc/css/common.css
|
35
|
-
- doc/css/full_list.css
|
36
|
-
- doc/css/style.css
|
37
|
-
- doc/file.README.html
|
38
|
-
- doc/file_list.html
|
39
|
-
- doc/frames.html
|
40
|
-
- doc/index.html
|
41
|
-
- doc/js/app.js
|
42
|
-
- doc/js/full_list.js
|
43
|
-
- doc/js/jquery.js
|
44
|
-
- doc/method_list.html
|
45
|
-
- doc/top-level-namespace.html
|
25
|
+
- Rakefile
|
46
26
|
- lib/formatted-money.rb
|
47
27
|
- test/test_all.rb
|
48
28
|
homepage: http://github.com/strzibny/formatted-money
|
49
29
|
licenses: []
|
30
|
+
metadata: {}
|
50
31
|
post_install_message:
|
51
32
|
rdoc_options: []
|
52
33
|
require_paths:
|
53
34
|
- lib
|
54
35
|
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
-
none: false
|
56
36
|
requirements:
|
57
|
-
- -
|
37
|
+
- - ">="
|
58
38
|
- !ruby/object:Gem::Version
|
59
|
-
version: 1.9.
|
39
|
+
version: 1.9.3
|
60
40
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
-
none: false
|
62
41
|
requirements:
|
63
|
-
- -
|
42
|
+
- - ">="
|
64
43
|
- !ruby/object:Gem::Version
|
65
44
|
version: '0'
|
66
45
|
requirements: []
|
67
46
|
rubyforge_project:
|
68
|
-
rubygems_version:
|
47
|
+
rubygems_version: 2.4.8
|
69
48
|
signing_key:
|
70
|
-
specification_version:
|
49
|
+
specification_version: 4
|
71
50
|
summary: A dead simple library for converting human-readable money inputs to Integer
|
72
51
|
and back
|
73
52
|
test_files: []
|
data/doc/FormattedMoney.html
DELETED
@@ -1,1144 +0,0 @@
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
-
<head>
|
5
|
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
-
<title>
|
7
|
-
Module: FormattedMoney
|
8
|
-
|
9
|
-
— Documentation by YARD 0.8.3
|
10
|
-
|
11
|
-
</title>
|
12
|
-
|
13
|
-
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
|
14
|
-
|
15
|
-
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
|
16
|
-
|
17
|
-
<script type="text/javascript" charset="utf-8">
|
18
|
-
hasFrames = window.top.frames.main ? true : false;
|
19
|
-
relpath = '';
|
20
|
-
framesUrl = "frames.html#!" + escape(window.location.href);
|
21
|
-
</script>
|
22
|
-
|
23
|
-
|
24
|
-
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
25
|
-
|
26
|
-
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
27
|
-
|
28
|
-
|
29
|
-
</head>
|
30
|
-
<body>
|
31
|
-
<div id="header">
|
32
|
-
<div id="menu">
|
33
|
-
|
34
|
-
<a href="_index.html">Index (F)</a> »
|
35
|
-
|
36
|
-
|
37
|
-
<span class="title">FormattedMoney</span>
|
38
|
-
|
39
|
-
|
40
|
-
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
41
|
-
</div>
|
42
|
-
|
43
|
-
<div id="search">
|
44
|
-
|
45
|
-
<a class="full_list_link" id="class_list_link"
|
46
|
-
href="class_list.html">
|
47
|
-
Class List
|
48
|
-
</a>
|
49
|
-
|
50
|
-
<a class="full_list_link" id="method_list_link"
|
51
|
-
href="method_list.html">
|
52
|
-
Method List
|
53
|
-
</a>
|
54
|
-
|
55
|
-
<a class="full_list_link" id="file_list_link"
|
56
|
-
href="file_list.html">
|
57
|
-
File List
|
58
|
-
</a>
|
59
|
-
|
60
|
-
</div>
|
61
|
-
<div class="clear"></div>
|
62
|
-
</div>
|
63
|
-
|
64
|
-
<iframe id="search_frame"></iframe>
|
65
|
-
|
66
|
-
<div id="content"><h1>Module: FormattedMoney
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
</h1>
|
71
|
-
|
72
|
-
<dl class="box">
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
<dt class="r1 last">Defined in:</dt>
|
82
|
-
<dd class="r1 last">lib/formatted-money.rb</dd>
|
83
|
-
|
84
|
-
</dl>
|
85
|
-
<div class="clear"></div>
|
86
|
-
|
87
|
-
<h2>Overview</h2><div class="docstring">
|
88
|
-
<div class="discussion">
|
89
|
-
|
90
|
-
|
91
|
-
</div>
|
92
|
-
</div>
|
93
|
-
<div class="tags">
|
94
|
-
|
95
|
-
<p class="tag_title">Author:</p>
|
96
|
-
<ul class="author">
|
97
|
-
|
98
|
-
<li>
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
<div class='inline'><p>
|
105
|
-
Josef Strzibny
|
106
|
-
</p>
|
107
|
-
</div>
|
108
|
-
|
109
|
-
</li>
|
110
|
-
|
111
|
-
</ul>
|
112
|
-
|
113
|
-
</div><h2>Defined Under Namespace</h2>
|
114
|
-
<p class="children">
|
115
|
-
|
116
|
-
|
117
|
-
<strong class="modules">Modules:</strong> <span class='object_link'><a href="FormattedMoney/American.html" title="FormattedMoney::American (module)">American</a></span>, <span class='object_link'><a href="FormattedMoney/European.html" title="FormattedMoney::European (module)">European</a></span>
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
<strong class="classes">Classes:</strong> <span class='object_link'><a href="FormattedMoney/NumberNotInFloatFormat.html" title="FormattedMoney::NumberNotInFloatFormat (class)">NumberNotInFloatFormat</a></span>, <span class='object_link'><a href="FormattedMoney/NumberNotInIntegerFormat.html" title="FormattedMoney::NumberNotInIntegerFormat (class)">NumberNotInIntegerFormat</a></span>
|
122
|
-
|
123
|
-
|
124
|
-
</p>
|
125
|
-
|
126
|
-
<h2>Constant Summary</h2>
|
127
|
-
|
128
|
-
<dl class="constants">
|
129
|
-
|
130
|
-
<dt id="omit_cents-classvariable" class="">@@omit_cents =
|
131
|
-
|
132
|
-
</dt>
|
133
|
-
<dd><pre class="code"><span class='kw'>false</span></pre></dd>
|
134
|
-
|
135
|
-
<dt id="round-classvariable" class="">@@round =
|
136
|
-
|
137
|
-
</dt>
|
138
|
-
<dd><pre class="code"><span class='kw'>true</span></pre></dd>
|
139
|
-
|
140
|
-
<dt id="delimiter-classvariable" class="">@@delimiter =
|
141
|
-
|
142
|
-
</dt>
|
143
|
-
<dd><pre class="code"><span class='const'>FormattedMoney</span><span class='op'>::</span><span class='const'>European</span><span class='op'>::</span><span class='const'>DELIMITER</span></pre></dd>
|
144
|
-
|
145
|
-
<dt id="cents_separator-classvariable" class="">@@cents_separator =
|
146
|
-
|
147
|
-
</dt>
|
148
|
-
<dd><pre class="code"><span class='const'>FormattedMoney</span><span class='op'>::</span><span class='const'>European</span><span class='op'>::</span><span class='const'>CENTS_SEPARATOR</span></pre></dd>
|
149
|
-
|
150
|
-
<dt id="escape_chars-classvariable" class="">@@escape_chars =
|
151
|
-
|
152
|
-
</dt>
|
153
|
-
<dd><pre class="code"><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>.</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>^</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>$</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>*</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span></pre></dd>
|
154
|
-
|
155
|
-
</dl>
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
<h2>
|
166
|
-
Class Method Summary
|
167
|
-
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
168
|
-
</h2>
|
169
|
-
|
170
|
-
<ul class="summary">
|
171
|
-
|
172
|
-
<li class="public ">
|
173
|
-
<span class="summary_signature">
|
174
|
-
|
175
|
-
<a href="#add_zero_cents-class_method" title="add_zero_cents (class method)">+ (Object) <strong>add_zero_cents</strong>(n) </a>
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
</span>
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
<span class="summary_desc"><div class='inline'></div></span>
|
190
|
-
|
191
|
-
</li>
|
192
|
-
|
193
|
-
|
194
|
-
<li class="public ">
|
195
|
-
<span class="summary_signature">
|
196
|
-
|
197
|
-
<a href="#amount-class_method" title="amount (class method)">+ (String) <strong>amount</strong>(amount, omit_cents = @@omit_cents, delimiter = @@delimiter, cents_separator = @@cents_separator) </a>
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
</span>
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
<span class="summary_desc"><div class='inline'><p>
|
212
|
-
Format Integer to float number with cents.
|
213
|
-
</p>
|
214
|
-
</div></span>
|
215
|
-
|
216
|
-
</li>
|
217
|
-
|
218
|
-
|
219
|
-
<li class="public ">
|
220
|
-
<span class="summary_signature">
|
221
|
-
|
222
|
-
<a href="#cents-class_method" title="cents (class method)">+ (Integer) <strong>cents</strong>(amount, round = @@round, delimiter = @@delimiter, cents_separator = @@cents_separator) </a>
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
</span>
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
<span class="summary_desc"><div class='inline'><p>
|
237
|
-
Format the float-formatted input to Integer for saving or for calculation.
|
238
|
-
</p>
|
239
|
-
</div></span>
|
240
|
-
|
241
|
-
</li>
|
242
|
-
|
243
|
-
|
244
|
-
<li class="public ">
|
245
|
-
<span class="summary_signature">
|
246
|
-
|
247
|
-
<a href="#cents_separator%3D-class_method" title="cents_separator= (class method)">+ (Object) <strong>cents_separator=</strong>(cents_separator) </a>
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
</span>
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
<span class="summary_desc"><div class='inline'></div></span>
|
262
|
-
|
263
|
-
</li>
|
264
|
-
|
265
|
-
|
266
|
-
<li class="public ">
|
267
|
-
<span class="summary_signature">
|
268
|
-
|
269
|
-
<a href="#check_float-class_method" title="check_float (class method)">+ (Object) <strong>check_float</strong>(n) </a>
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
</span>
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
<span class="summary_desc"><div class='inline'><p>
|
284
|
-
Check if the given number is formatted as a float - numbers should contain
|
285
|
-
only digits, commas or dots.
|
286
|
-
</p>
|
287
|
-
</div></span>
|
288
|
-
|
289
|
-
</li>
|
290
|
-
|
291
|
-
|
292
|
-
<li class="public ">
|
293
|
-
<span class="summary_signature">
|
294
|
-
|
295
|
-
<a href="#check_integer-class_method" title="check_integer (class method)">+ (Object) <strong>check_integer</strong>(n) </a>
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
</span>
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
<span class="summary_desc"><div class='inline'></div></span>
|
310
|
-
|
311
|
-
</li>
|
312
|
-
|
313
|
-
|
314
|
-
<li class="public ">
|
315
|
-
<span class="summary_signature">
|
316
|
-
|
317
|
-
<a href="#delimiter%3D-class_method" title="delimiter= (class method)">+ (Object) <strong>delimiter=</strong>(delimiter) </a>
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
</span>
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
<span class="summary_desc"><div class='inline'></div></span>
|
332
|
-
|
333
|
-
</li>
|
334
|
-
|
335
|
-
|
336
|
-
<li class="public ">
|
337
|
-
<span class="summary_signature">
|
338
|
-
|
339
|
-
<a href="#escape_chars%3D-class_method" title="escape_chars= (class method)">+ (Object) <strong>escape_chars=</strong>(chars) </a>
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
</span>
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
<span class="summary_desc"><div class='inline'></div></span>
|
354
|
-
|
355
|
-
</li>
|
356
|
-
|
357
|
-
|
358
|
-
<li class="public ">
|
359
|
-
<span class="summary_signature">
|
360
|
-
|
361
|
-
<a href="#number_with_delimiter-class_method" title="number_with_delimiter (class method)">+ (Object) <strong>number_with_delimiter</strong>(number, delimiter) </a>
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
</span>
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
<span class="summary_desc"><div class='inline'></div></span>
|
376
|
-
|
377
|
-
</li>
|
378
|
-
|
379
|
-
|
380
|
-
<li class="public ">
|
381
|
-
<span class="summary_signature">
|
382
|
-
|
383
|
-
<a href="#omit_cents%3D-class_method" title="omit_cents= (class method)">+ (Object) <strong>omit_cents=</strong>(bool) </a>
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
</span>
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
<span class="summary_desc"><div class='inline'></div></span>
|
398
|
-
|
399
|
-
</li>
|
400
|
-
|
401
|
-
|
402
|
-
<li class="public ">
|
403
|
-
<span class="summary_signature">
|
404
|
-
|
405
|
-
<a href="#only_zeros%3F-class_method" title="only_zeros? (class method)">+ (Boolean) <strong>only_zeros?</strong>(number, delimiter, cents_separator) </a>
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
</span>
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
<span class="summary_desc"><div class='inline'></div></span>
|
420
|
-
|
421
|
-
</li>
|
422
|
-
|
423
|
-
|
424
|
-
<li class="public ">
|
425
|
-
<span class="summary_signature">
|
426
|
-
|
427
|
-
<a href="#round%3D-class_method" title="round= (class method)">+ (Object) <strong>round=</strong>(bool) </a>
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
</span>
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
<span class="summary_desc"><div class='inline'></div></span>
|
442
|
-
|
443
|
-
</li>
|
444
|
-
|
445
|
-
|
446
|
-
<li class="public ">
|
447
|
-
<span class="summary_signature">
|
448
|
-
|
449
|
-
<a href="#separator_regex-class_method" title="separator_regex (class method)">+ (Object) <strong>separator_regex</strong>(separator) </a>
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
</span>
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
<span class="summary_desc"><div class='inline'></div></span>
|
464
|
-
|
465
|
-
</li>
|
466
|
-
|
467
|
-
|
468
|
-
<li class="public ">
|
469
|
-
<span class="summary_signature">
|
470
|
-
|
471
|
-
<a href="#trim_leading_zeros-class_method" title="trim_leading_zeros (class method)">+ (Object) <strong>trim_leading_zeros</strong>(number) </a>
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
</span>
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
<span class="summary_desc"><div class='inline'></div></span>
|
486
|
-
|
487
|
-
</li>
|
488
|
-
|
489
|
-
|
490
|
-
</ul>
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
<div id="class_method_details" class="method_details_list">
|
496
|
-
<h2>Class Method Details</h2>
|
497
|
-
|
498
|
-
|
499
|
-
<div class="method_details first">
|
500
|
-
<h3 class="signature first" id="add_zero_cents-class_method">
|
501
|
-
|
502
|
-
+ (<tt>Object</tt>) <strong>add_zero_cents</strong>(n)
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
</h3><table class="source_code">
|
509
|
-
<tr>
|
510
|
-
<td>
|
511
|
-
<pre class="lines">
|
512
|
-
|
513
|
-
|
514
|
-
121
|
515
|
-
122
|
516
|
-
123</pre>
|
517
|
-
</td>
|
518
|
-
<td>
|
519
|
-
<pre class="code"><span class="info file"># File 'lib/formatted-money.rb', line 121</span>
|
520
|
-
|
521
|
-
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_add_zero_cents'>add_zero_cents</span><span class='lparen'>(</span><span class='id identifier rubyid_n'>n</span><span class='rparen'>)</span>
|
522
|
-
<span class='const'>Integer</span><span class='lparen'>(</span><span class='id identifier rubyid_sprintf'>sprintf</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>%d00</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_n'>n</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
523
|
-
<span class='kw'>end</span></pre>
|
524
|
-
</td>
|
525
|
-
</tr>
|
526
|
-
</table>
|
527
|
-
</div>
|
528
|
-
|
529
|
-
<div class="method_details ">
|
530
|
-
<h3 class="signature " id="amount-class_method">
|
531
|
-
|
532
|
-
+ (<tt>String</tt>) <strong>amount</strong>(amount, omit_cents = @@omit_cents, delimiter = @@delimiter, cents_separator = @@cents_separator)
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
</h3><div class="docstring">
|
539
|
-
<div class="discussion">
|
540
|
-
<p>
|
541
|
-
Format Integer to float number with cents
|
542
|
-
</p>
|
543
|
-
|
544
|
-
|
545
|
-
</div>
|
546
|
-
</div>
|
547
|
-
<div class="tags">
|
548
|
-
|
549
|
-
<p class="tag_title">Returns:</p>
|
550
|
-
<ul class="return">
|
551
|
-
|
552
|
-
<li>
|
553
|
-
|
554
|
-
|
555
|
-
<span class='type'>(<tt>String</tt>)</span>
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
—
|
560
|
-
<div class='inline'><p>
|
561
|
-
amount in human-readable format
|
562
|
-
</p>
|
563
|
-
</div>
|
564
|
-
|
565
|
-
</li>
|
566
|
-
|
567
|
-
</ul>
|
568
|
-
|
569
|
-
</div><table class="source_code">
|
570
|
-
<tr>
|
571
|
-
<td>
|
572
|
-
<pre class="lines">
|
573
|
-
|
574
|
-
|
575
|
-
68
|
576
|
-
69
|
577
|
-
70
|
578
|
-
71
|
579
|
-
72
|
580
|
-
73
|
581
|
-
74
|
582
|
-
75
|
583
|
-
76
|
584
|
-
77
|
585
|
-
78
|
586
|
-
79
|
587
|
-
80
|
588
|
-
81
|
589
|
-
82
|
590
|
-
83
|
591
|
-
84
|
592
|
-
85</pre>
|
593
|
-
</td>
|
594
|
-
<td>
|
595
|
-
<pre class="code"><span class="info file"># File 'lib/formatted-money.rb', line 68</span>
|
596
|
-
|
597
|
-
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_amount'>amount</span><span class='lparen'>(</span><span class='id identifier rubyid_amount'>amount</span><span class='comma'>,</span> <span class='id identifier rubyid_omit_cents'>omit_cents</span> <span class='op'>=</span> <span class='cvar'>@@omit_cents</span><span class='comma'>,</span> <span class='id identifier rubyid_delimiter'>delimiter</span> <span class='op'>=</span> <span class='cvar'>@@delimiter</span><span class='comma'>,</span> <span class='id identifier rubyid_cents_separator'>cents_separator</span> <span class='op'>=</span> <span class='cvar'>@@cents_separator</span><span class='rparen'>)</span>
|
598
|
-
<span class='kw'>unless</span> <span class='id identifier rubyid_amount'>amount</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>Integer</span><span class='semicolon'>;</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_check_integer'>check_integer</span><span class='lparen'>(</span><span class='id identifier rubyid_amount'>amount</span><span class='rparen'>)</span><span class='semicolon'>;</span> <span class='kw'>end</span>
|
599
|
-
|
600
|
-
<span class='id identifier rubyid_amount'>amount</span> <span class='op'>=</span> <span class='id identifier rubyid_amount'>amount</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
|
601
|
-
<span class='id identifier rubyid_cents'>cents</span> <span class='op'>=</span> <span class='id identifier rubyid_amount'>amount</span><span class='lbracket'>[</span><span class='op'>-</span><span class='int'>2</span><span class='comma'>,</span><span class='int'>2</span><span class='rbracket'>]</span>
|
602
|
-
<span class='id identifier rubyid_cents'>cents</span> <span class='op'>||=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>00</span><span class='tstring_end'>'</span></span>
|
603
|
-
<span class='id identifier rubyid_units'>units</span> <span class='op'>=</span> <span class='id identifier rubyid_amount'>amount</span><span class='lbracket'>[</span><span class='int'>0</span><span class='op'>..</span><span class='op'>-</span><span class='int'>3</span><span class='rbracket'>]</span>
|
604
|
-
|
605
|
-
<span class='kw'>if</span> <span class='id identifier rubyid_units'>units</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
|
606
|
-
<span class='kw'>if</span> <span class='id identifier rubyid_omit_cents'>omit_cents</span><span class='semicolon'>;</span> <span class='kw'>return</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>0</span><span class='tstring_end'>'</span></span><span class='semicolon'>;</span> <span class='kw'>end</span>
|
607
|
-
|
608
|
-
<span class='kw'>return</span> <span class='const'>String</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>0</span><span class='tstring_end'>'</span></span> <span class='op'>+</span> <span class='id identifier rubyid_cents_separator'>cents_separator</span> <span class='op'>+</span> <span class='id identifier rubyid_cents'>cents</span><span class='rparen'>)</span>
|
609
|
-
<span class='kw'>end</span>
|
610
|
-
|
611
|
-
<span class='kw'>if</span> <span class='id identifier rubyid_omit_cents'>omit_cents</span><span class='semicolon'>;</span> <span class='kw'>return</span> <span class='const'>String</span><span class='lparen'>(</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_number_with_delimiter'>number_with_delimiter</span><span class='lparen'>(</span><span class='id identifier rubyid_units'>units</span><span class='comma'>,</span> <span class='id identifier rubyid_delimiter'>delimiter</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='semicolon'>;</span> <span class='kw'>end</span>
|
612
|
-
|
613
|
-
<span class='const'>String</span><span class='lparen'>(</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_number_with_delimiter'>number_with_delimiter</span><span class='lparen'>(</span><span class='id identifier rubyid_units'>units</span><span class='comma'>,</span> <span class='id identifier rubyid_delimiter'>delimiter</span><span class='rparen'>)</span> <span class='op'>+</span> <span class='id identifier rubyid_cents_separator'>cents_separator</span> <span class='op'>+</span> <span class='id identifier rubyid_cents'>cents</span><span class='rparen'>)</span>
|
614
|
-
<span class='kw'>end</span></pre>
|
615
|
-
</td>
|
616
|
-
</tr>
|
617
|
-
</table>
|
618
|
-
</div>
|
619
|
-
|
620
|
-
<div class="method_details ">
|
621
|
-
<h3 class="signature " id="cents-class_method">
|
622
|
-
|
623
|
-
+ (<tt>Integer</tt>) <strong>cents</strong>(amount, round = @@round, delimiter = @@delimiter, cents_separator = @@cents_separator)
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
</h3><div class="docstring">
|
630
|
-
<div class="discussion">
|
631
|
-
<p>
|
632
|
-
Format the float-formatted input to Integer for saving or for calculation
|
633
|
-
</p>
|
634
|
-
|
635
|
-
|
636
|
-
</div>
|
637
|
-
</div>
|
638
|
-
<div class="tags">
|
639
|
-
|
640
|
-
<p class="tag_title">Returns:</p>
|
641
|
-
<ul class="return">
|
642
|
-
|
643
|
-
<li>
|
644
|
-
|
645
|
-
|
646
|
-
<span class='type'>(<tt>Integer</tt>)</span>
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
—
|
651
|
-
<div class='inline'><p>
|
652
|
-
money as cents
|
653
|
-
</p>
|
654
|
-
</div>
|
655
|
-
|
656
|
-
</li>
|
657
|
-
|
658
|
-
</ul>
|
659
|
-
|
660
|
-
</div><table class="source_code">
|
661
|
-
<tr>
|
662
|
-
<td>
|
663
|
-
<pre class="lines">
|
664
|
-
|
665
|
-
|
666
|
-
89
|
667
|
-
90
|
668
|
-
91
|
669
|
-
92
|
670
|
-
93
|
671
|
-
94
|
672
|
-
95
|
673
|
-
96
|
674
|
-
97
|
675
|
-
98
|
676
|
-
99
|
677
|
-
100
|
678
|
-
101
|
679
|
-
102
|
680
|
-
103
|
681
|
-
104
|
682
|
-
105
|
683
|
-
106
|
684
|
-
107
|
685
|
-
108
|
686
|
-
109
|
687
|
-
110
|
688
|
-
111
|
689
|
-
112
|
690
|
-
113
|
691
|
-
114
|
692
|
-
115
|
693
|
-
116
|
694
|
-
117
|
695
|
-
118
|
696
|
-
119</pre>
|
697
|
-
</td>
|
698
|
-
<td>
|
699
|
-
<pre class="code"><span class="info file"># File 'lib/formatted-money.rb', line 89</span>
|
700
|
-
|
701
|
-
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_cents'>cents</span><span class='lparen'>(</span><span class='id identifier rubyid_amount'>amount</span><span class='comma'>,</span> <span class='id identifier rubyid_round'>round</span> <span class='op'>=</span> <span class='cvar'>@@round</span><span class='comma'>,</span> <span class='id identifier rubyid_delimiter'>delimiter</span> <span class='op'>=</span> <span class='cvar'>@@delimiter</span><span class='comma'>,</span> <span class='id identifier rubyid_cents_separator'>cents_separator</span> <span class='op'>=</span> <span class='cvar'>@@cents_separator</span><span class='rparen'>)</span>
|
702
|
-
<span class='id identifier rubyid_delimiter_regex'>delimiter_regex</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_separator_regex'>separator_regex</span><span class='lparen'>(</span><span class='id identifier rubyid_delimiter'>delimiter</span><span class='rparen'>)</span>
|
703
|
-
<span class='id identifier rubyid_cents_separator_regex'>cents_separator_regex</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_separator_regex'>separator_regex</span><span class='lparen'>(</span><span class='id identifier rubyid_cents_separator'>cents_separator</span><span class='rparen'>)</span>
|
704
|
-
|
705
|
-
<span class='comment'># Only zeros
|
706
|
-
</span> <span class='kw'>if</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_only_zeros?'>only_zeros?</span><span class='lparen'>(</span><span class='id identifier rubyid_amount'>amount</span><span class='comma'>,</span> <span class='id identifier rubyid_delimiter_regex'>delimiter_regex</span><span class='comma'>,</span> <span class='id identifier rubyid_cents_separator_regex'>cents_separator_regex</span><span class='rparen'>)</span><span class='semicolon'>;</span> <span class='kw'>return</span> <span class='int'>0</span><span class='semicolon'>;</span> <span class='kw'>end</span><span class='semicolon'>;</span>
|
707
|
-
|
708
|
-
<span class='comment'># Already integer
|
709
|
-
</span> <span class='kw'>if</span> <span class='id identifier rubyid_amount'>amount</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>Integer</span><span class='semicolon'>;</span> <span class='kw'>return</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_add_zero_cents'>add_zero_cents</span> <span class='id identifier rubyid_amount'>amount</span><span class='semicolon'>;</span> <span class='kw'>end</span><span class='semicolon'>;</span>
|
710
|
-
|
711
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_check_float'>check_float</span><span class='lparen'>(</span><span class='id identifier rubyid_amount'>amount</span><span class='rparen'>)</span>
|
712
|
-
|
713
|
-
<span class='comment'># No cents
|
714
|
-
</span> <span class='id identifier rubyid_amount'>amount</span> <span class='op'>=</span> <span class='id identifier rubyid_amount'>amount</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_delimiter'>delimiter</span><span class='rparen'>)</span>
|
715
|
-
<span class='kw'>if</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^\d+$</span><span class='regexp_end'>/</span></span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span> <span class='id identifier rubyid_amount'>amount</span><span class='semicolon'>;</span> <span class='kw'>return</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_add_zero_cents'>add_zero_cents</span> <span class='id identifier rubyid_amount'>amount</span><span class='semicolon'>;</span> <span class='kw'>end</span><span class='semicolon'>;</span>
|
716
|
-
|
717
|
-
<span class='comment'># With cents
|
718
|
-
</span> <span class='id identifier rubyid_units'>units</span> <span class='op'>=</span> <span class='id identifier rubyid_amount'>amount</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_cents_separator_regex'>cents_separator_regex</span><span class='rbrace'>}</span><span class='tstring_content'>\d+</span><span class='regexp_end'>/</span></span><span class='comma'>,</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
719
|
-
<span class='id identifier rubyid_cents'>cents</span> <span class='op'>=</span> <span class='id identifier rubyid_amount'>amount</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_units'>units</span><span class='rbrace'>}</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_cents_separator_regex'>cents_separator_regex</span><span class='rbrace'>}</span><span class='regexp_end'>/</span></span><span class='comma'>,</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
720
|
-
|
721
|
-
<span class='comment'># Round the last cent
|
722
|
-
</span> <span class='kw'>unless</span> <span class='id identifier rubyid_cents'>cents</span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='kw'>and</span> <span class='id identifier rubyid_round'>round</span>
|
723
|
-
<span class='id identifier rubyid_last_cent'>last_cent</span> <span class='op'>=</span> <span class='id identifier rubyid_cents'>cents</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
|
724
|
-
|
725
|
-
<span class='kw'>if</span> <span class='const'>Integer</span><span class='lparen'>(</span><span class='id identifier rubyid_cents'>cents</span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='op'>>=</span> <span class='int'>5</span><span class='semicolon'>;</span> <span class='id identifier rubyid_last_cent'>last_cent</span> <span class='op'>=</span> <span class='const'>Integer</span><span class='lparen'>(</span><span class='id identifier rubyid_last_cent'>last_cent</span><span class='rparen'>)</span> <span class='op'>+</span> <span class='int'>1</span><span class='semicolon'>;</span> <span class='kw'>end</span>
|
726
|
-
|
727
|
-
<span class='kw'>return</span> <span class='const'>Integer</span><span class='lparen'>(</span><span class='id identifier rubyid_units'>units</span> <span class='op'>+</span> <span class='id identifier rubyid_cents'>cents</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>+</span> <span class='const'>String</span><span class='lparen'>(</span><span class='id identifier rubyid_last_cent'>last_cent</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
728
|
-
<span class='kw'>end</span>
|
729
|
-
|
730
|
-
<span class='const'>Integer</span><span class='lparen'>(</span><span class='id identifier rubyid_units'>units</span> <span class='op'>+</span> <span class='id identifier rubyid_cents'>cents</span><span class='rparen'>)</span>
|
731
|
-
<span class='kw'>end</span></pre>
|
732
|
-
</td>
|
733
|
-
</tr>
|
734
|
-
</table>
|
735
|
-
</div>
|
736
|
-
|
737
|
-
<div class="method_details ">
|
738
|
-
<h3 class="signature " id="cents_separator=-class_method">
|
739
|
-
|
740
|
-
+ (<tt>Object</tt>) <strong>cents_separator=</strong>(cents_separator)
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
</h3><table class="source_code">
|
747
|
-
<tr>
|
748
|
-
<td>
|
749
|
-
<pre class="lines">
|
750
|
-
|
751
|
-
|
752
|
-
62
|
753
|
-
63
|
754
|
-
64</pre>
|
755
|
-
</td>
|
756
|
-
<td>
|
757
|
-
<pre class="code"><span class="info file"># File 'lib/formatted-money.rb', line 62</span>
|
758
|
-
|
759
|
-
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_cents_separator='>cents_separator=</span><span class='lparen'>(</span><span class='id identifier rubyid_cents_separator'>cents_separator</span><span class='rparen'>)</span>
|
760
|
-
<span class='cvar'>@@cents_separator</span> <span class='op'>=</span> <span class='id identifier rubyid_cents_separator'>cents_separator</span>
|
761
|
-
<span class='kw'>end</span></pre>
|
762
|
-
</td>
|
763
|
-
</tr>
|
764
|
-
</table>
|
765
|
-
</div>
|
766
|
-
|
767
|
-
<div class="method_details ">
|
768
|
-
<h3 class="signature " id="check_float-class_method">
|
769
|
-
|
770
|
-
+ (<tt>Object</tt>) <strong>check_float</strong>(n)
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
</h3><div class="docstring">
|
777
|
-
<div class="discussion">
|
778
|
-
<p>
|
779
|
-
Check if the given number is formatted as a float - numbers should contain
|
780
|
-
only digits, commas or dots. Only numbers like 1.000.000.000,2056 or
|
781
|
-
2,150.3 are accepted
|
782
|
-
</p>
|
783
|
-
|
784
|
-
|
785
|
-
</div>
|
786
|
-
</div>
|
787
|
-
<div class="tags">
|
788
|
-
|
789
|
-
|
790
|
-
</div><table class="source_code">
|
791
|
-
<tr>
|
792
|
-
<td>
|
793
|
-
<pre class="lines">
|
794
|
-
|
795
|
-
|
796
|
-
128
|
797
|
-
129
|
798
|
-
130
|
799
|
-
131
|
800
|
-
132</pre>
|
801
|
-
</td>
|
802
|
-
<td>
|
803
|
-
<pre class="code"><span class="info file"># File 'lib/formatted-money.rb', line 128</span>
|
804
|
-
|
805
|
-
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_check_float'>check_float</span><span class='lparen'>(</span><span class='id identifier rubyid_n'>n</span><span class='rparen'>)</span>
|
806
|
-
<span class='kw'>unless</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^[\d\.\,]*$</span><span class='regexp_end'>/</span></span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='id identifier rubyid_n'>n</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rparen'>)</span>
|
807
|
-
<span class='id identifier rubyid_throw'>throw</span> <span class='const'>NumberNotInFloatFormat</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Float numbers can only be made out of digits, commas (,) or dots (.).</span><span class='tstring_end'>'</span></span>
|
808
|
-
<span class='kw'>end</span>
|
809
|
-
<span class='kw'>end</span></pre>
|
810
|
-
</td>
|
811
|
-
</tr>
|
812
|
-
</table>
|
813
|
-
</div>
|
814
|
-
|
815
|
-
<div class="method_details ">
|
816
|
-
<h3 class="signature " id="check_integer-class_method">
|
817
|
-
|
818
|
-
+ (<tt>Object</tt>) <strong>check_integer</strong>(n)
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
</h3><table class="source_code">
|
825
|
-
<tr>
|
826
|
-
<td>
|
827
|
-
<pre class="lines">
|
828
|
-
|
829
|
-
|
830
|
-
134
|
831
|
-
135
|
832
|
-
136
|
833
|
-
137
|
834
|
-
138</pre>
|
835
|
-
</td>
|
836
|
-
<td>
|
837
|
-
<pre class="code"><span class="info file"># File 'lib/formatted-money.rb', line 134</span>
|
838
|
-
|
839
|
-
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_check_integer'>check_integer</span><span class='lparen'>(</span><span class='id identifier rubyid_n'>n</span><span class='rparen'>)</span>
|
840
|
-
<span class='kw'>unless</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^\d*$</span><span class='regexp_end'>/</span></span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='id identifier rubyid_n'>n</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rparen'>)</span>
|
841
|
-
<span class='id identifier rubyid_throw'>throw</span> <span class='const'>NumberNotInIntegerFormat</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Integer numbers can only be made out of digits.</span><span class='tstring_end'>'</span></span>
|
842
|
-
<span class='kw'>end</span>
|
843
|
-
<span class='kw'>end</span></pre>
|
844
|
-
</td>
|
845
|
-
</tr>
|
846
|
-
</table>
|
847
|
-
</div>
|
848
|
-
|
849
|
-
<div class="method_details ">
|
850
|
-
<h3 class="signature " id="delimiter=-class_method">
|
851
|
-
|
852
|
-
+ (<tt>Object</tt>) <strong>delimiter=</strong>(delimiter)
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
</h3><table class="source_code">
|
859
|
-
<tr>
|
860
|
-
<td>
|
861
|
-
<pre class="lines">
|
862
|
-
|
863
|
-
|
864
|
-
58
|
865
|
-
59
|
866
|
-
60</pre>
|
867
|
-
</td>
|
868
|
-
<td>
|
869
|
-
<pre class="code"><span class="info file"># File 'lib/formatted-money.rb', line 58</span>
|
870
|
-
|
871
|
-
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_delimiter='>delimiter=</span><span class='lparen'>(</span><span class='id identifier rubyid_delimiter'>delimiter</span><span class='rparen'>)</span>
|
872
|
-
<span class='cvar'>@@delimiter</span> <span class='op'>=</span> <span class='id identifier rubyid_delimiter'>delimiter</span>
|
873
|
-
<span class='kw'>end</span></pre>
|
874
|
-
</td>
|
875
|
-
</tr>
|
876
|
-
</table>
|
877
|
-
</div>
|
878
|
-
|
879
|
-
<div class="method_details ">
|
880
|
-
<h3 class="signature " id="escape_chars=-class_method">
|
881
|
-
|
882
|
-
+ (<tt>Object</tt>) <strong>escape_chars=</strong>(chars)
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
</h3><table class="source_code">
|
889
|
-
<tr>
|
890
|
-
<td>
|
891
|
-
<pre class="lines">
|
892
|
-
|
893
|
-
|
894
|
-
46
|
895
|
-
47
|
896
|
-
48</pre>
|
897
|
-
</td>
|
898
|
-
<td>
|
899
|
-
<pre class="code"><span class="info file"># File 'lib/formatted-money.rb', line 46</span>
|
900
|
-
|
901
|
-
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_escape_chars='>escape_chars=</span><span class='lparen'>(</span><span class='id identifier rubyid_chars'>chars</span><span class='rparen'>)</span>
|
902
|
-
<span class='cvar'>@@escape_chars</span> <span class='op'>=</span> <span class='id identifier rubyid_chars'>chars</span>
|
903
|
-
<span class='kw'>end</span></pre>
|
904
|
-
</td>
|
905
|
-
</tr>
|
906
|
-
</table>
|
907
|
-
</div>
|
908
|
-
|
909
|
-
<div class="method_details ">
|
910
|
-
<h3 class="signature " id="number_with_delimiter-class_method">
|
911
|
-
|
912
|
-
+ (<tt>Object</tt>) <strong>number_with_delimiter</strong>(number, delimiter)
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
</h3><table class="source_code">
|
919
|
-
<tr>
|
920
|
-
<td>
|
921
|
-
<pre class="lines">
|
922
|
-
|
923
|
-
|
924
|
-
140
|
925
|
-
141
|
926
|
-
142</pre>
|
927
|
-
</td>
|
928
|
-
<td>
|
929
|
-
<pre class="code"><span class="info file"># File 'lib/formatted-money.rb', line 140</span>
|
930
|
-
|
931
|
-
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_number_with_delimiter'>number_with_delimiter</span><span class='lparen'>(</span><span class='id identifier rubyid_number'>number</span><span class='comma'>,</span> <span class='id identifier rubyid_delimiter'>delimiter</span><span class='rparen'>)</span>
|
932
|
-
<span class='id identifier rubyid_number'>number</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>(\d)(?=(\d\d\d)+(?!\d))</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\\1</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_delimiter'>delimiter</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
933
|
-
<span class='kw'>end</span></pre>
|
934
|
-
</td>
|
935
|
-
</tr>
|
936
|
-
</table>
|
937
|
-
</div>
|
938
|
-
|
939
|
-
<div class="method_details ">
|
940
|
-
<h3 class="signature " id="omit_cents=-class_method">
|
941
|
-
|
942
|
-
+ (<tt>Object</tt>) <strong>omit_cents=</strong>(bool)
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
</h3><table class="source_code">
|
949
|
-
<tr>
|
950
|
-
<td>
|
951
|
-
<pre class="lines">
|
952
|
-
|
953
|
-
|
954
|
-
50
|
955
|
-
51
|
956
|
-
52</pre>
|
957
|
-
</td>
|
958
|
-
<td>
|
959
|
-
<pre class="code"><span class="info file"># File 'lib/formatted-money.rb', line 50</span>
|
960
|
-
|
961
|
-
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_omit_cents='>omit_cents=</span><span class='lparen'>(</span><span class='id identifier rubyid_bool'>bool</span><span class='rparen'>)</span>
|
962
|
-
<span class='cvar'>@@omit_cents</span> <span class='op'>=</span> <span class='id identifier rubyid_bool'>bool</span>
|
963
|
-
<span class='kw'>end</span></pre>
|
964
|
-
</td>
|
965
|
-
</tr>
|
966
|
-
</table>
|
967
|
-
</div>
|
968
|
-
|
969
|
-
<div class="method_details ">
|
970
|
-
<h3 class="signature " id="only_zeros?-class_method">
|
971
|
-
|
972
|
-
+ (<tt>Boolean</tt>) <strong>only_zeros?</strong>(number, delimiter, cents_separator)
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
</h3><div class="docstring">
|
979
|
-
<div class="discussion">
|
980
|
-
|
981
|
-
|
982
|
-
</div>
|
983
|
-
</div>
|
984
|
-
<div class="tags">
|
985
|
-
|
986
|
-
<p class="tag_title">Returns:</p>
|
987
|
-
<ul class="return">
|
988
|
-
|
989
|
-
<li>
|
990
|
-
|
991
|
-
|
992
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
</li>
|
997
|
-
|
998
|
-
</ul>
|
999
|
-
|
1000
|
-
</div><table class="source_code">
|
1001
|
-
<tr>
|
1002
|
-
<td>
|
1003
|
-
<pre class="lines">
|
1004
|
-
|
1005
|
-
|
1006
|
-
159
|
1007
|
-
160
|
1008
|
-
161
|
1009
|
-
162
|
1010
|
-
163
|
1011
|
-
164
|
1012
|
-
165</pre>
|
1013
|
-
</td>
|
1014
|
-
<td>
|
1015
|
-
<pre class="code"><span class="info file"># File 'lib/formatted-money.rb', line 159</span>
|
1016
|
-
|
1017
|
-
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_only_zeros?'>only_zeros?</span><span class='lparen'>(</span><span class='id identifier rubyid_number'>number</span><span class='comma'>,</span> <span class='id identifier rubyid_delimiter'>delimiter</span><span class='comma'>,</span> <span class='id identifier rubyid_cents_separator'>cents_separator</span><span class='rparen'>)</span>
|
1018
|
-
<span class='kw'>unless</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^[0</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_delimiter'>delimiter</span><span class='rbrace'>}</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_cents_separator'>cents_separator</span><span class='rbrace'>}</span><span class='tstring_content'>]*$</span><span class='regexp_end'>/</span></span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='id identifier rubyid_number'>number</span><span class='rparen'>)</span>
|
1019
|
-
<span class='kw'>return</span> <span class='kw'>false</span><span class='semicolon'>;</span>
|
1020
|
-
<span class='kw'>end</span>
|
1021
|
-
|
1022
|
-
<span class='kw'>return</span> <span class='kw'>true</span><span class='semicolon'>;</span>
|
1023
|
-
<span class='kw'>end</span></pre>
|
1024
|
-
</td>
|
1025
|
-
</tr>
|
1026
|
-
</table>
|
1027
|
-
</div>
|
1028
|
-
|
1029
|
-
<div class="method_details ">
|
1030
|
-
<h3 class="signature " id="round=-class_method">
|
1031
|
-
|
1032
|
-
+ (<tt>Object</tt>) <strong>round=</strong>(bool)
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
</h3><table class="source_code">
|
1039
|
-
<tr>
|
1040
|
-
<td>
|
1041
|
-
<pre class="lines">
|
1042
|
-
|
1043
|
-
|
1044
|
-
54
|
1045
|
-
55
|
1046
|
-
56</pre>
|
1047
|
-
</td>
|
1048
|
-
<td>
|
1049
|
-
<pre class="code"><span class="info file"># File 'lib/formatted-money.rb', line 54</span>
|
1050
|
-
|
1051
|
-
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_round='>round=</span><span class='lparen'>(</span><span class='id identifier rubyid_bool'>bool</span><span class='rparen'>)</span>
|
1052
|
-
<span class='cvar'>@@round</span> <span class='op'>=</span> <span class='id identifier rubyid_bool'>bool</span>
|
1053
|
-
<span class='kw'>end</span></pre>
|
1054
|
-
</td>
|
1055
|
-
</tr>
|
1056
|
-
</table>
|
1057
|
-
</div>
|
1058
|
-
|
1059
|
-
<div class="method_details ">
|
1060
|
-
<h3 class="signature " id="separator_regex-class_method">
|
1061
|
-
|
1062
|
-
+ (<tt>Object</tt>) <strong>separator_regex</strong>(separator)
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
</h3><table class="source_code">
|
1069
|
-
<tr>
|
1070
|
-
<td>
|
1071
|
-
<pre class="lines">
|
1072
|
-
|
1073
|
-
|
1074
|
-
151
|
1075
|
-
152
|
1076
|
-
153
|
1077
|
-
154
|
1078
|
-
155
|
1079
|
-
156
|
1080
|
-
157</pre>
|
1081
|
-
</td>
|
1082
|
-
<td>
|
1083
|
-
<pre class="code"><span class="info file"># File 'lib/formatted-money.rb', line 151</span>
|
1084
|
-
|
1085
|
-
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_separator_regex'>separator_regex</span><span class='lparen'>(</span><span class='id identifier rubyid_separator'>separator</span><span class='rparen'>)</span>
|
1086
|
-
<span class='kw'>if</span> <span class='cvar'>@@escape_chars</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span> <span class='id identifier rubyid_separator'>separator</span>
|
1087
|
-
<span class='kw'>return</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\\</span><span class='tstring_end'>"</span></span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_separator'>separator</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span>
|
1088
|
-
<span class='kw'>end</span>
|
1089
|
-
|
1090
|
-
<span class='kw'>return</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_separator'>separator</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span>
|
1091
|
-
<span class='kw'>end</span></pre>
|
1092
|
-
</td>
|
1093
|
-
</tr>
|
1094
|
-
</table>
|
1095
|
-
</div>
|
1096
|
-
|
1097
|
-
<div class="method_details ">
|
1098
|
-
<h3 class="signature " id="trim_leading_zeros-class_method">
|
1099
|
-
|
1100
|
-
+ (<tt>Object</tt>) <strong>trim_leading_zeros</strong>(number)
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
</h3><table class="source_code">
|
1107
|
-
<tr>
|
1108
|
-
<td>
|
1109
|
-
<pre class="lines">
|
1110
|
-
|
1111
|
-
|
1112
|
-
144
|
1113
|
-
145
|
1114
|
-
146
|
1115
|
-
147
|
1116
|
-
148
|
1117
|
-
149</pre>
|
1118
|
-
</td>
|
1119
|
-
<td>
|
1120
|
-
<pre class="code"><span class="info file"># File 'lib/formatted-money.rb', line 144</span>
|
1121
|
-
|
1122
|
-
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_trim_leading_zeros'>trim_leading_zeros</span><span class='lparen'>(</span><span class='id identifier rubyid_number'>number</span><span class='rparen'>)</span>
|
1123
|
-
<span class='id identifier rubyid_string'>string</span> <span class='op'>=</span> <span class='id identifier rubyid_number'>number</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^[0]*(.*)</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>\\1</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
1124
|
-
<span class='id identifier rubyid_string'>string</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>0</span><span class='tstring_end'>'</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_string'>string</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
|
1125
|
-
|
1126
|
-
<span class='id identifier rubyid_string'>string</span>
|
1127
|
-
<span class='kw'>end</span></pre>
|
1128
|
-
</td>
|
1129
|
-
</tr>
|
1130
|
-
</table>
|
1131
|
-
</div>
|
1132
|
-
|
1133
|
-
</div>
|
1134
|
-
|
1135
|
-
</div>
|
1136
|
-
|
1137
|
-
<div id="footer">
|
1138
|
-
Generated on Mon Nov 19 20:29:51 2012 by
|
1139
|
-
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1140
|
-
0.8.3 (ruby-1.9.2).
|
1141
|
-
</div>
|
1142
|
-
|
1143
|
-
</body>
|
1144
|
-
</html>
|