Class: Code::Object::Decimal

Inherits:
Number show all
Defined in:
lib/code/object/decimal.rb

Constant Summary

Constants inherited from Code::Object

NUMBER_CLASSES

Instance Attribute Summary

Attributes included from Concerns::Shared

#methods, #raw

Instance Method Summary collapse

Methods inherited from Code::Object

code_new, #code_new, maybe, #name, repeat, |

Methods included from Concerns::Shared

#<=>, #==, #as_json, #code_and, #code_as_json, #code_deep_duplicate, #code_different, #code_duplicate, #code_equal, #code_exclamation_mark, #code_exclusive_range, #code_falsy?, #code_fetch, code_fetch, #code_get, code_get, #code_inclusive_range, #code_inspect, #code_methods, #code_name, #code_nothing?, #code_or, #code_self, #code_set, code_set, #code_something?, #code_strict_different, #code_strict_equal, #code_to_boolean, #code_to_class, #code_to_date, #code_to_decimal, #code_to_dictionary, #code_to_duration, #code_to_integer, #code_to_json, #code_to_list, #code_to_nothing, #code_to_parameter, #code_to_range, #code_to_time, #code_truthy?, #eql?, #falsy?, #hash, #inspect, #multi_fetch, #nothing?, #sig, #something?, #succ, #to_code, #to_i, #to_json, #to_s, #truthy?

Constructor Details

#initialize(*args, **_kargs, &_block) ⇒ Decimal

Returns a new instance of Decimal.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/code/object/decimal.rb', line 6

def initialize(*args, **_kargs, &_block)
  self.raw =
    if args.first.class.in?(NUMBER_CLASSES)
      if args.second.class.in?(NUMBER_CLASSES)
        args.first.to_s.to_d * (10**args.second.to_s.to_d)
      else
        args.first.to_s.to_d
      end
    else
      0.to_d
    end
rescue FloatDomainError
  self.raw = 0.to_d
end

Instance Method Details

#call(**args) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
# File 'lib/code/object/decimal.rb', line 21

def call(**args)
  code_operator = args.fetch(:operator, nil).to_code
  code_arguments = args.fetch(:arguments, []).to_code
  code_value = code_arguments.code_first

  case code_operator.to_s
  when "%", "modulo"
    sig(args) { Integer | Decimal }
    code_modulo(code_value)
  when "&", "bitwise_and"
    sig(args) { Integer | Decimal }
    code_bitwise_and(code_value)
  when "*", "multiplication"
    sig(args) { Integer | Decimal }
    code_multiplication(code_value)
  when "**", "power"
    sig(args) { Integer | Decimal }
    code_power(code_value)
  when "+", "plus"
    sig(args) { Object.maybe }
    code_arguments.any? ? code_plus(code_value) : self
  when "-", "minus"
    sig(args) { (Integer | Decimal).maybe }
    code_arguments.any? ? code_minus(code_value) : code_unary_minus
  when "/", "division"
    sig(args) { Integer | Decimal }
    code_division(code_value)
  when "<", "inferior"
    sig(args) { Integer | Decimal }
    code_inferior(code_value)
  when "<<", "left_shift"
    sig(args) { Integer | Decimal }
    code_left_shift(code_value)
  when "<=", "inferior_or_equal"
    sig(args) { Integer | Decimal }
    code_inferior_or_equal(code_value)
  when "<=>", "compare"
    sig(args) { Integer | Decimal }
    code_compare(code_value)
  when ">", "superior"
    sig(args) { Integer | Decimal }
    code_superior(code_value)
  when ">=", "superior_or_equal"
    sig(args) { Integer | Decimal }
    code_superior_or_equal(code_value)
  when ">>", "right_shift"
    sig(args) { Integer | Decimal }
    code_right_shift(code_value)
  when "^", "bitwise_xor"
    sig(args) { Integer | Decimal }
    code_bitwise_xor(code_value)
  when "abs"
    sig(args)
    code_abs
  when "ceil"
    sig(args) { Integer.maybe }
    code_ceil(code_value)
  when "floor"
    sig(args) { Integer.maybe }
    code_floor(code_value)
  when "round"
    sig(args) { Integer.maybe }
    code_round(code_value)
  when "sqrt"
    sig(args)
    code_sqrt
  when "truncate"
    sig(args) { Integer.maybe }
    code_truncate(code_value)
  when "|", "bitwise_or"
    sig(args) { Integer | Decimal }
    code_bitwise_or(code_value)
  when "many?"
    sig(args)
    code_many?
  when "any?"
    sig(args)
    code_any?
  when "positive?"
    sig(args)
    code_positive?
  when "negative?"
    sig(args)
    code_negative?
  when "zero?"
    sig(args)
    code_zero?
  when "one?"
    sig(args)
    code_one?
  when "two?"
    sig(args)
    code_two?
  when "three?"
    sig(args)
    code_three?
  when "four?"
    sig(args)
    code_four?
  when "five?"
    sig(args)
    code_five?
  when "six?"
    sig(args)
    code_six?
  when "seven?"
    sig(args)
    code_seven?
  when "eight?"
    sig(args)
    code_eight?
  when "nine?"
    sig(args)
    code_nine?
  when "ten?"
    sig(args)
    code_ten?
  when "eleven?"
    sig(args)
    code_eleven?
  when "twelve?"
    sig(args)
    code_twelve?
  when "thirteen?"
    sig(args)
    code_thirteen?
  when "fourteen?"
    sig(args)
    code_fourteen?
  when "fifteen?"
    sig(args)
    code_fifteen?
  when "sixteen?"
    sig(args)
    code_sixteen?
  when "seventeen?"
    sig(args)
    code_seventeen?
  when "eighteen?"
    sig(args)
    code_eighteen?
  when "nineteen?"
    sig(args)
    code_nineteen?
  when "twenty?"
    sig(args)
    code_twenty?
  when "twenty_one?"
    sig(args)
    code_twenty_one?
  when "twenty_two?"
    sig(args)
    code_twenty_two?
  when "twenty_three?"
    sig(args)
    code_twenty_three?
  when "twenty_four?"
    sig(args)
    code_twenty_four?
  when "twenty_five?"
    sig(args)
    code_twenty_five?
  when "twenty_six?"
    sig(args)
    code_twenty_six?
  when "twenty_seven?"
    sig(args)
    code_twenty_seven?
  when "twenty_eight?"
    sig(args)
    code_twenty_eight?
  when "twenty_nine?"
    sig(args)
    code_twenty_nine?
  when "thirty?"
    sig(args)
    code_thirty?
  when "thirty_one?"
    sig(args)
    code_thirty_one?
  when "thirty_two?"
    sig(args)
    code_thirty_two?
  when "thirty_three?"
    sig(args)
    code_thirty_three?
  when "thirty_four?"
    sig(args)
    code_thirty_four?
  when "thirty_five?"
    sig(args)
    code_thirty_five?
  when "thirty_six?"
    sig(args)
    code_thirty_six?
  when "thirty_seven?"
    sig(args)
    code_thirty_seven?
  when "thirty_eight?"
    sig(args)
    code_thirty_eight?
  when "thirty_nine?"
    sig(args)
    code_thirty_nine?
  when "forty?"
    sig(args)
    code_forty?
  when "forty_one?"
    sig(args)
    code_forty_one?
  when "forty_two?"
    sig(args)
    code_forty_two?
  when "forty_three?"
    sig(args)
    code_forty_three?
  when "forty_four?"
    sig(args)
    code_forty_four?
  when "forty_five?"
    sig(args)
    code_forty_five?
  when "forty_six?"
    sig(args)
    code_forty_six?
  when "forty_seven?"
    sig(args)
    code_forty_seven?
  when "forty_eight?"
    sig(args)
    code_forty_eight?
  when "forty_nine?"
    sig(args)
    code_forty_nine?
  when "fifty?"
    sig(args)
    code_fifty?
  when "fifty_one?"
    sig(args)
    code_fifty_one?
  when "fifty_two?"
    sig(args)
    code_fifty_two?
  when "fifty_three?"
    sig(args)
    code_fifty_three?
  when "fifty_four?"
    sig(args)
    code_fifty_four?
  when "fifty_five?"
    sig(args)
    code_fifty_five?
  when "fifty_six?"
    sig(args)
    code_fifty_six?
  when "fifty_seven?"
    sig(args)
    code_fifty_seven?
  when "fifty_eight?"
    sig(args)
    code_fifty_eight?
  when "fifty_nine?"
    sig(args)
    code_fifty_nine?
  when "sixty?"
    sig(args)
    code_sixty?
  when "sixty_one?"
    sig(args)
    code_sixty_one?
  when "sixty_two?"
    sig(args)
    code_sixty_two?
  when "sixty_three?"
    sig(args)
    code_sixty_three?
  when "sixty_four?"
    sig(args)
    code_sixty_four?
  when "sixty_five?"
    sig(args)
    code_sixty_five?
  when "sixty_six?"
    sig(args)
    code_sixty_six?
  when "sixty_seven?"
    sig(args)
    code_sixty_seven?
  when "sixty_eight?"
    sig(args)
    code_sixty_eight?
  when "sixty_nine?"
    sig(args)
    code_sixty_nine?
  when "seventy?"
    sig(args)
    code_seventy?
  when "seventy_one?"
    sig(args)
    code_seventy_one?
  when "seventy_two?"
    sig(args)
    code_seventy_two?
  when "seventy_three?"
    sig(args)
    code_seventy_three?
  when "seventy_four?"
    sig(args)
    code_seventy_four?
  when "seventy_five?"
    sig(args)
    code_seventy_five?
  when "seventy_six?"
    sig(args)
    code_seventy_six?
  when "seventy_seven?"
    sig(args)
    code_seventy_seven?
  when "seventy_eight?"
    sig(args)
    code_seventy_eight?
  when "seventy_nine?"
    sig(args)
    code_seventy_nine?
  when "eighty?"
    sig(args)
    code_eighty?
  when "eighty_one?"
    sig(args)
    code_eighty_one?
  when "eighty_two?"
    sig(args)
    code_eighty_two?
  when "eighty_three?"
    sig(args)
    code_eighty_three?
  when "eighty_four?"
    sig(args)
    code_eighty_four?
  when "eighty_five?"
    sig(args)
    code_eighty_five?
  when "eighty_six?"
    sig(args)
    code_eighty_six?
  when "eighty_seven?"
    sig(args)
    code_eighty_seven?
  when "eighty_eight?"
    sig(args)
    code_eighty_eight?
  when "eighty_nine?"
    sig(args)
    code_eighty_nine?
  when "ninety?"
    sig(args)
    code_ninety?
  when "ninety_one?"
    sig(args)
    code_ninety_one?
  when "ninety_two?"
    sig(args)
    code_ninety_two?
  when "ninety_three?"
    sig(args)
    code_ninety_three?
  when "ninety_four?"
    sig(args)
    code_ninety_four?
  when "ninety_five?"
    sig(args)
    code_ninety_five?
  when "ninety_six?"
    sig(args)
    code_ninety_six?
  when "ninety_seven?"
    sig(args)
    code_ninety_seven?
  when "ninety_eight?"
    sig(args)
    code_ninety_eight?
  when "ninety_nine?"
    sig(args)
    code_ninety_nine?
  when "one_hundred?"
    sig(args)
    code_one_hundred?
  else
    super
  end
end

#code_absObject



413
414
415
# File 'lib/code/object/decimal.rb', line 413

def code_abs
  Decimal.new(raw.abs)
end

#code_any?Boolean

Returns:



561
562
563
# File 'lib/code/object/decimal.rb', line 561

def code_any?
  Boolean.new(raw.positive?)
end

#code_bitwise_and(other) ⇒ Object



417
418
419
420
421
# File 'lib/code/object/decimal.rb', line 417

def code_bitwise_and(other)
  code_other = other.to_code

  Integer.new(raw.to_i & code_other.raw.to_i)
end

#code_bitwise_or(other) ⇒ Object



423
424
425
426
427
# File 'lib/code/object/decimal.rb', line 423

def code_bitwise_or(other)
  code_other = other.to_code

  Integer.new(raw.to_i | code_other.raw.to_i)
end

#code_bitwise_xor(other) ⇒ Object



429
430
431
432
433
# File 'lib/code/object/decimal.rb', line 429

def code_bitwise_xor(other)
  code_other = other.to_code

  Integer.new(raw.to_i ^ code_other.raw.to_i)
end

#code_ceil(n = nil) ⇒ Object



435
436
437
438
439
440
# File 'lib/code/object/decimal.rb', line 435

def code_ceil(n = nil)
  code_n = n.to_code
  code_n = Integer.new(0) if code_n.nothing?

  Decimal.new(raw.ceil(code_n.raw))
end

#code_compare(other) ⇒ Object



442
443
444
445
446
# File 'lib/code/object/decimal.rb', line 442

def code_compare(other)
  code_other = other.to_code

  Integer.new(raw <=> code_other.raw)
end

#code_division(other) ⇒ Object



448
449
450
451
452
# File 'lib/code/object/decimal.rb', line 448

def code_division(other)
  code_other = other.to_code

  Decimal.new(raw / code_other.raw)
end

#code_eight?Boolean

Returns:



605
606
607
# File 'lib/code/object/decimal.rb', line 605

def code_eight?
  Boolean.new(raw == 8)
end

#code_eighteen?Boolean

Returns:



645
646
647
# File 'lib/code/object/decimal.rb', line 645

def code_eighteen?
  Boolean.new(raw == 18)
end

#code_eighty?Boolean

Returns:



893
894
895
# File 'lib/code/object/decimal.rb', line 893

def code_eighty?
  Boolean.new(raw == 80)
end

#code_eighty_eight?Boolean

Returns:



925
926
927
# File 'lib/code/object/decimal.rb', line 925

def code_eighty_eight?
  Boolean.new(raw == 88)
end

#code_eighty_five?Boolean

Returns:



913
914
915
# File 'lib/code/object/decimal.rb', line 913

def code_eighty_five?
  Boolean.new(raw == 85)
end

#code_eighty_four?Boolean

Returns:



909
910
911
# File 'lib/code/object/decimal.rb', line 909

def code_eighty_four?
  Boolean.new(raw == 84)
end

#code_eighty_nine?Boolean

Returns:



929
930
931
# File 'lib/code/object/decimal.rb', line 929

def code_eighty_nine?
  Boolean.new(raw == 89)
end

#code_eighty_one?Boolean

Returns:



897
898
899
# File 'lib/code/object/decimal.rb', line 897

def code_eighty_one?
  Boolean.new(raw == 81)
end

#code_eighty_seven?Boolean

Returns:



921
922
923
# File 'lib/code/object/decimal.rb', line 921

def code_eighty_seven?
  Boolean.new(raw == 87)
end

#code_eighty_six?Boolean

Returns:



917
918
919
# File 'lib/code/object/decimal.rb', line 917

def code_eighty_six?
  Boolean.new(raw == 86)
end

#code_eighty_three?Boolean

Returns:



905
906
907
# File 'lib/code/object/decimal.rb', line 905

def code_eighty_three?
  Boolean.new(raw == 83)
end

#code_eighty_two?Boolean

Returns:



901
902
903
# File 'lib/code/object/decimal.rb', line 901

def code_eighty_two?
  Boolean.new(raw == 82)
end

#code_eleven?Boolean

Returns:



617
618
619
# File 'lib/code/object/decimal.rb', line 617

def code_eleven?
  Boolean.new(raw == 11)
end

#code_fifteen?Boolean

Returns:



633
634
635
# File 'lib/code/object/decimal.rb', line 633

def code_fifteen?
  Boolean.new(raw == 15)
end

#code_fifty?Boolean

Returns:



773
774
775
# File 'lib/code/object/decimal.rb', line 773

def code_fifty?
  Boolean.new(raw == 50)
end

#code_fifty_eight?Boolean

Returns:



805
806
807
# File 'lib/code/object/decimal.rb', line 805

def code_fifty_eight?
  Boolean.new(raw == 58)
end

#code_fifty_five?Boolean

Returns:



793
794
795
# File 'lib/code/object/decimal.rb', line 793

def code_fifty_five?
  Boolean.new(raw == 55)
end

#code_fifty_four?Boolean

Returns:



789
790
791
# File 'lib/code/object/decimal.rb', line 789

def code_fifty_four?
  Boolean.new(raw == 54)
end

#code_fifty_nine?Boolean

Returns:



809
810
811
# File 'lib/code/object/decimal.rb', line 809

def code_fifty_nine?
  Boolean.new(raw == 59)
end

#code_fifty_one?Boolean

Returns:



777
778
779
# File 'lib/code/object/decimal.rb', line 777

def code_fifty_one?
  Boolean.new(raw == 51)
end

#code_fifty_seven?Boolean

Returns:



801
802
803
# File 'lib/code/object/decimal.rb', line 801

def code_fifty_seven?
  Boolean.new(raw == 57)
end

#code_fifty_six?Boolean

Returns:



797
798
799
# File 'lib/code/object/decimal.rb', line 797

def code_fifty_six?
  Boolean.new(raw == 56)
end

#code_fifty_three?Boolean

Returns:



785
786
787
# File 'lib/code/object/decimal.rb', line 785

def code_fifty_three?
  Boolean.new(raw == 53)
end

#code_fifty_two?Boolean

Returns:



781
782
783
# File 'lib/code/object/decimal.rb', line 781

def code_fifty_two?
  Boolean.new(raw == 52)
end

#code_five?Boolean

Returns:



593
594
595
# File 'lib/code/object/decimal.rb', line 593

def code_five?
  Boolean.new(raw == 5)
end

#code_floor(n = nil) ⇒ Object



454
455
456
457
458
459
# File 'lib/code/object/decimal.rb', line 454

def code_floor(n = nil)
  code_n = n.to_code
  code_n = Integer.new(0) if code_n.nothing?

  Decimal.new(raw.floor(code_n.raw))
end

#code_forty?Boolean

Returns:



733
734
735
# File 'lib/code/object/decimal.rb', line 733

def code_forty?
  Boolean.new(raw == 40)
end

#code_forty_eight?Boolean

Returns:



765
766
767
# File 'lib/code/object/decimal.rb', line 765

def code_forty_eight?
  Boolean.new(raw == 48)
end

#code_forty_five?Boolean

Returns:



753
754
755
# File 'lib/code/object/decimal.rb', line 753

def code_forty_five?
  Boolean.new(raw == 45)
end

#code_forty_four?Boolean

Returns:



749
750
751
# File 'lib/code/object/decimal.rb', line 749

def code_forty_four?
  Boolean.new(raw == 44)
end

#code_forty_nine?Boolean

Returns:



769
770
771
# File 'lib/code/object/decimal.rb', line 769

def code_forty_nine?
  Boolean.new(raw == 49)
end

#code_forty_one?Boolean

Returns:



737
738
739
# File 'lib/code/object/decimal.rb', line 737

def code_forty_one?
  Boolean.new(raw == 41)
end

#code_forty_seven?Boolean

Returns:



761
762
763
# File 'lib/code/object/decimal.rb', line 761

def code_forty_seven?
  Boolean.new(raw == 47)
end

#code_forty_six?Boolean

Returns:



757
758
759
# File 'lib/code/object/decimal.rb', line 757

def code_forty_six?
  Boolean.new(raw == 46)
end

#code_forty_three?Boolean

Returns:



745
746
747
# File 'lib/code/object/decimal.rb', line 745

def code_forty_three?
  Boolean.new(raw == 43)
end

#code_forty_two?Boolean

Returns:



741
742
743
# File 'lib/code/object/decimal.rb', line 741

def code_forty_two?
  Boolean.new(raw == 42)
end

#code_four?Boolean

Returns:



589
590
591
# File 'lib/code/object/decimal.rb', line 589

def code_four?
  Boolean.new(raw == 4)
end

#code_fourteen?Boolean

Returns:



629
630
631
# File 'lib/code/object/decimal.rb', line 629

def code_fourteen?
  Boolean.new(raw == 14)
end

#code_inferior(other) ⇒ Object



461
462
463
464
465
# File 'lib/code/object/decimal.rb', line 461

def code_inferior(other)
  code_other = other.to_code

  Boolean.new(raw < code_other.raw)
end

#code_inferior_or_equal(other) ⇒ Object



467
468
469
470
471
# File 'lib/code/object/decimal.rb', line 467

def code_inferior_or_equal(other)
  code_other = other.to_code

  Boolean.new(raw <= code_other.raw)
end

#code_left_shift(other) ⇒ Object



473
474
475
476
477
# File 'lib/code/object/decimal.rb', line 473

def code_left_shift(other)
  code_other = other.to_code

  Integer.new(raw.to_i << code_other.raw.to_i)
end

#code_many?Boolean

Returns:



557
558
559
# File 'lib/code/object/decimal.rb', line 557

def code_many?
  Boolean.new(raw > 1)
end

#code_minus(other) ⇒ Object



479
480
481
482
483
# File 'lib/code/object/decimal.rb', line 479

def code_minus(other)
  code_other = other.to_code

  Decimal.new(raw - code_other.raw)
end

#code_modulo(other) ⇒ Object



485
486
487
488
489
# File 'lib/code/object/decimal.rb', line 485

def code_modulo(other)
  code_other = other.to_code

  Decimal.new(raw % code_other.raw)
end

#code_multiplication(other) ⇒ Object



491
492
493
494
495
# File 'lib/code/object/decimal.rb', line 491

def code_multiplication(other)
  code_other = other.to_code

  Decimal.new(raw * code_other.raw)
end

#code_negative?Boolean

Returns:



569
570
571
# File 'lib/code/object/decimal.rb', line 569

def code_negative?
  Boolean.new(raw.negative?)
end

#code_nine?Boolean

Returns:



609
610
611
# File 'lib/code/object/decimal.rb', line 609

def code_nine?
  Boolean.new(raw == 9)
end

#code_nineteen?Boolean

Returns:



649
650
651
# File 'lib/code/object/decimal.rb', line 649

def code_nineteen?
  Boolean.new(raw == 19)
end

#code_ninety?Boolean

Returns:



933
934
935
# File 'lib/code/object/decimal.rb', line 933

def code_ninety?
  Boolean.new(raw == 90)
end

#code_ninety_eight?Boolean

Returns:



965
966
967
# File 'lib/code/object/decimal.rb', line 965

def code_ninety_eight?
  Boolean.new(raw == 98)
end

#code_ninety_five?Boolean

Returns:



953
954
955
# File 'lib/code/object/decimal.rb', line 953

def code_ninety_five?
  Boolean.new(raw == 95)
end

#code_ninety_four?Boolean

Returns:



949
950
951
# File 'lib/code/object/decimal.rb', line 949

def code_ninety_four?
  Boolean.new(raw == 94)
end

#code_ninety_nine?Boolean

Returns:



969
970
971
# File 'lib/code/object/decimal.rb', line 969

def code_ninety_nine?
  Boolean.new(raw == 99)
end

#code_ninety_one?Boolean

Returns:



937
938
939
# File 'lib/code/object/decimal.rb', line 937

def code_ninety_one?
  Boolean.new(raw == 91)
end

#code_ninety_seven?Boolean

Returns:



961
962
963
# File 'lib/code/object/decimal.rb', line 961

def code_ninety_seven?
  Boolean.new(raw == 97)
end

#code_ninety_six?Boolean

Returns:



957
958
959
# File 'lib/code/object/decimal.rb', line 957

def code_ninety_six?
  Boolean.new(raw == 96)
end

#code_ninety_three?Boolean

Returns:



945
946
947
# File 'lib/code/object/decimal.rb', line 945

def code_ninety_three?
  Boolean.new(raw == 93)
end

#code_ninety_two?Boolean

Returns:



941
942
943
# File 'lib/code/object/decimal.rb', line 941

def code_ninety_two?
  Boolean.new(raw == 92)
end

#code_one?Boolean

Returns:



577
578
579
# File 'lib/code/object/decimal.rb', line 577

def code_one?
  Boolean.new(raw == 1)
end

#code_one_hundred?Boolean

Returns:



973
974
975
# File 'lib/code/object/decimal.rb', line 973

def code_one_hundred?
  Boolean.new(raw == 100)
end

#code_plus(other) ⇒ Object



497
498
499
500
501
502
503
504
505
# File 'lib/code/object/decimal.rb', line 497

def code_plus(other)
  code_other = other.to_code

  if code_other.is_an?(Integer) || other.is_a?(Decimal)
    Decimal.new(raw + code_other.raw)
  else
    String.new(to_s + code_other.to_s)
  end
end

#code_positive?Boolean

Returns:



565
566
567
# File 'lib/code/object/decimal.rb', line 565

def code_positive?
  Boolean.new(raw.positive?)
end

#code_power(other) ⇒ Object



507
508
509
510
511
# File 'lib/code/object/decimal.rb', line 507

def code_power(other)
  code_other = other.to_code

  Decimal.new(raw**code_other.raw)
end

#code_right_shift(other) ⇒ Object



513
514
515
516
517
# File 'lib/code/object/decimal.rb', line 513

def code_right_shift(other)
  code_other = other.to_code

  Integer.new(raw.to_i >> code_other.raw.to_i)
end

#code_round(n = nil) ⇒ Object



519
520
521
522
523
524
# File 'lib/code/object/decimal.rb', line 519

def code_round(n = nil)
  code_n = n.to_code
  code_n = Integer.new(0) if code_n.nothing?

  Decimal.new(raw.round(code_n.raw))
end

#code_seven?Boolean

Returns:



601
602
603
# File 'lib/code/object/decimal.rb', line 601

def code_seven?
  Boolean.new(raw == 7)
end

#code_seventeen?Boolean

Returns:



641
642
643
# File 'lib/code/object/decimal.rb', line 641

def code_seventeen?
  Boolean.new(raw == 17)
end

#code_seventy?Boolean

Returns:



853
854
855
# File 'lib/code/object/decimal.rb', line 853

def code_seventy?
  Boolean.new(raw == 70)
end

#code_seventy_eight?Boolean

Returns:



885
886
887
# File 'lib/code/object/decimal.rb', line 885

def code_seventy_eight?
  Boolean.new(raw == 78)
end

#code_seventy_five?Boolean

Returns:



873
874
875
# File 'lib/code/object/decimal.rb', line 873

def code_seventy_five?
  Boolean.new(raw == 75)
end

#code_seventy_four?Boolean

Returns:



869
870
871
# File 'lib/code/object/decimal.rb', line 869

def code_seventy_four?
  Boolean.new(raw == 74)
end

#code_seventy_nine?Boolean

Returns:



889
890
891
# File 'lib/code/object/decimal.rb', line 889

def code_seventy_nine?
  Boolean.new(raw == 79)
end

#code_seventy_one?Boolean

Returns:



857
858
859
# File 'lib/code/object/decimal.rb', line 857

def code_seventy_one?
  Boolean.new(raw == 71)
end

#code_seventy_seven?Boolean

Returns:



881
882
883
# File 'lib/code/object/decimal.rb', line 881

def code_seventy_seven?
  Boolean.new(raw == 77)
end

#code_seventy_six?Boolean

Returns:



877
878
879
# File 'lib/code/object/decimal.rb', line 877

def code_seventy_six?
  Boolean.new(raw == 76)
end

#code_seventy_three?Boolean

Returns:



865
866
867
# File 'lib/code/object/decimal.rb', line 865

def code_seventy_three?
  Boolean.new(raw == 73)
end

#code_seventy_two?Boolean

Returns:



861
862
863
# File 'lib/code/object/decimal.rb', line 861

def code_seventy_two?
  Boolean.new(raw == 72)
end

#code_six?Boolean

Returns:



597
598
599
# File 'lib/code/object/decimal.rb', line 597

def code_six?
  Boolean.new(raw == 6)
end

#code_sixteen?Boolean

Returns:



637
638
639
# File 'lib/code/object/decimal.rb', line 637

def code_sixteen?
  Boolean.new(raw == 16)
end

#code_sixty?Boolean

Returns:



813
814
815
# File 'lib/code/object/decimal.rb', line 813

def code_sixty?
  Boolean.new(raw == 60)
end

#code_sixty_eight?Boolean

Returns:



845
846
847
# File 'lib/code/object/decimal.rb', line 845

def code_sixty_eight?
  Boolean.new(raw == 68)
end

#code_sixty_five?Boolean

Returns:



833
834
835
# File 'lib/code/object/decimal.rb', line 833

def code_sixty_five?
  Boolean.new(raw == 65)
end

#code_sixty_four?Boolean

Returns:



829
830
831
# File 'lib/code/object/decimal.rb', line 829

def code_sixty_four?
  Boolean.new(raw == 64)
end

#code_sixty_nine?Boolean

Returns:



849
850
851
# File 'lib/code/object/decimal.rb', line 849

def code_sixty_nine?
  Boolean.new(raw == 69)
end

#code_sixty_one?Boolean

Returns:



817
818
819
# File 'lib/code/object/decimal.rb', line 817

def code_sixty_one?
  Boolean.new(raw == 61)
end

#code_sixty_seven?Boolean

Returns:



841
842
843
# File 'lib/code/object/decimal.rb', line 841

def code_sixty_seven?
  Boolean.new(raw == 67)
end

#code_sixty_six?Boolean

Returns:



837
838
839
# File 'lib/code/object/decimal.rb', line 837

def code_sixty_six?
  Boolean.new(raw == 66)
end

#code_sixty_three?Boolean

Returns:



825
826
827
# File 'lib/code/object/decimal.rb', line 825

def code_sixty_three?
  Boolean.new(raw == 63)
end

#code_sixty_two?Boolean

Returns:



821
822
823
# File 'lib/code/object/decimal.rb', line 821

def code_sixty_two?
  Boolean.new(raw == 62)
end

#code_sqrtObject



526
527
528
# File 'lib/code/object/decimal.rb', line 526

def code_sqrt
  Decimal.new(Math.sqrt(raw).to_s)
end

#code_superior(other) ⇒ Object



530
531
532
533
534
# File 'lib/code/object/decimal.rb', line 530

def code_superior(other)
  code_other = other.to_code

  Boolean.new(raw > code_other.raw)
end

#code_superior_or_equal(other) ⇒ Object



536
537
538
539
540
# File 'lib/code/object/decimal.rb', line 536

def code_superior_or_equal(other)
  code_other = other.to_code

  Boolean.new(raw >= code_other.raw)
end

#code_ten?Boolean

Returns:



613
614
615
# File 'lib/code/object/decimal.rb', line 613

def code_ten?
  Boolean.new(raw == 10)
end

#code_thirteen?Boolean

Returns:



625
626
627
# File 'lib/code/object/decimal.rb', line 625

def code_thirteen?
  Boolean.new(raw == 13)
end

#code_thirty?Boolean

Returns:



693
694
695
# File 'lib/code/object/decimal.rb', line 693

def code_thirty?
  Boolean.new(raw == 30)
end

#code_thirty_eight?Boolean

Returns:



725
726
727
# File 'lib/code/object/decimal.rb', line 725

def code_thirty_eight?
  Boolean.new(raw == 38)
end

#code_thirty_five?Boolean

Returns:



713
714
715
# File 'lib/code/object/decimal.rb', line 713

def code_thirty_five?
  Boolean.new(raw == 35)
end

#code_thirty_four?Boolean

Returns:



709
710
711
# File 'lib/code/object/decimal.rb', line 709

def code_thirty_four?
  Boolean.new(raw == 34)
end

#code_thirty_nine?Boolean

Returns:



729
730
731
# File 'lib/code/object/decimal.rb', line 729

def code_thirty_nine?
  Boolean.new(raw == 39)
end

#code_thirty_one?Boolean

Returns:



697
698
699
# File 'lib/code/object/decimal.rb', line 697

def code_thirty_one?
  Boolean.new(raw == 31)
end

#code_thirty_seven?Boolean

Returns:



721
722
723
# File 'lib/code/object/decimal.rb', line 721

def code_thirty_seven?
  Boolean.new(raw == 37)
end

#code_thirty_six?Boolean

Returns:



717
718
719
# File 'lib/code/object/decimal.rb', line 717

def code_thirty_six?
  Boolean.new(raw == 36)
end

#code_thirty_three?Boolean

Returns:



705
706
707
# File 'lib/code/object/decimal.rb', line 705

def code_thirty_three?
  Boolean.new(raw == 33)
end

#code_thirty_two?Boolean

Returns:



701
702
703
# File 'lib/code/object/decimal.rb', line 701

def code_thirty_two?
  Boolean.new(raw == 32)
end

#code_three?Boolean

Returns:



585
586
587
# File 'lib/code/object/decimal.rb', line 585

def code_three?
  Boolean.new(raw == 3)
end

#code_to_stringObject



542
543
544
# File 'lib/code/object/decimal.rb', line 542

def code_to_string
  String.new(raw.to_s("F"))
end

#code_truncate(n = nil) ⇒ Object



546
547
548
549
550
551
# File 'lib/code/object/decimal.rb', line 546

def code_truncate(n = nil)
  code_n = n.to_code
  code_n = Integer.new(0) if code_n.nothing?

  Decimal.new(raw.truncate(code_n.raw))
end

#code_twelve?Boolean

Returns:



621
622
623
# File 'lib/code/object/decimal.rb', line 621

def code_twelve?
  Boolean.new(raw == 12)
end

#code_twenty?Boolean

Returns:



653
654
655
# File 'lib/code/object/decimal.rb', line 653

def code_twenty?
  Boolean.new(raw == 20)
end

#code_twenty_eight?Boolean

Returns:



685
686
687
# File 'lib/code/object/decimal.rb', line 685

def code_twenty_eight?
  Boolean.new(raw == 28)
end

#code_twenty_five?Boolean

Returns:



673
674
675
# File 'lib/code/object/decimal.rb', line 673

def code_twenty_five?
  Boolean.new(raw == 25)
end

#code_twenty_four?Boolean

Returns:



669
670
671
# File 'lib/code/object/decimal.rb', line 669

def code_twenty_four?
  Boolean.new(raw == 24)
end

#code_twenty_nine?Boolean

Returns:



689
690
691
# File 'lib/code/object/decimal.rb', line 689

def code_twenty_nine?
  Boolean.new(raw == 29)
end

#code_twenty_one?Boolean

Returns:



657
658
659
# File 'lib/code/object/decimal.rb', line 657

def code_twenty_one?
  Boolean.new(raw == 21)
end

#code_twenty_seven?Boolean

Returns:



681
682
683
# File 'lib/code/object/decimal.rb', line 681

def code_twenty_seven?
  Boolean.new(raw == 27)
end

#code_twenty_six?Boolean

Returns:



677
678
679
# File 'lib/code/object/decimal.rb', line 677

def code_twenty_six?
  Boolean.new(raw == 26)
end

#code_twenty_three?Boolean

Returns:



665
666
667
# File 'lib/code/object/decimal.rb', line 665

def code_twenty_three?
  Boolean.new(raw == 23)
end

#code_twenty_two?Boolean

Returns:



661
662
663
# File 'lib/code/object/decimal.rb', line 661

def code_twenty_two?
  Boolean.new(raw == 22)
end

#code_two?Boolean

Returns:



581
582
583
# File 'lib/code/object/decimal.rb', line 581

def code_two?
  Boolean.new(raw == 2)
end

#code_unary_minusObject



553
554
555
# File 'lib/code/object/decimal.rb', line 553

def code_unary_minus
  Decimal.new(-raw)
end

#code_zero?Boolean

Returns:



573
574
575
# File 'lib/code/object/decimal.rb', line 573

def code_zero?
  Boolean.new(raw.zero?)
end