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, #blank?, #code_and, #code_as_json, #code_blank?, #code_compare, #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_greater, #code_greater_or_equal, #code_inclusive_range, #code_inspect, #code_less, #code_less_or_equal, #code_methods, #code_name, #code_nothing?, #code_or, #code_presence, #code_presence_in, #code_present?, #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?, #present?, #sig, #something?, #succ, #to_code, #to_i, #to_json, #to_s, #truthy?

Constructor Details

#initialize(*args, **_kargs, &_block) ⇒ 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
# 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 "<<", "left_shift"
    sig(args) { Integer | Decimal }
    code_left_shift(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



398
399
400
# File 'lib/code/object/decimal.rb', line 398

def code_abs
  Decimal.new(raw.abs)
end

#code_any?Boolean



516
517
518
# File 'lib/code/object/decimal.rb', line 516

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

#code_bitwise_and(other) ⇒ Object



402
403
404
405
406
# File 'lib/code/object/decimal.rb', line 402

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



408
409
410
411
412
# File 'lib/code/object/decimal.rb', line 408

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



414
415
416
417
418
# File 'lib/code/object/decimal.rb', line 414

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



420
421
422
423
424
425
# File 'lib/code/object/decimal.rb', line 420

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_division(other) ⇒ Object



427
428
429
430
431
# File 'lib/code/object/decimal.rb', line 427

def code_division(other)
  code_other = other.to_code

  Decimal.new(raw / code_other.raw)
end

#code_eight?Boolean



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

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

#code_eighteen?Boolean



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

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

#code_eighty?Boolean



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

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

#code_eighty_eight?Boolean



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

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

#code_eighty_five?Boolean



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

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

#code_eighty_four?Boolean



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

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

#code_eighty_nine?Boolean



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

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

#code_eighty_one?Boolean



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

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

#code_eighty_seven?Boolean



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

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

#code_eighty_six?Boolean



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

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

#code_eighty_three?Boolean



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

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

#code_eighty_two?Boolean



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

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

#code_eleven?Boolean



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

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

#code_fifteen?Boolean



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

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

#code_fifty?Boolean



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

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

#code_fifty_eight?Boolean



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

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

#code_fifty_five?Boolean



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

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

#code_fifty_four?Boolean



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

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

#code_fifty_nine?Boolean



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

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

#code_fifty_one?Boolean



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

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

#code_fifty_seven?Boolean



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

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

#code_fifty_six?Boolean



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

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

#code_fifty_three?Boolean



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

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

#code_fifty_two?Boolean



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

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

#code_five?Boolean



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

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

#code_floor(n = nil) ⇒ Object



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

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



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

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

#code_forty_eight?Boolean



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

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

#code_forty_five?Boolean



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

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

#code_forty_four?Boolean



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

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

#code_forty_nine?Boolean



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

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

#code_forty_one?Boolean



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

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

#code_forty_seven?Boolean



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

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

#code_forty_six?Boolean



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

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

#code_forty_three?Boolean



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

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

#code_forty_two?Boolean



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

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

#code_four?Boolean



544
545
546
# File 'lib/code/object/decimal.rb', line 544

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

#code_fourteen?Boolean



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

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

#code_left_shift(other) ⇒ Object



440
441
442
443
444
# File 'lib/code/object/decimal.rb', line 440

def code_left_shift(other)
  code_other = other.to_code

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

#code_many?Boolean



512
513
514
# File 'lib/code/object/decimal.rb', line 512

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

#code_minus(other) ⇒ Object



446
447
448
449
450
# File 'lib/code/object/decimal.rb', line 446

def code_minus(other)
  code_other = other.to_code

  Decimal.new(raw - code_other.raw)
end

#code_modulo(other) ⇒ Object



452
453
454
455
456
# File 'lib/code/object/decimal.rb', line 452

def code_modulo(other)
  code_other = other.to_code

  Decimal.new(raw % code_other.raw)
end

#code_multiplication(other) ⇒ Object



458
459
460
461
462
# File 'lib/code/object/decimal.rb', line 458

def code_multiplication(other)
  code_other = other.to_code

  Decimal.new(raw * code_other.raw)
end

#code_negative?Boolean



524
525
526
# File 'lib/code/object/decimal.rb', line 524

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

#code_nine?Boolean



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

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

#code_nineteen?Boolean



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

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

#code_ninety?Boolean



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

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

#code_ninety_eight?Boolean



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

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

#code_ninety_five?Boolean



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

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

#code_ninety_four?Boolean



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

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

#code_ninety_nine?Boolean



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

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

#code_ninety_one?Boolean



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

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

#code_ninety_seven?Boolean



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

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

#code_ninety_six?Boolean



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

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

#code_ninety_three?Boolean



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

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

#code_ninety_two?Boolean



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

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

#code_one?Boolean



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

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

#code_one_hundred?Boolean



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

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

#code_plus(other) ⇒ Object



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

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



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

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

#code_power(other) ⇒ Object



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

def code_power(other)
  code_other = other.to_code

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

#code_right_shift(other) ⇒ Object



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

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



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

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



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

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

#code_seventeen?Boolean



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

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

#code_seventy?Boolean



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

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

#code_seventy_eight?Boolean



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

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

#code_seventy_five?Boolean



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

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

#code_seventy_four?Boolean



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

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

#code_seventy_nine?Boolean



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

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

#code_seventy_one?Boolean



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

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

#code_seventy_seven?Boolean



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

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

#code_seventy_six?Boolean



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

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

#code_seventy_three?Boolean



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

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

#code_seventy_two?Boolean



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

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

#code_six?Boolean



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

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

#code_sixteen?Boolean



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

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

#code_sixty?Boolean



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

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

#code_sixty_eight?Boolean



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

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

#code_sixty_five?Boolean



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

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

#code_sixty_four?Boolean



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

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

#code_sixty_nine?Boolean



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

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

#code_sixty_one?Boolean



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

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

#code_sixty_seven?Boolean



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

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

#code_sixty_six?Boolean



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

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

#code_sixty_three?Boolean



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

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

#code_sixty_two?Boolean



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

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

#code_sqrtObject



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

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

#code_ten?Boolean



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

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

#code_thirteen?Boolean



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

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

#code_thirty?Boolean



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

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

#code_thirty_eight?Boolean



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

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

#code_thirty_five?Boolean



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

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

#code_thirty_four?Boolean



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

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

#code_thirty_nine?Boolean



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

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

#code_thirty_one?Boolean



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

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

#code_thirty_seven?Boolean



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

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

#code_thirty_six?Boolean



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

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

#code_thirty_three?Boolean



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

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

#code_thirty_two?Boolean



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

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

#code_three?Boolean



540
541
542
# File 'lib/code/object/decimal.rb', line 540

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

#code_to_stringObject



497
498
499
# File 'lib/code/object/decimal.rb', line 497

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

#code_truncate(n = nil) ⇒ Object



501
502
503
504
505
506
# File 'lib/code/object/decimal.rb', line 501

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



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

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

#code_twenty?Boolean



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

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

#code_twenty_eight?Boolean



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

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

#code_twenty_five?Boolean



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

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

#code_twenty_four?Boolean



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

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

#code_twenty_nine?Boolean



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

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

#code_twenty_one?Boolean



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

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

#code_twenty_seven?Boolean



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

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

#code_twenty_six?Boolean



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

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

#code_twenty_three?Boolean



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

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

#code_twenty_two?Boolean



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

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

#code_two?Boolean



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

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

#code_unary_minusObject



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

def code_unary_minus
  Decimal.new(-raw)
end

#code_zero?Boolean



528
529
530
# File 'lib/code/object/decimal.rb', line 528

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