Class: Code::Object::Integer

Inherits:
Number show all
Defined in:
lib/code/object/integer.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_dictionary, #code_to_duration, #code_to_json, #code_to_list, #code_to_nothing, #code_to_parameter, #code_to_range, #code_to_string, #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) ⇒ Integer

Returns a new instance of Integer.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/code/object/integer.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)).to_i
      else
        args.first.to_s.to_i
      end
    else
      0
    end
rescue FloatDomainError
  self.raw = 0
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
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
# File 'lib/code/object/integer.rb', line 21

def call(**args)
  code_operator = args.fetch(:operator, nil).to_code
  code_arguments = args.fetch(:arguments, []).to_code
  globals = multi_fetch(args, *GLOBALS)
  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 | String }
    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) : code_self
  when "-", "minus", "unary_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 "day", "days"
    sig(args)
    code_days
  when "decrement!"
    sig(args) { Integer.maybe }
    code_decrement!(code_value)
  when "decrement"
    sig(args) { Integer.maybe }
    code_decrement(code_value)
  when "even?"
    sig(args)
    code_even?
  when "floor"
    sig(args) { Integer.maybe }
    code_floor(code_value)
  when "hour", "hours"
    sig(args)
    code_hours
  when "increment!"
    sig(args) { Integer.maybe }
    code_increment!(code_value)
  when "increment"
    sig(args) { Integer.maybe }
    code_increment(code_value)
  when "odd?"
    sig(args)
    code_odd?
  when "round"
    sig(args) { Integer.maybe }
    code_round(code_value)
  when "sqrt"
    sig(args)
    code_sqrt
  when "times"
    sig(args) { Function }
    code_times(code_value, **globals)
  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



441
442
443
# File 'lib/code/object/integer.rb', line 441

def code_abs
  Decimal.new(raw.abs)
end

#code_any?Boolean

Returns:



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

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

#code_bitwise_and(other) ⇒ Object



445
446
447
448
# File 'lib/code/object/integer.rb', line 445

def code_bitwise_and(other)
  code_other = other.to_code
  Integer.new(raw & code_other.raw.to_i)
end

#code_bitwise_or(other) ⇒ Object



450
451
452
453
# File 'lib/code/object/integer.rb', line 450

def code_bitwise_or(other)
  code_other = other.to_code
  Integer.new(raw | code_other.raw.to_i)
end

#code_bitwise_xor(other) ⇒ Object



455
456
457
458
# File 'lib/code/object/integer.rb', line 455

def code_bitwise_xor(other)
  code_other = other.to_code
  Integer.new(raw ^ code_other.raw.to_i)
end

#code_ceil(n = nil) ⇒ Object



460
461
462
463
464
# File 'lib/code/object/integer.rb', line 460

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

#code_compare(other) ⇒ Object



466
467
468
469
# File 'lib/code/object/integer.rb', line 466

def code_compare(other)
  code_other = other.to_code
  Integer.new(raw <=> code_other.raw)
end

#code_daysObject



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

def code_days
  Duration.new(raw.days)
end

#code_decrement(n = nil) ⇒ Object



478
479
480
481
482
# File 'lib/code/object/integer.rb', line 478

def code_decrement(n = nil)
  code_n = n.to_code
  code_n = Integer.new(1) if code_n.nothing?
  Integer.new(raw - code_n.raw)
end

#code_decrement!(n = nil) ⇒ Object



471
472
473
474
475
476
# File 'lib/code/object/integer.rb', line 471

def code_decrement!(n = nil)
  code_n = n.to_code
  code_n = Integer.new(1) if code_n.nothing?
  @raw -= code_n.raw
  self
end

#code_division(other) ⇒ Object



484
485
486
487
# File 'lib/code/object/integer.rb', line 484

def code_division(other)
  code_other = other.to_code
  Decimal.new(BigDecimal(raw) / code_other.raw)
end

#code_eight?Boolean

Returns:



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

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

#code_eighteen?Boolean

Returns:



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

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

#code_eighty?Boolean

Returns:



989
990
991
# File 'lib/code/object/integer.rb', line 989

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

#code_eighty_eight?Boolean

Returns:



1021
1022
1023
# File 'lib/code/object/integer.rb', line 1021

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

#code_eighty_five?Boolean

Returns:



1009
1010
1011
# File 'lib/code/object/integer.rb', line 1009

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

#code_eighty_four?Boolean

Returns:



1005
1006
1007
# File 'lib/code/object/integer.rb', line 1005

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

#code_eighty_nine?Boolean

Returns:



1025
1026
1027
# File 'lib/code/object/integer.rb', line 1025

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

#code_eighty_one?Boolean

Returns:



993
994
995
# File 'lib/code/object/integer.rb', line 993

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

#code_eighty_seven?Boolean

Returns:



1017
1018
1019
# File 'lib/code/object/integer.rb', line 1017

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

#code_eighty_six?Boolean

Returns:



1013
1014
1015
# File 'lib/code/object/integer.rb', line 1013

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

#code_eighty_three?Boolean

Returns:



1001
1002
1003
# File 'lib/code/object/integer.rb', line 1001

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

#code_eighty_two?Boolean

Returns:



997
998
999
# File 'lib/code/object/integer.rb', line 997

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

#code_eleven?Boolean

Returns:



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

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

#code_even?Boolean

Returns:



489
490
491
# File 'lib/code/object/integer.rb', line 489

def code_even?
  Boolean.new(raw.even?)
end

#code_fifteen?Boolean

Returns:



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

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

#code_fifty?Boolean

Returns:



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

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

#code_fifty_eight?Boolean

Returns:



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

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

#code_fifty_five?Boolean

Returns:



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

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

#code_fifty_four?Boolean

Returns:



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

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

#code_fifty_nine?Boolean

Returns:



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

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

#code_fifty_one?Boolean

Returns:



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

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

#code_fifty_seven?Boolean

Returns:



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

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

#code_fifty_six?Boolean

Returns:



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

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

#code_fifty_three?Boolean

Returns:



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

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

#code_fifty_two?Boolean

Returns:



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

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

#code_five?Boolean

Returns:



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

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

#code_floor(n = nil) ⇒ Object



493
494
495
496
497
# File 'lib/code/object/integer.rb', line 493

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

#code_forty?Boolean

Returns:



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

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

#code_forty_eight?Boolean

Returns:



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

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

#code_forty_five?Boolean

Returns:



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

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

#code_forty_four?Boolean

Returns:



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

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

#code_forty_nine?Boolean

Returns:



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

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

#code_forty_one?Boolean

Returns:



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

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

#code_forty_seven?Boolean

Returns:



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

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

#code_forty_six?Boolean

Returns:



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

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

#code_forty_three?Boolean

Returns:



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

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

#code_forty_two?Boolean

Returns:



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

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

#code_four?Boolean

Returns:



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

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

#code_fourteen?Boolean

Returns:



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

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

#code_hoursObject



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

def code_hours
  Duration.new(raw.hours)
end

#code_increment(n = nil) ⇒ Object



506
507
508
509
510
# File 'lib/code/object/integer.rb', line 506

def code_increment(n = nil)
  code_n = n.to_code
  code_n = Integer.new(1) if code_n.nothing?
  Integer.new(raw + code_n.raw)
end

#code_increment!(n = nil) ⇒ Object



499
500
501
502
503
504
# File 'lib/code/object/integer.rb', line 499

def code_increment!(n = nil)
  code_n = n.to_code
  code_n = Integer.new(1) if code_n.nothing?
  @raw += code_n.raw
  self
end

#code_inferior(other) ⇒ Object



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

def code_inferior(other)
  code_other = other.to_code
  Boolean.new(raw < code_other.raw)
end

#code_inferior_or_equal(other) ⇒ Object



517
518
519
520
# File 'lib/code/object/integer.rb', line 517

def code_inferior_or_equal(other)
  code_other = other.to_code
  Boolean.new(raw <= code_other.raw)
end

#code_left_shift(other) ⇒ Object



522
523
524
525
# File 'lib/code/object/integer.rb', line 522

def code_left_shift(other)
  code_other = other.to_code
  Integer.new(raw << code_other.raw.to_i)
end

#code_many?Boolean

Returns:



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

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

#code_minus(other) ⇒ Object



527
528
529
530
531
532
533
534
535
# File 'lib/code/object/integer.rb', line 527

def code_minus(other)
  code_other = other.to_code

  if code_other.is_a?(Integer)
    Integer.new(raw - code_other.raw)
  else
    Decimal.new(raw - code_other.raw)
  end
end

#code_modulo(other) ⇒ Object



537
538
539
540
541
542
543
544
545
# File 'lib/code/object/integer.rb', line 537

def code_modulo(other)
  code_other = other.to_code

  if code_other.is_a?(Integer)
    Integer.new(raw % code_other.raw)
  else
    Decimal.new(raw % code_other.raw)
  end
end

#code_multiplication(other) ⇒ Object



547
548
549
550
551
552
553
554
555
556
557
# File 'lib/code/object/integer.rb', line 547

def code_multiplication(other)
  code_other = other.to_code

  if code_other.is_a?(Integer)
    Integer.new(raw * code_other.raw)
  elsif code_other.is_a?(Decimal)
    Decimal.new(raw * code_other.raw)
  else
    String.new(code_other.raw * raw)
  end
end

#code_negative?Boolean

Returns:



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

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

#code_nine?Boolean

Returns:



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

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

#code_nineteen?Boolean

Returns:



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

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

#code_ninety?Boolean

Returns:



1029
1030
1031
# File 'lib/code/object/integer.rb', line 1029

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

#code_ninety_eight?Boolean

Returns:



1061
1062
1063
# File 'lib/code/object/integer.rb', line 1061

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

#code_ninety_five?Boolean

Returns:



1049
1050
1051
# File 'lib/code/object/integer.rb', line 1049

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

#code_ninety_four?Boolean

Returns:



1045
1046
1047
# File 'lib/code/object/integer.rb', line 1045

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

#code_ninety_nine?Boolean

Returns:



1065
1066
1067
# File 'lib/code/object/integer.rb', line 1065

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

#code_ninety_one?Boolean

Returns:



1033
1034
1035
# File 'lib/code/object/integer.rb', line 1033

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

#code_ninety_seven?Boolean

Returns:



1057
1058
1059
# File 'lib/code/object/integer.rb', line 1057

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

#code_ninety_six?Boolean

Returns:



1053
1054
1055
# File 'lib/code/object/integer.rb', line 1053

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

#code_ninety_three?Boolean

Returns:



1041
1042
1043
# File 'lib/code/object/integer.rb', line 1041

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

#code_ninety_two?Boolean

Returns:



1037
1038
1039
# File 'lib/code/object/integer.rb', line 1037

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

#code_odd?Boolean

Returns:



559
560
561
# File 'lib/code/object/integer.rb', line 559

def code_odd?
  Boolean.new(raw.odd?)
end

#code_one?Boolean

Returns:



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

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

#code_one_hundred?Boolean

Returns:



1069
1070
1071
# File 'lib/code/object/integer.rb', line 1069

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

#code_plus(other) ⇒ Object



563
564
565
566
567
568
569
570
571
572
573
# File 'lib/code/object/integer.rb', line 563

def code_plus(other)
  code_other = other.to_code

  if code_other.is_a?(Integer)
    Integer.new(raw + code_other.raw)
  elsif code_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:



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

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

#code_power(other) ⇒ Object



575
576
577
578
579
580
581
582
583
# File 'lib/code/object/integer.rb', line 575

def code_power(other)
  code_other = other.to_code

  if code_other.is_a?(Integer)
    Integer.new(raw**other.raw)
  else
    Decimal.new(raw**other.raw)
  end
end

#code_right_shift(other) ⇒ Object



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

def code_right_shift(other)
  code_other = other.to_code
  Integer.new(raw >> code_other.raw.to_i)
end

#code_round(n = nil) ⇒ Object



590
591
592
593
594
595
# File 'lib/code/object/integer.rb', line 590

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

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

#code_seven?Boolean

Returns:



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

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

#code_seventeen?Boolean

Returns:



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

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

#code_seventy?Boolean

Returns:



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

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

#code_seventy_eight?Boolean

Returns:



981
982
983
# File 'lib/code/object/integer.rb', line 981

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

#code_seventy_five?Boolean

Returns:



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

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

#code_seventy_four?Boolean

Returns:



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

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

#code_seventy_nine?Boolean

Returns:



985
986
987
# File 'lib/code/object/integer.rb', line 985

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

#code_seventy_one?Boolean

Returns:



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

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

#code_seventy_seven?Boolean

Returns:



977
978
979
# File 'lib/code/object/integer.rb', line 977

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

#code_seventy_six?Boolean

Returns:



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

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

#code_seventy_three?Boolean

Returns:



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

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

#code_seventy_two?Boolean

Returns:



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

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

#code_six?Boolean

Returns:



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

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

#code_sixteen?Boolean

Returns:



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

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

#code_sixty?Boolean

Returns:



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

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

#code_sixty_eight?Boolean

Returns:



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

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

#code_sixty_five?Boolean

Returns:



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

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

#code_sixty_four?Boolean

Returns:



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

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

#code_sixty_nine?Boolean

Returns:



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

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

#code_sixty_one?Boolean

Returns:



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

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

#code_sixty_seven?Boolean

Returns:



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

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

#code_sixty_six?Boolean

Returns:



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

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

#code_sixty_three?Boolean

Returns:



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

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

#code_sixty_two?Boolean

Returns:



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

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

#code_sqrtObject



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

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

#code_superior(other) ⇒ Object



601
602
603
604
605
# File 'lib/code/object/integer.rb', line 601

def code_superior(other)
  code_other = other.to_code

  Boolean.new(raw > code_other.raw)
end

#code_superior_or_equal(other) ⇒ Object



607
608
609
610
611
# File 'lib/code/object/integer.rb', line 607

def code_superior_or_equal(other)
  code_other = other.to_code

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

#code_ten?Boolean

Returns:



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

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

#code_thirteen?Boolean

Returns:



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

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

#code_thirty?Boolean

Returns:



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

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

#code_thirty_eight?Boolean

Returns:



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

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

#code_thirty_five?Boolean

Returns:



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

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

#code_thirty_four?Boolean

Returns:



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

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

#code_thirty_nine?Boolean

Returns:



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

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

#code_thirty_one?Boolean

Returns:



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

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

#code_thirty_seven?Boolean

Returns:



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

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

#code_thirty_six?Boolean

Returns:



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

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

#code_thirty_three?Boolean

Returns:



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

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

#code_thirty_two?Boolean

Returns:



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

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

#code_three?Boolean

Returns:



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

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

#code_times(argument, **globals) ⇒ Object



621
622
623
624
625
626
627
628
629
630
631
632
# File 'lib/code/object/integer.rb', line 621

def code_times(argument, **globals)
  code_argument = argument.to_code

  raw.times do |element|
    code_argument.call(
      arguments: List.new([Integer.new(element), self]),
      **globals
    )
  end

  self
end

#code_to_decimalObject



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

def code_to_decimal
  Decimal.new(raw)
end

#code_to_integerObject



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

def code_to_integer
  Integer.new(raw)
end

#code_truncate(n = nil) ⇒ Object



634
635
636
637
638
639
# File 'lib/code/object/integer.rb', line 634

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

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

#code_twelve?Boolean

Returns:



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

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

#code_twenty?Boolean

Returns:



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

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

#code_twenty_eight?Boolean

Returns:



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

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

#code_twenty_five?Boolean

Returns:



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

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

#code_twenty_four?Boolean

Returns:



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

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

#code_twenty_nine?Boolean

Returns:



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

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

#code_twenty_one?Boolean

Returns:



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

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

#code_twenty_seven?Boolean

Returns:



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

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

#code_twenty_six?Boolean

Returns:



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

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

#code_twenty_three?Boolean

Returns:



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

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

#code_twenty_two?Boolean

Returns:



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

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

#code_two?Boolean

Returns:



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

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

#code_unary_minusObject



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

def code_unary_minus
  Integer.new(-raw)
end

#code_zero?Boolean

Returns:



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

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