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, #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_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?, #present?, #sig, #something?, #succ, #to_code, #to_i, #to_json, #to_s, #truthy?

Constructor Details

#initialize(*args, **_kargs, &_block) ⇒ 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
# 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 "<<", "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 "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



426
427
428
# File 'lib/code/object/integer.rb', line 426

def code_abs
  Decimal.new(raw.abs)
end

#code_any?Boolean



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

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

#code_bitwise_and(other) ⇒ Object



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

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

#code_bitwise_or(other) ⇒ Object



435
436
437
438
# File 'lib/code/object/integer.rb', line 435

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

#code_bitwise_xor(other) ⇒ Object



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

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

#code_ceil(n = nil) ⇒ Object



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

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_daysObject



615
616
617
# File 'lib/code/object/integer.rb', line 615

def code_days
  Duration.new(raw.days)
end

#code_decrement(n = nil) ⇒ Object



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

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



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

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



464
465
466
467
# File 'lib/code/object/integer.rb', line 464

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

#code_eight?Boolean



659
660
661
# File 'lib/code/object/integer.rb', line 659

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

#code_eighteen?Boolean



699
700
701
# File 'lib/code/object/integer.rb', line 699

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

#code_eighty?Boolean



947
948
949
# File 'lib/code/object/integer.rb', line 947

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

#code_eighty_eight?Boolean



979
980
981
# File 'lib/code/object/integer.rb', line 979

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

#code_eighty_five?Boolean



967
968
969
# File 'lib/code/object/integer.rb', line 967

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

#code_eighty_four?Boolean



963
964
965
# File 'lib/code/object/integer.rb', line 963

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

#code_eighty_nine?Boolean



983
984
985
# File 'lib/code/object/integer.rb', line 983

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

#code_eighty_one?Boolean



951
952
953
# File 'lib/code/object/integer.rb', line 951

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

#code_eighty_seven?Boolean



975
976
977
# File 'lib/code/object/integer.rb', line 975

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

#code_eighty_six?Boolean



971
972
973
# File 'lib/code/object/integer.rb', line 971

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

#code_eighty_three?Boolean



959
960
961
# File 'lib/code/object/integer.rb', line 959

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

#code_eighty_two?Boolean



955
956
957
# File 'lib/code/object/integer.rb', line 955

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

#code_eleven?Boolean



671
672
673
# File 'lib/code/object/integer.rb', line 671

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

#code_even?Boolean



469
470
471
# File 'lib/code/object/integer.rb', line 469

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

#code_fifteen?Boolean



687
688
689
# File 'lib/code/object/integer.rb', line 687

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

#code_fifty?Boolean



827
828
829
# File 'lib/code/object/integer.rb', line 827

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

#code_fifty_eight?Boolean



859
860
861
# File 'lib/code/object/integer.rb', line 859

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

#code_fifty_five?Boolean



847
848
849
# File 'lib/code/object/integer.rb', line 847

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

#code_fifty_four?Boolean



843
844
845
# File 'lib/code/object/integer.rb', line 843

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

#code_fifty_nine?Boolean



863
864
865
# File 'lib/code/object/integer.rb', line 863

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

#code_fifty_one?Boolean



831
832
833
# File 'lib/code/object/integer.rb', line 831

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

#code_fifty_seven?Boolean



855
856
857
# File 'lib/code/object/integer.rb', line 855

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

#code_fifty_six?Boolean



851
852
853
# File 'lib/code/object/integer.rb', line 851

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

#code_fifty_three?Boolean



839
840
841
# File 'lib/code/object/integer.rb', line 839

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

#code_fifty_two?Boolean



835
836
837
# File 'lib/code/object/integer.rb', line 835

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

#code_five?Boolean



647
648
649
# File 'lib/code/object/integer.rb', line 647

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

#code_floor(n = nil) ⇒ Object



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

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



787
788
789
# File 'lib/code/object/integer.rb', line 787

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

#code_forty_eight?Boolean



819
820
821
# File 'lib/code/object/integer.rb', line 819

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

#code_forty_five?Boolean



807
808
809
# File 'lib/code/object/integer.rb', line 807

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

#code_forty_four?Boolean



803
804
805
# File 'lib/code/object/integer.rb', line 803

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

#code_forty_nine?Boolean



823
824
825
# File 'lib/code/object/integer.rb', line 823

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

#code_forty_one?Boolean



791
792
793
# File 'lib/code/object/integer.rb', line 791

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

#code_forty_seven?Boolean



815
816
817
# File 'lib/code/object/integer.rb', line 815

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

#code_forty_six?Boolean



811
812
813
# File 'lib/code/object/integer.rb', line 811

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

#code_forty_three?Boolean



799
800
801
# File 'lib/code/object/integer.rb', line 799

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

#code_forty_two?Boolean



795
796
797
# File 'lib/code/object/integer.rb', line 795

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

#code_four?Boolean



643
644
645
# File 'lib/code/object/integer.rb', line 643

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

#code_fourteen?Boolean



683
684
685
# File 'lib/code/object/integer.rb', line 683

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

#code_hoursObject



611
612
613
# File 'lib/code/object/integer.rb', line 611

def code_hours
  Duration.new(raw.hours)
end

#code_increment(n = nil) ⇒ Object



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

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



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

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



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

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

#code_many?Boolean



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

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

#code_minus(other) ⇒ Object



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

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



507
508
509
510
511
512
513
514
515
# File 'lib/code/object/integer.rb', line 507

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



517
518
519
520
521
522
523
524
525
526
527
# File 'lib/code/object/integer.rb', line 517

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



623
624
625
# File 'lib/code/object/integer.rb', line 623

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

#code_nine?Boolean



663
664
665
# File 'lib/code/object/integer.rb', line 663

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

#code_nineteen?Boolean



703
704
705
# File 'lib/code/object/integer.rb', line 703

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

#code_ninety?Boolean



987
988
989
# File 'lib/code/object/integer.rb', line 987

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

#code_ninety_eight?Boolean



1019
1020
1021
# File 'lib/code/object/integer.rb', line 1019

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

#code_ninety_five?Boolean



1007
1008
1009
# File 'lib/code/object/integer.rb', line 1007

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

#code_ninety_four?Boolean



1003
1004
1005
# File 'lib/code/object/integer.rb', line 1003

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

#code_ninety_nine?Boolean



1023
1024
1025
# File 'lib/code/object/integer.rb', line 1023

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

#code_ninety_one?Boolean



991
992
993
# File 'lib/code/object/integer.rb', line 991

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

#code_ninety_seven?Boolean



1015
1016
1017
# File 'lib/code/object/integer.rb', line 1015

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

#code_ninety_six?Boolean



1011
1012
1013
# File 'lib/code/object/integer.rb', line 1011

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

#code_ninety_three?Boolean



999
1000
1001
# File 'lib/code/object/integer.rb', line 999

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

#code_ninety_two?Boolean



995
996
997
# File 'lib/code/object/integer.rb', line 995

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

#code_odd?Boolean



529
530
531
# File 'lib/code/object/integer.rb', line 529

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

#code_one?Boolean



631
632
633
# File 'lib/code/object/integer.rb', line 631

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

#code_one_hundred?Boolean



1027
1028
1029
# File 'lib/code/object/integer.rb', line 1027

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

#code_plus(other) ⇒ Object



533
534
535
536
537
538
539
540
541
542
543
# File 'lib/code/object/integer.rb', line 533

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



619
620
621
# File 'lib/code/object/integer.rb', line 619

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

#code_power(other) ⇒ Object



545
546
547
548
549
550
551
552
553
# File 'lib/code/object/integer.rb', line 545

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



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

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

#code_round(n = nil) ⇒ Object



560
561
562
563
564
565
# File 'lib/code/object/integer.rb', line 560

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



655
656
657
# File 'lib/code/object/integer.rb', line 655

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

#code_seventeen?Boolean



695
696
697
# File 'lib/code/object/integer.rb', line 695

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

#code_seventy?Boolean



907
908
909
# File 'lib/code/object/integer.rb', line 907

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

#code_seventy_eight?Boolean



939
940
941
# File 'lib/code/object/integer.rb', line 939

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

#code_seventy_five?Boolean



927
928
929
# File 'lib/code/object/integer.rb', line 927

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

#code_seventy_four?Boolean



923
924
925
# File 'lib/code/object/integer.rb', line 923

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

#code_seventy_nine?Boolean



943
944
945
# File 'lib/code/object/integer.rb', line 943

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

#code_seventy_one?Boolean



911
912
913
# File 'lib/code/object/integer.rb', line 911

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

#code_seventy_seven?Boolean



935
936
937
# File 'lib/code/object/integer.rb', line 935

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

#code_seventy_six?Boolean



931
932
933
# File 'lib/code/object/integer.rb', line 931

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

#code_seventy_three?Boolean



919
920
921
# File 'lib/code/object/integer.rb', line 919

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

#code_seventy_two?Boolean



915
916
917
# File 'lib/code/object/integer.rb', line 915

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

#code_six?Boolean



651
652
653
# File 'lib/code/object/integer.rb', line 651

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

#code_sixteen?Boolean



691
692
693
# File 'lib/code/object/integer.rb', line 691

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

#code_sixty?Boolean



867
868
869
# File 'lib/code/object/integer.rb', line 867

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

#code_sixty_eight?Boolean



899
900
901
# File 'lib/code/object/integer.rb', line 899

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

#code_sixty_five?Boolean



887
888
889
# File 'lib/code/object/integer.rb', line 887

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

#code_sixty_four?Boolean



883
884
885
# File 'lib/code/object/integer.rb', line 883

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

#code_sixty_nine?Boolean



903
904
905
# File 'lib/code/object/integer.rb', line 903

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

#code_sixty_one?Boolean



871
872
873
# File 'lib/code/object/integer.rb', line 871

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

#code_sixty_seven?Boolean



895
896
897
# File 'lib/code/object/integer.rb', line 895

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

#code_sixty_six?Boolean



891
892
893
# File 'lib/code/object/integer.rb', line 891

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

#code_sixty_three?Boolean



879
880
881
# File 'lib/code/object/integer.rb', line 879

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

#code_sixty_two?Boolean



875
876
877
# File 'lib/code/object/integer.rb', line 875

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

#code_sqrtObject



567
568
569
# File 'lib/code/object/integer.rb', line 567

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

#code_ten?Boolean



667
668
669
# File 'lib/code/object/integer.rb', line 667

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

#code_thirteen?Boolean



679
680
681
# File 'lib/code/object/integer.rb', line 679

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

#code_thirty?Boolean



747
748
749
# File 'lib/code/object/integer.rb', line 747

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

#code_thirty_eight?Boolean



779
780
781
# File 'lib/code/object/integer.rb', line 779

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

#code_thirty_five?Boolean



767
768
769
# File 'lib/code/object/integer.rb', line 767

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

#code_thirty_four?Boolean



763
764
765
# File 'lib/code/object/integer.rb', line 763

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

#code_thirty_nine?Boolean



783
784
785
# File 'lib/code/object/integer.rb', line 783

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

#code_thirty_one?Boolean



751
752
753
# File 'lib/code/object/integer.rb', line 751

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

#code_thirty_seven?Boolean



775
776
777
# File 'lib/code/object/integer.rb', line 775

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

#code_thirty_six?Boolean



771
772
773
# File 'lib/code/object/integer.rb', line 771

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

#code_thirty_three?Boolean



759
760
761
# File 'lib/code/object/integer.rb', line 759

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

#code_thirty_two?Boolean



755
756
757
# File 'lib/code/object/integer.rb', line 755

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

#code_three?Boolean



639
640
641
# File 'lib/code/object/integer.rb', line 639

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

#code_times(argument, **globals) ⇒ Object



579
580
581
582
583
584
585
586
587
588
589
590
# File 'lib/code/object/integer.rb', line 579

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



571
572
573
# File 'lib/code/object/integer.rb', line 571

def code_to_decimal
  Decimal.new(raw)
end

#code_to_integerObject



575
576
577
# File 'lib/code/object/integer.rb', line 575

def code_to_integer
  Integer.new(raw)
end

#code_truncate(n = nil) ⇒ Object



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

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



675
676
677
# File 'lib/code/object/integer.rb', line 675

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

#code_twenty?Boolean



707
708
709
# File 'lib/code/object/integer.rb', line 707

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

#code_twenty_eight?Boolean



739
740
741
# File 'lib/code/object/integer.rb', line 739

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

#code_twenty_five?Boolean



727
728
729
# File 'lib/code/object/integer.rb', line 727

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

#code_twenty_four?Boolean



723
724
725
# File 'lib/code/object/integer.rb', line 723

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

#code_twenty_nine?Boolean



743
744
745
# File 'lib/code/object/integer.rb', line 743

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

#code_twenty_one?Boolean



711
712
713
# File 'lib/code/object/integer.rb', line 711

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

#code_twenty_seven?Boolean



735
736
737
# File 'lib/code/object/integer.rb', line 735

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

#code_twenty_six?Boolean



731
732
733
# File 'lib/code/object/integer.rb', line 731

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

#code_twenty_three?Boolean



719
720
721
# File 'lib/code/object/integer.rb', line 719

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

#code_twenty_two?Boolean



715
716
717
# File 'lib/code/object/integer.rb', line 715

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

#code_two?Boolean



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

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

#code_unary_minusObject



599
600
601
# File 'lib/code/object/integer.rb', line 599

def code_unary_minus
  Integer.new(-raw)
end

#code_zero?Boolean



627
628
629
# File 'lib/code/object/integer.rb', line 627

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