Class: Code::Object::Integer

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

Constant Summary collapse

CLASS_DOCUMENTATION =
{
  name: "Integer",
  description:
    "represents whole numbers with arithmetic, bitwise operations, iteration, duration helpers, and numeric predicates.",
  examples: ["Integer.new(1)", "12.digits", "3.times((i) => { i })"]
}.freeze
INSTANCE_FUNCTIONS =
{
  "%" => {
    name: "%",
    description: "returns the integer modulo another number.",
    examples: ["5 % 2", "4 % 2", "7 % 3"]
  },
  "modulo" => {
    name: "modulo",
    description: "returns the integer modulo another number.",
    examples: %w[5.modulo(2) 4.modulo(2) 7.modulo(3)]
  },
  "&" => {
    name: "&",
    description:
      "returns the bitwise and of the integer and another number.",
    examples: ["5 & 3", "4 & 1", "7 & 2"]
  },
  "bitwise_and" => {
    name: "bitwise_and",
    description:
      "returns the bitwise and of the integer and another number.",
    examples: %w[5.bitwise_and(3) 4.bitwise_and(1) 7.bitwise_and(2)]
  },
  "*" => {
    name: "*",
    description: "multiplies numbers or repeats text by the integer.",
    examples: ["2 * 3", "2 * 3.5", "3 * :ha"]
  },
  "multiplication" => {
    name: "multiplication",
    description: "multiplies numbers or repeats text by the integer.",
    examples: %w[
      2.multiplication(3)
      2.multiplication(3.5)
      3.multiplication(:ha)
    ]
  },
  "×" => {
    name: "×",
    description: "multiplies numbers or repeats text by the integer.",
    examples: ["2 × 3", "2 × 3.5", "3 × :ha"]
  },
  "**" => {
    name: "**",
    description: "returns the integer raised to a power.",
    examples: ["2 ** 3", "4 ** 2", "9 ** 0.5"]
  },
  "power" => {
    name: "power",
    description: "returns the integer raised to a power.",
    examples: %w[2.power(3) 4.power(2) 9.power(0.5)]
  },
  "power_modulo" => {
    name: "power_modulo",
    description: "returns modular exponentiation.",
    examples: [
      "2.power_modulo(3, 5)",
      "3.power_modulo(2, 7)",
      "10.power_modulo(2, 6)"
    ]
  },
  "+" => {
    name: "+",
    description:
      "returns the integer itself when unary, adds numbers, or joins other values as text.",
    examples: ["1 + 2", "1 + 2.5", "+1"]
  },
  "plus" => {
    name: "plus",
    description: "adds numbers or joins non-numeric values as text.",
    examples: %w[1.plus(2) 1.plus(2.5) 1.plus(:x)]
  },
  "-" => {
    name: "-",
    description:
      "returns the integer negated when unary or minus another number.",
    examples: ["5 - 1", "5 - 2.5", "-5"]
  },
  "minus" => {
    name: "minus",
    description: "returns the integer minus another number.",
    examples: %w[5.minus(1) 5.minus(2.5) 1.minus(3)]
  },
  "unary_minus" => {
    name: "unary_minus",
    description: "returns the negated integer.",
    examples: %w[5.unary_minus 0.unary_minus -5.unary_minus]
  },
  "/" => {
    name: "/",
    description:
      "returns the integer divided by another number as a decimal.",
    examples: ["5 / 2", "4 / 2", "7 / 3"]
  },
  "division" => {
    name: "division",
    description:
      "returns the integer divided by another number as a decimal.",
    examples: %w[5.division(2) 4.division(2) 7.division(3)]
  },
  "÷" => {
    name: "÷",
    description:
      "returns the integer divided by another number as a decimal.",
    examples: ["5 ÷ 2", "4 ÷ 2", "7 ÷ 3"]
  },
  "decimal_divide" => {
    name: "decimal_divide",
    description:
      "returns the integer divided by another number as a decimal.",
    examples: %w[
      5.decimal_divide(2)
      4.decimal_divide(2)
      7.decimal_divide(3)
    ]
  },
  "digits" => {
    name: "digits",
    description:
      "returns the integer digits in reverse order, optionally for a base.",
    examples: %w[123.digits 123.digits(10) 10.digits(2)]
  },
  "bit_length" => {
    name: "bit_length",
    description:
      "returns the number of bits needed to represent the integer.",
    examples: %w[5.bit_length 0.bit_length 255.bit_length]
  },
  "all_bits?" => {
    name: "all_bits?",
    description: "returns whether every bit in a mask is set.",
    examples: %w[7.all_bits?(3) 4.all_bits?(3) 0.all_bits?(1)]
  },
  "any_bits?" => {
    name: "any_bits?",
    description: "returns whether any bit in a mask is set.",
    examples: %w[5.any_bits?(1) 4.any_bits?(1) 0.any_bits?(1)]
  },
  "no_bits?" => {
    name: "no_bits?",
    description: "returns whether no bits in a mask are set.",
    examples: %w[4.no_bits?(1) 5.no_bits?(1) 0.no_bits?(1)]
  },
  "character" => {
    name: "character",
    description: "returns the character for the integer codepoint.",
    examples: %w[65.character 97.character 48.character]
  },
  "greatest_common_denominator" => {
    name: "greatest_common_denominator",
    description:
      "returns the greatest common divisor with another integer.",
    examples: %w[
      12.greatest_common_denominator(8)
      21.greatest_common_denominator(14)
      5.greatest_common_denominator(2)
    ]
  },
  "lowest_common_multiple" => {
    name: "lowest_common_multiple",
    description:
      "returns the least common multiple with another integer.",
    examples: %w[
      4.lowest_common_multiple(6)
      3.lowest_common_multiple(7)
      5.lowest_common_multiple(10)
    ]
  },
  "<<" => {
    name: "<<",
    description: "returns the integer shifted left by a bit count.",
    examples: ["5 << 1", "4 << 2", "1 << 3"]
  },
  "left_shift" => {
    name: "left_shift",
    description: "returns the integer shifted left by a bit count.",
    examples: %w[5.left_shift(1) 4.left_shift(2) 1.left_shift(3)]
  },
  ">>" => {
    name: ">>",
    description: "returns the integer shifted right by a bit count.",
    examples: ["5 >> 1", "4 >> 1", "8 >> 2"]
  },
  "right_shift" => {
    name: "right_shift",
    description: "returns the integer shifted right by a bit count.",
    examples: %w[5.right_shift(1) 4.right_shift(1) 8.right_shift(2)]
  },
  "^" => {
    name: "^",
    description:
      "returns the bitwise xor of the integer and another number.",
    examples: ["5 ^ 3", "4 ^ 1", "7 ^ 2"]
  },
  "bitwise_xor" => {
    name: "bitwise_xor",
    description:
      "returns the bitwise xor of the integer and another number.",
    examples: %w[5.bitwise_xor(3) 4.bitwise_xor(1) 7.bitwise_xor(2)]
  },
  "abs" => {
    name: "abs",
    description: "returns the absolute value of the integer.",
    examples: %w[-1.abs 1.abs 0.abs]
  },
  "between?" => {
    name: "between?",
    description: "returns whether the integer is between two bounds.",
    examples: ["2.between?(1, 3)", "4.between?(1, 3)", "1.between?(1, 3)"]
  },
  "clamp" => {
    name: "clamp",
    description: "returns the integer constrained between two bounds.",
    examples: ["5.clamp(1, 3)", "0.clamp(1, 3)", "2.clamp(1, 3)"]
  },
  "divide" => {
    name: "divide",
    description:
      "returns integer division of the integer by another number.",
    examples: %w[5.divide(2) 10.divide(3) 9.divide(2)]
  },
  "divide_modulo" => {
    name: "divide_modulo",
    description: "returns integer division and modulo results as a list.",
    examples: %w[
      5.divide_modulo(2)
      10.divide_modulo(3)
      9.divide_modulo(2)
    ]
  },
  "ceil" => {
    name: "ceil",
    description:
      "returns the integer rounded toward positive infinity at an optional precision.",
    examples: %w[12.ceil 123.ceil(-1) -123.ceil(-1)]
  },
  "ceil_divide" => {
    name: "ceil_divide",
    description:
      "returns division by another number rounded up to an integer.",
    examples: %w[5.ceil_divide(2) 4.ceil_divide(2) 7.ceil_divide(3)]
  },
  "day" => {
    name: "day",
    description: "returns a duration of this many days.",
    examples: %w[1.day 2.day 0.day]
  },
  "days" => {
    name: "days",
    description: "returns a duration of this many days.",
    examples: %w[1.days 2.days 0.days]
  },
  "decrement!" => {
    name: "decrement!",
    description:
      "subtracts a value from the integer in place and returns it.",
    examples: [
      "i = 2 i.decrement!",
      "i = 2 i.decrement!(2)",
      "i = 0 i.decrement!"
    ]
  },
  "decrement" => {
    name: "decrement",
    description: "returns the integer minus a value, defaulting to one.",
    examples: %w[2.decrement 2.decrement(2) 0.decrement]
  },
  "even?" => {
    name: "even?",
    description: "returns whether the integer is even.",
    examples: %w[2.even? 1.even? 0.even?]
  },
  "floor" => {
    name: "floor",
    description:
      "returns the integer rounded toward negative infinity at an optional precision.",
    examples: %w[12.floor 123.floor(-1) -123.floor(-1)]
  },
  "hour" => {
    name: "hour",
    description: "returns a duration of this many hours.",
    examples: %w[1.hour 2.hour 0.hour]
  },
  "hours" => {
    name: "hours",
    description: "returns a duration of this many hours.",
    examples: %w[1.hours 2.hours 0.hours]
  },
  "increment!" => {
    name: "increment!",
    description: "adds a value to the integer in place and returns it.",
    examples: [
      "i = 1 i.increment!",
      "i = 1 i.increment!(2)",
      "i = 0 i.increment!"
    ]
  },
  "increment" => {
    name: "increment",
    description: "returns the integer plus a value, defaulting to one.",
    examples: %w[1.increment 1.increment(2) 0.increment]
  },
  "odd?" => {
    name: "odd?",
    description: "returns whether the integer is odd.",
    examples: %w[1.odd? 2.odd? 0.odd?]
  },
  "minute" => {
    name: "minute",
    description: "returns a duration of this many minutes.",
    examples: %w[1.minute 2.minute 0.minute]
  },
  "minutes" => {
    name: "minutes",
    description: "returns a duration of this many minutes.",
    examples: %w[1.minutes 2.minutes 0.minutes]
  },
  "month" => {
    name: "month",
    description: "returns a duration of this many months.",
    examples: %w[1.month 2.month 0.month]
  },
  "months" => {
    name: "months",
    description: "returns a duration of this many months.",
    examples: %w[1.months 2.months 0.months]
  },
  "round" => {
    name: "round",
    description: "returns the integer rounded to a precision.",
    examples: %w[12.round 123.round(-1) -123.round(-1)]
  },
  "second" => {
    name: "second",
    description: "returns a duration of this many seconds.",
    examples: %w[1.second 2.second 0.second]
  },
  "seconds" => {
    name: "seconds",
    description: "returns a duration of this many seconds.",
    examples: %w[1.seconds 2.seconds 0.seconds]
  },
  "sqrt" => {
    name: "sqrt",
    description: "returns the square root of the integer.",
    examples: %w[4.sqrt 9.sqrt 2.sqrt]
  },
  "times" => {
    name: "times",
    description:
      "calls a function once for each number from zero up to the integer and returns the integer.",
    examples: [
      "3.times((i) => { i })",
      "0.times((i) => { i })",
      "2.times((i, count) => { count })"
    ]
  },
  "down_to" => {
    name: "down_to",
    description:
      "calls a function for each integer from this value down to a target and returns the integer.",
    examples: [
      "3.down_to(1, (i) => { i })",
      "3.down_to(1, (i, index) => { index })",
      "1.down_to(1, (i) => { i })"
    ]
  },
  "up_to" => {
    name: "up_to",
    description:
      "calls a function for each integer from this value up to a target and returns the integer.",
    examples: [
      "1.up_to(3, (i) => { i })",
      "1.up_to(3, (i, index) => { index })",
      "1.up_to(1, (i) => { i })"
    ]
  },
  "truncate" => {
    name: "truncate",
    description: "returns the integer truncated to a precision.",
    examples: %w[12.truncate 123.truncate(-1) -123.truncate(-1)]
  },
  "week" => {
    name: "week",
    description: "returns a duration of this many weeks.",
    examples: %w[1.week 2.week 0.week]
  },
  "weeks" => {
    name: "weeks",
    description: "returns a duration of this many weeks.",
    examples: %w[1.weeks 2.weeks 0.weeks]
  },
  "year" => {
    name: "year",
    description: "returns a duration of this many years.",
    examples: %w[1.year 2.year 0.year]
  },
  "years" => {
    name: "years",
    description: "returns a duration of this many years.",
    examples: %w[1.years 2.years 0.years]
  },
  "|" => {
    name: "|",
    description:
      "returns the bitwise or of the integer and another number.",
    examples: ["5 | 2", "4 | 1", "7 | 2"]
  },
  "bitwise_or" => {
    name: "bitwise_or",
    description:
      "returns the bitwise or of the integer and another number.",
    examples: %w[5.bitwise_or(2) 4.bitwise_or(1) 7.bitwise_or(2)]
  },
  "many?" => {
    name: "many?",
    description: "returns whether the integer is greater than one.",
    examples: %w[2.many? 1.many? 0.many?]
  },
  "any?" => {
    name: "any?",
    description: "returns whether the integer is greater than zero.",
    examples: %w[1.any? 0.any? -1.any?]
  },
  "positive?" => {
    name: "positive?",
    description: "returns whether the integer is positive.",
    examples: %w[1.positive? 0.positive? -1.positive?]
  },
  "negative?" => {
    name: "negative?",
    description: "returns whether the integer is negative.",
    examples: %w[-1.negative? 0.negative? 1.negative?]
  },
  "next" => {
    name: "next",
    description: "returns the integer plus one.",
    examples: %w[1.next 0.next -1.next]
  },
  "successor" => {
    name: "successor",
    description: "returns the integer plus one.",
    examples: %w[1.successor 0.successor -1.successor]
  },
  "previous" => {
    name: "previous",
    description: "returns the integer minus one.",
    examples: %w[1.previous 0.previous -1.previous]
  },
  "predecessor" => {
    name: "predecessor",
    description: "returns the integer minus one.",
    examples: %w[1.predecessor 0.predecessor -1.predecessor]
  },
  "remainder" => {
    name: "remainder",
    description:
      "returns the remainder after division by another number.",
    examples: %w[5.remainder(2) 10.remainder(3) 9.remainder(2)]
  },
  "non_zero?" => {
    name: "non_zero?",
    description: "returns whether the integer is not zero.",
    examples: %w[1.non_zero? 0.non_zero? -1.non_zero?]
  },
  "integer?" => {
    name: "integer?",
    description: "returns whether the value is an integer.",
    examples: %w[1.integer? 0.integer? -1.integer?]
  },
  "finite?" => {
    name: "finite?",
    description: "returns whether the integer is finite.",
    examples: %w[1.finite? 0.finite? -1.finite?]
  },
  "infinite?" => {
    name: "infinite?",
    description: "returns whether the integer is infinite.",
    examples: %w[1.infinite? 0.infinite? -1.infinite?]
  },
  "numerator" => {
    name: "numerator",
    description: "returns the integer numerator.",
    examples: %w[1.numerator 0.numerator -1.numerator]
  },
  "denominator" => {
    name: "denominator",
    description: "returns one as the integer denominator.",
    examples: %w[1.denominator 0.denominator -1.denominator]
  },
  "magnitude" => {
    name: "magnitude",
    description: "returns the absolute value of the integer.",
    examples: %w[-1.magnitude 1.magnitude 0.magnitude]
  },
  "zero?" => {
    name: "zero?",
    description: "returns whether the integer is zero.",
    examples: %w[0.zero? 1.zero? -1.zero?]
  },
  "one?" => {
    name: "one?",
    description: "returns whether the integer is one.",
    examples: %w[1.one? 2.one? 0.one?]
  },
  "two?" => {
    name: "two?",
    description: "returns whether the integer is two.",
    examples: %w[2.two? 3.two? 0.two?]
  },
  "three?" => {
    name: "three?",
    description: "returns whether the integer is three.",
    examples: %w[3.three? 4.three? 0.three?]
  },
  "four?" => {
    name: "four?",
    description: "returns whether the integer is four.",
    examples: %w[4.four? 5.four? 0.four?]
  },
  "five?" => {
    name: "five?",
    description: "returns whether the integer is five.",
    examples: %w[5.five? 6.five? 0.five?]
  },
  "six?" => {
    name: "six?",
    description: "returns whether the integer is six.",
    examples: %w[6.six? 7.six? 0.six?]
  },
  "seven?" => {
    name: "seven?",
    description: "returns whether the integer is seven.",
    examples: %w[7.seven? 8.seven? 0.seven?]
  },
  "eight?" => {
    name: "eight?",
    description: "returns whether the integer is eight.",
    examples: %w[8.eight? 9.eight? 0.eight?]
  },
  "nine?" => {
    name: "nine?",
    description: "returns whether the integer is nine.",
    examples: %w[9.nine? 10.nine? 0.nine?]
  },
  "ten?" => {
    name: "ten?",
    description: "returns whether the integer is ten.",
    examples: %w[10.ten? 11.ten? 0.ten?]
  },
  "eleven?" => {
    name: "eleven?",
    description: "returns whether the integer is eleven.",
    examples: %w[11.eleven? 12.eleven? 0.eleven?]
  },
  "twelve?" => {
    name: "twelve?",
    description: "returns whether the integer is twelve.",
    examples: %w[12.twelve? 13.twelve? 0.twelve?]
  },
  "thirteen?" => {
    name: "thirteen?",
    description: "returns whether the integer is thirteen.",
    examples: %w[13.thirteen? 14.thirteen? 0.thirteen?]
  },
  "fourteen?" => {
    name: "fourteen?",
    description: "returns whether the integer is fourteen.",
    examples: %w[14.fourteen? 15.fourteen? 0.fourteen?]
  },
  "fifteen?" => {
    name: "fifteen?",
    description: "returns whether the integer is fifteen.",
    examples: %w[15.fifteen? 16.fifteen? 0.fifteen?]
  },
  "sixteen?" => {
    name: "sixteen?",
    description: "returns whether the integer is sixteen.",
    examples: %w[16.sixteen? 17.sixteen? 0.sixteen?]
  },
  "seventeen?" => {
    name: "seventeen?",
    description: "returns whether the integer is seventeen.",
    examples: %w[17.seventeen? 18.seventeen? 0.seventeen?]
  },
  "eighteen?" => {
    name: "eighteen?",
    description: "returns whether the integer is eighteen.",
    examples: %w[18.eighteen? 19.eighteen? 0.eighteen?]
  },
  "nineteen?" => {
    name: "nineteen?",
    description: "returns whether the integer is nineteen.",
    examples: %w[19.nineteen? 20.nineteen? 0.nineteen?]
  },
  "twenty?" => {
    name: "twenty?",
    description: "returns whether the integer is twenty.",
    examples: %w[20.twenty? 21.twenty? 0.twenty?]
  },
  "twenty_one?" => {
    name: "twenty_one?",
    description: "returns whether the integer is twenty one.",
    examples: %w[21.twenty_one? 22.twenty_one? 0.twenty_one?]
  },
  "twenty_two?" => {
    name: "twenty_two?",
    description: "returns whether the integer is twenty two.",
    examples: %w[22.twenty_two? 23.twenty_two? 0.twenty_two?]
  },
  "twenty_three?" => {
    name: "twenty_three?",
    description: "returns whether the integer is twenty three.",
    examples: %w[23.twenty_three? 24.twenty_three? 0.twenty_three?]
  },
  "twenty_four?" => {
    name: "twenty_four?",
    description: "returns whether the integer is twenty four.",
    examples: %w[24.twenty_four? 25.twenty_four? 0.twenty_four?]
  },
  "twenty_five?" => {
    name: "twenty_five?",
    description: "returns whether the integer is twenty five.",
    examples: %w[25.twenty_five? 26.twenty_five? 0.twenty_five?]
  },
  "twenty_six?" => {
    name: "twenty_six?",
    description: "returns whether the integer is twenty six.",
    examples: %w[26.twenty_six? 27.twenty_six? 0.twenty_six?]
  },
  "twenty_seven?" => {
    name: "twenty_seven?",
    description: "returns whether the integer is twenty seven.",
    examples: %w[27.twenty_seven? 28.twenty_seven? 0.twenty_seven?]
  },
  "twenty_eight?" => {
    name: "twenty_eight?",
    description: "returns whether the integer is twenty eight.",
    examples: %w[28.twenty_eight? 29.twenty_eight? 0.twenty_eight?]
  },
  "twenty_nine?" => {
    name: "twenty_nine?",
    description: "returns whether the integer is twenty nine.",
    examples: %w[29.twenty_nine? 30.twenty_nine? 0.twenty_nine?]
  },
  "thirty?" => {
    name: "thirty?",
    description: "returns whether the integer is thirty.",
    examples: %w[30.thirty? 31.thirty? 0.thirty?]
  },
  "thirty_one?" => {
    name: "thirty_one?",
    description: "returns whether the integer is thirty one.",
    examples: %w[31.thirty_one? 32.thirty_one? 0.thirty_one?]
  },
  "thirty_two?" => {
    name: "thirty_two?",
    description: "returns whether the integer is thirty two.",
    examples: %w[32.thirty_two? 33.thirty_two? 0.thirty_two?]
  },
  "thirty_three?" => {
    name: "thirty_three?",
    description: "returns whether the integer is thirty three.",
    examples: %w[33.thirty_three? 34.thirty_three? 0.thirty_three?]
  },
  "thirty_four?" => {
    name: "thirty_four?",
    description: "returns whether the integer is thirty four.",
    examples: %w[34.thirty_four? 35.thirty_four? 0.thirty_four?]
  },
  "thirty_five?" => {
    name: "thirty_five?",
    description: "returns whether the integer is thirty five.",
    examples: %w[35.thirty_five? 36.thirty_five? 0.thirty_five?]
  },
  "thirty_six?" => {
    name: "thirty_six?",
    description: "returns whether the integer is thirty six.",
    examples: %w[36.thirty_six? 37.thirty_six? 0.thirty_six?]
  },
  "thirty_seven?" => {
    name: "thirty_seven?",
    description: "returns whether the integer is thirty seven.",
    examples: %w[37.thirty_seven? 38.thirty_seven? 0.thirty_seven?]
  },
  "thirty_eight?" => {
    name: "thirty_eight?",
    description: "returns whether the integer is thirty eight.",
    examples: %w[38.thirty_eight? 39.thirty_eight? 0.thirty_eight?]
  },
  "thirty_nine?" => {
    name: "thirty_nine?",
    description: "returns whether the integer is thirty nine.",
    examples: %w[39.thirty_nine? 40.thirty_nine? 0.thirty_nine?]
  },
  "forty?" => {
    name: "forty?",
    description: "returns whether the integer is forty.",
    examples: %w[40.forty? 41.forty? 0.forty?]
  },
  "forty_one?" => {
    name: "forty_one?",
    description: "returns whether the integer is forty one.",
    examples: %w[41.forty_one? 42.forty_one? 0.forty_one?]
  },
  "forty_two?" => {
    name: "forty_two?",
    description: "returns whether the integer is forty two.",
    examples: %w[42.forty_two? 43.forty_two? 0.forty_two?]
  },
  "forty_three?" => {
    name: "forty_three?",
    description: "returns whether the integer is forty three.",
    examples: %w[43.forty_three? 44.forty_three? 0.forty_three?]
  },
  "forty_four?" => {
    name: "forty_four?",
    description: "returns whether the integer is forty four.",
    examples: %w[44.forty_four? 45.forty_four? 0.forty_four?]
  },
  "forty_five?" => {
    name: "forty_five?",
    description: "returns whether the integer is forty five.",
    examples: %w[45.forty_five? 46.forty_five? 0.forty_five?]
  },
  "forty_six?" => {
    name: "forty_six?",
    description: "returns whether the integer is forty six.",
    examples: %w[46.forty_six? 47.forty_six? 0.forty_six?]
  },
  "forty_seven?" => {
    name: "forty_seven?",
    description: "returns whether the integer is forty seven.",
    examples: %w[47.forty_seven? 48.forty_seven? 0.forty_seven?]
  },
  "forty_eight?" => {
    name: "forty_eight?",
    description: "returns whether the integer is forty eight.",
    examples: %w[48.forty_eight? 49.forty_eight? 0.forty_eight?]
  },
  "forty_nine?" => {
    name: "forty_nine?",
    description: "returns whether the integer is forty nine.",
    examples: %w[49.forty_nine? 50.forty_nine? 0.forty_nine?]
  },
  "fifty?" => {
    name: "fifty?",
    description: "returns whether the integer is fifty.",
    examples: %w[50.fifty? 51.fifty? 0.fifty?]
  },
  "fifty_one?" => {
    name: "fifty_one?",
    description: "returns whether the integer is fifty one.",
    examples: %w[51.fifty_one? 52.fifty_one? 0.fifty_one?]
  },
  "fifty_two?" => {
    name: "fifty_two?",
    description: "returns whether the integer is fifty two.",
    examples: %w[52.fifty_two? 53.fifty_two? 0.fifty_two?]
  },
  "fifty_three?" => {
    name: "fifty_three?",
    description: "returns whether the integer is fifty three.",
    examples: %w[53.fifty_three? 54.fifty_three? 0.fifty_three?]
  },
  "fifty_four?" => {
    name: "fifty_four?",
    description: "returns whether the integer is fifty four.",
    examples: %w[54.fifty_four? 55.fifty_four? 0.fifty_four?]
  },
  "fifty_five?" => {
    name: "fifty_five?",
    description: "returns whether the integer is fifty five.",
    examples: %w[55.fifty_five? 56.fifty_five? 0.fifty_five?]
  },
  "fifty_six?" => {
    name: "fifty_six?",
    description: "returns whether the integer is fifty six.",
    examples: %w[56.fifty_six? 57.fifty_six? 0.fifty_six?]
  },
  "fifty_seven?" => {
    name: "fifty_seven?",
    description: "returns whether the integer is fifty seven.",
    examples: %w[57.fifty_seven? 58.fifty_seven? 0.fifty_seven?]
  },
  "fifty_eight?" => {
    name: "fifty_eight?",
    description: "returns whether the integer is fifty eight.",
    examples: %w[58.fifty_eight? 59.fifty_eight? 0.fifty_eight?]
  },
  "fifty_nine?" => {
    name: "fifty_nine?",
    description: "returns whether the integer is fifty nine.",
    examples: %w[59.fifty_nine? 60.fifty_nine? 0.fifty_nine?]
  },
  "sixty?" => {
    name: "sixty?",
    description: "returns whether the integer is sixty.",
    examples: %w[60.sixty? 61.sixty? 0.sixty?]
  },
  "sixty_one?" => {
    name: "sixty_one?",
    description: "returns whether the integer is sixty one.",
    examples: %w[61.sixty_one? 62.sixty_one? 0.sixty_one?]
  },
  "sixty_two?" => {
    name: "sixty_two?",
    description: "returns whether the integer is sixty two.",
    examples: %w[62.sixty_two? 63.sixty_two? 0.sixty_two?]
  },
  "sixty_three?" => {
    name: "sixty_three?",
    description: "returns whether the integer is sixty three.",
    examples: %w[63.sixty_three? 64.sixty_three? 0.sixty_three?]
  },
  "sixty_four?" => {
    name: "sixty_four?",
    description: "returns whether the integer is sixty four.",
    examples: %w[64.sixty_four? 65.sixty_four? 0.sixty_four?]
  },
  "sixty_five?" => {
    name: "sixty_five?",
    description: "returns whether the integer is sixty five.",
    examples: %w[65.sixty_five? 66.sixty_five? 0.sixty_five?]
  },
  "sixty_six?" => {
    name: "sixty_six?",
    description: "returns whether the integer is sixty six.",
    examples: %w[66.sixty_six? 67.sixty_six? 0.sixty_six?]
  },
  "sixty_seven?" => {
    name: "sixty_seven?",
    description: "returns whether the integer is sixty seven.",
    examples: %w[67.sixty_seven? 68.sixty_seven? 0.sixty_seven?]
  },
  "sixty_eight?" => {
    name: "sixty_eight?",
    description: "returns whether the integer is sixty eight.",
    examples: %w[68.sixty_eight? 69.sixty_eight? 0.sixty_eight?]
  },
  "sixty_nine?" => {
    name: "sixty_nine?",
    description: "returns whether the integer is sixty nine.",
    examples: %w[69.sixty_nine? 70.sixty_nine? 0.sixty_nine?]
  },
  "seventy?" => {
    name: "seventy?",
    description: "returns whether the integer is seventy.",
    examples: %w[70.seventy? 71.seventy? 0.seventy?]
  },
  "seventy_one?" => {
    name: "seventy_one?",
    description: "returns whether the integer is seventy one.",
    examples: %w[71.seventy_one? 72.seventy_one? 0.seventy_one?]
  },
  "seventy_two?" => {
    name: "seventy_two?",
    description: "returns whether the integer is seventy two.",
    examples: %w[72.seventy_two? 73.seventy_two? 0.seventy_two?]
  },
  "seventy_three?" => {
    name: "seventy_three?",
    description: "returns whether the integer is seventy three.",
    examples: %w[73.seventy_three? 74.seventy_three? 0.seventy_three?]
  },
  "seventy_four?" => {
    name: "seventy_four?",
    description: "returns whether the integer is seventy four.",
    examples: %w[74.seventy_four? 75.seventy_four? 0.seventy_four?]
  },
  "seventy_five?" => {
    name: "seventy_five?",
    description: "returns whether the integer is seventy five.",
    examples: %w[75.seventy_five? 76.seventy_five? 0.seventy_five?]
  },
  "seventy_six?" => {
    name: "seventy_six?",
    description: "returns whether the integer is seventy six.",
    examples: %w[76.seventy_six? 77.seventy_six? 0.seventy_six?]
  },
  "seventy_seven?" => {
    name: "seventy_seven?",
    description: "returns whether the integer is seventy seven.",
    examples: %w[77.seventy_seven? 78.seventy_seven? 0.seventy_seven?]
  },
  "seventy_eight?" => {
    name: "seventy_eight?",
    description: "returns whether the integer is seventy eight.",
    examples: %w[78.seventy_eight? 79.seventy_eight? 0.seventy_eight?]
  },
  "seventy_nine?" => {
    name: "seventy_nine?",
    description: "returns whether the integer is seventy nine.",
    examples: %w[79.seventy_nine? 80.seventy_nine? 0.seventy_nine?]
  },
  "eighty?" => {
    name: "eighty?",
    description: "returns whether the integer is eighty.",
    examples: %w[80.eighty? 81.eighty? 0.eighty?]
  },
  "eighty_one?" => {
    name: "eighty_one?",
    description: "returns whether the integer is eighty one.",
    examples: %w[81.eighty_one? 82.eighty_one? 0.eighty_one?]
  },
  "eighty_two?" => {
    name: "eighty_two?",
    description: "returns whether the integer is eighty two.",
    examples: %w[82.eighty_two? 83.eighty_two? 0.eighty_two?]
  },
  "eighty_three?" => {
    name: "eighty_three?",
    description: "returns whether the integer is eighty three.",
    examples: %w[83.eighty_three? 84.eighty_three? 0.eighty_three?]
  },
  "eighty_four?" => {
    name: "eighty_four?",
    description: "returns whether the integer is eighty four.",
    examples: %w[84.eighty_four? 85.eighty_four? 0.eighty_four?]
  },
  "eighty_five?" => {
    name: "eighty_five?",
    description: "returns whether the integer is eighty five.",
    examples: %w[85.eighty_five? 86.eighty_five? 0.eighty_five?]
  },
  "eighty_six?" => {
    name: "eighty_six?",
    description: "returns whether the integer is eighty six.",
    examples: %w[86.eighty_six? 87.eighty_six? 0.eighty_six?]
  },
  "eighty_seven?" => {
    name: "eighty_seven?",
    description: "returns whether the integer is eighty seven.",
    examples: %w[87.eighty_seven? 88.eighty_seven? 0.eighty_seven?]
  },
  "eighty_eight?" => {
    name: "eighty_eight?",
    description: "returns whether the integer is eighty eight.",
    examples: %w[88.eighty_eight? 89.eighty_eight? 0.eighty_eight?]
  },
  "eighty_nine?" => {
    name: "eighty_nine?",
    description: "returns whether the integer is eighty nine.",
    examples: %w[89.eighty_nine? 90.eighty_nine? 0.eighty_nine?]
  },
  "ninety?" => {
    name: "ninety?",
    description: "returns whether the integer is ninety.",
    examples: %w[90.ninety? 91.ninety? 0.ninety?]
  },
  "ninety_one?" => {
    name: "ninety_one?",
    description: "returns whether the integer is ninety one.",
    examples: %w[91.ninety_one? 92.ninety_one? 0.ninety_one?]
  },
  "ninety_two?" => {
    name: "ninety_two?",
    description: "returns whether the integer is ninety two.",
    examples: %w[92.ninety_two? 93.ninety_two? 0.ninety_two?]
  },
  "ninety_three?" => {
    name: "ninety_three?",
    description: "returns whether the integer is ninety three.",
    examples: %w[93.ninety_three? 94.ninety_three? 0.ninety_three?]
  },
  "ninety_four?" => {
    name: "ninety_four?",
    description: "returns whether the integer is ninety four.",
    examples: %w[94.ninety_four? 95.ninety_four? 0.ninety_four?]
  },
  "ninety_five?" => {
    name: "ninety_five?",
    description: "returns whether the integer is ninety five.",
    examples: %w[95.ninety_five? 96.ninety_five? 0.ninety_five?]
  },
  "ninety_six?" => {
    name: "ninety_six?",
    description: "returns whether the integer is ninety six.",
    examples: %w[96.ninety_six? 97.ninety_six? 0.ninety_six?]
  },
  "ninety_seven?" => {
    name: "ninety_seven?",
    description: "returns whether the integer is ninety seven.",
    examples: %w[97.ninety_seven? 98.ninety_seven? 0.ninety_seven?]
  },
  "ninety_eight?" => {
    name: "ninety_eight?",
    description: "returns whether the integer is ninety eight.",
    examples: %w[98.ninety_eight? 99.ninety_eight? 0.ninety_eight?]
  },
  "ninety_nine?" => {
    name: "ninety_nine?",
    description: "returns whether the integer is ninety nine.",
    examples: %w[99.ninety_nine? 100.ninety_nine? 0.ninety_nine?]
  },
  "one_hundred?" => {
    name: "one_hundred?",
    description: "returns whether the integer is one hundred.",
    examples: %w[100.one_hundred? 101.one_hundred? 0.one_hundred?]
  }
}.freeze

Constants inherited from Code::Object

CLASS_FUNCTIONS, NUMBER_CLASSES

Constants included from Concerns::Shared

Concerns::Shared::COMPOUND_ASSIGNMENT_OPERATORS, Concerns::Shared::OPERATOR_METHOD_ALIASES, Concerns::Shared::SHARED_OPERATORS

Instance Attribute Summary

Attributes included from Concerns::Shared

#functions, #raw

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Number

#code_between?, #code_clamp, #code_divide, #code_divide_modulo, #code_next, #code_predecessor, #code_previous, #code_remainder, #code_successor

Methods inherited from Code::Object

class_documentation, class_functions, code_new, #code_new, documentation, documentation_for, documented_functions_for, function_documentation_for, function_documentation_registry_for, functions, inherited_function_documentation_for, instance_functions, maybe, #name, repeat, sorted_dictionary, |

Methods included from Concerns::Shared

#<=>, #==, #as_json, #blank?, #code_and, #code_as_json, #code_blank?, #code_class_functions, #code_compare, #code_deep_duplicate, #code_different, #code_documentable_functions, #code_documentation, #code_duplicate, #code_dynamic_call, #code_equal, #code_exclamation_mark, #code_exclusive_range, #code_false?, #code_falsy?, code_fetch, #code_fetch, #code_functions, code_get, #code_get, #code_greater, #code_greater_or_equal, #code_has_key?, #code_inclusive_range, #code_inspect, #code_instance_functions, #code_instance_of?, #code_is_a?, #code_itself, #code_less, #code_less_or_equal, #code_name, #code_nothing?, #code_or, #code_presence, #code_presence_in, #code_present?, #code_respond_to?, #code_same_object?, #code_self, #code_send, code_set, #code_set, #code_something?, #code_strict_different, #code_strict_equal, #code_tap, #code_then, #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_true?, #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

Returns a new instance of Integer.



1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
# File 'lib/code/object/integer.rb', line 1020

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

Class Method Details

.function_documentation(scope) ⇒ Object



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

def self.function_documentation(scope)
  return INSTANCE_FUNCTIONS if scope == :instance

  {}
end

Instance Method Details

#call(**args) ⇒ Object



1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
# File 'lib/code/object/integer.rb', line 1035

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 "power_modulo"
    sig(args) { [Integer, Integer] }
    code_power_modulo(*code_arguments.raw)
  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 "divide"
    sig(args) { Integer | Decimal }
    code_divide(code_value)
  when "divide_modulo"
    sig(args) { Integer | Decimal }
    code_divide_modulo(code_value)
  when "decimal_divide"
    sig(args) { Integer | Decimal }
    code_decimal_divide(code_value)
  when "digits"
    sig(args) { Integer.maybe }
    code_digits(code_value)
  when "bit_length"
    sig(args)
    code_bit_length
  when "all_bits?"
    sig(args) { Integer }
    code_all_bits?(code_value)
  when "any_bits?"
    sig(args) { Integer }
    code_any_bits?(code_value)
  when "no_bits?"
    sig(args) { Integer }
    code_no_bits?(code_value)
  when "character"
    sig(args)
    code_character
  when "greatest_common_denominator"
    sig(args) { Integer }
    code_greatest_common_denominator(code_value)
  when "lowest_common_multiple"
    sig(args) { Integer }
    code_lowest_common_multiple(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 "between?"
    sig(args) { [Integer | Decimal, Integer | Decimal] }
    code_between?(*code_arguments.raw)
  when "ceil"
    sig(args) { Integer.maybe }
    code_ceil(code_value)
  when "ceil_divide"
    sig(args) { Integer | Decimal }
    code_ceil_divide(code_value)
  when "clamp"
    sig(args) { [Integer | Decimal, Integer | Decimal] }
    code_clamp(*code_arguments.raw)
  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 "minute", "minutes"
    sig(args)
    code_minutes
  when "month", "months"
    sig(args)
    code_months
  when "next", "successor"
    sig(args)
    code_next
  when "previous", "predecessor"
    sig(args)
    code_previous
  when "remainder"
    sig(args) { Integer | Decimal }
    code_remainder(code_value)
  when "round"
    sig(args) { Integer.maybe }
    code_round(code_value)
  when "second", "seconds"
    sig(args)
    code_seconds
  when "sqrt"
    sig(args)
    code_sqrt
  when "times"
    sig(args) { Function }
    code_times(code_value, **globals)
  when "down_to"
    sig(args) { [Integer, Function] }
    code_down_to(*code_arguments.raw, **globals)
  when "up_to"
    sig(args) { [Integer, Function] }
    code_up_to(*code_arguments.raw, **globals)
  when "truncate"
    sig(args) { Integer.maybe }
    code_truncate(code_value)
  when "week", "weeks"
    sig(args)
    code_weeks
  when "year", "years"
    sig(args)
    code_years
  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 "non_zero?"
    sig(args)
    code_non_zero?
  when "integer?"
    sig(args)
    code_integer?
  when "finite?"
    sig(args)
    code_finite?
  when "infinite?"
    sig(args)
    code_infinite?
  when "numerator"
    sig(args)
    code_numerator
  when "denominator"
    sig(args)
    code_denominator
  when "magnitude"
    sig(args)
    code_magnitude
  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



1536
1537
1538
# File 'lib/code/object/integer.rb', line 1536

def code_abs
  Decimal.new(raw.abs)
end

#code_all_bits?(mask) ⇒ Boolean

Returns:



1559
1560
1561
1562
1563
# File 'lib/code/object/integer.rb', line 1559

def code_all_bits?(mask)
  code_mask = mask.to_code

  Boolean.new(raw.allbits?(code_mask.raw))
end

#code_any?Boolean

Returns:



1826
1827
1828
# File 'lib/code/object/integer.rb', line 1826

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

#code_any_bits?(mask) ⇒ Boolean

Returns:



1565
1566
1567
1568
1569
# File 'lib/code/object/integer.rb', line 1565

def code_any_bits?(mask)
  code_mask = mask.to_code

  Boolean.new(raw.anybits?(code_mask.raw))
end

#code_bit_lengthObject



1555
1556
1557
# File 'lib/code/object/integer.rb', line 1555

def code_bit_length
  Integer.new(raw.bit_length)
end

#code_bitwise_and(other) ⇒ Object



1540
1541
1542
1543
# File 'lib/code/object/integer.rb', line 1540

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

#code_bitwise_or(other) ⇒ Object



1545
1546
1547
1548
# File 'lib/code/object/integer.rb', line 1545

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

#code_bitwise_xor(other) ⇒ Object



1550
1551
1552
1553
# File 'lib/code/object/integer.rb', line 1550

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

#code_ceil(n = nil) ⇒ Object



1577
1578
1579
1580
1581
# File 'lib/code/object/integer.rb', line 1577

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



1583
1584
1585
1586
1587
# File 'lib/code/object/integer.rb', line 1583

def code_ceil_divide(other)
  code_other = other.to_code

  Integer.new(raw.ceildiv(code_other.raw))
end

#code_characterObject



1621
1622
1623
# File 'lib/code/object/integer.rb', line 1621

def code_character
  String.new(raw.chr)
end

#code_daysObject



1854
1855
1856
# File 'lib/code/object/integer.rb', line 1854

def code_days
  Duration.new(raw.days)
end

#code_decimal_divide(other) ⇒ Object



1607
1608
1609
# File 'lib/code/object/integer.rb', line 1607

def code_decimal_divide(other)
  code_division(other)
end

#code_decrement(n = nil) ⇒ Object



1596
1597
1598
1599
1600
# File 'lib/code/object/integer.rb', line 1596

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



1589
1590
1591
1592
1593
1594
# File 'lib/code/object/integer.rb', line 1589

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_denominatorObject



1886
1887
1888
# File 'lib/code/object/integer.rb', line 1886

def code_denominator
  Integer.new(raw.denominator)
end

#code_digits(base = nil) ⇒ Object



1611
1612
1613
1614
1615
1616
1617
1618
1619
# File 'lib/code/object/integer.rb', line 1611

def code_digits(base = nil)
  code_base = base.to_code

  if code_base.nothing?
    List.new(raw.digits)
  else
    List.new(raw.digits(code_base.raw))
  end
end

#code_division(other) ⇒ Object



1602
1603
1604
1605
# File 'lib/code/object/integer.rb', line 1602

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

#code_down_to(value, function, **globals) ⇒ Object



1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
# File 'lib/code/object/integer.rb', line 1769

def code_down_to(value, function, **globals)
  code_value = value.to_code
  code_function = function.to_code

  raw
    .downto(code_value.raw)
    .with_index do |element, index|
      code_function.call(
        arguments:
          List.new([Integer.new(element), Integer.new(index), self]),
        **globals
      )
    rescue Error::Next => e
      e.code_value
    end

  self
rescue Error::Break => e
  e.code_value
end

#code_eight?Boolean

Returns:



1926
1927
1928
# File 'lib/code/object/integer.rb', line 1926

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

#code_eighteen?Boolean

Returns:



1966
1967
1968
# File 'lib/code/object/integer.rb', line 1966

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

#code_eighty?Boolean

Returns:



2214
2215
2216
# File 'lib/code/object/integer.rb', line 2214

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

#code_eighty_eight?Boolean

Returns:



2246
2247
2248
# File 'lib/code/object/integer.rb', line 2246

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

#code_eighty_five?Boolean

Returns:



2234
2235
2236
# File 'lib/code/object/integer.rb', line 2234

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

#code_eighty_four?Boolean

Returns:



2230
2231
2232
# File 'lib/code/object/integer.rb', line 2230

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

#code_eighty_nine?Boolean

Returns:



2250
2251
2252
# File 'lib/code/object/integer.rb', line 2250

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

#code_eighty_one?Boolean

Returns:



2218
2219
2220
# File 'lib/code/object/integer.rb', line 2218

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

#code_eighty_seven?Boolean

Returns:



2242
2243
2244
# File 'lib/code/object/integer.rb', line 2242

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

#code_eighty_six?Boolean

Returns:



2238
2239
2240
# File 'lib/code/object/integer.rb', line 2238

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

#code_eighty_three?Boolean

Returns:



2226
2227
2228
# File 'lib/code/object/integer.rb', line 2226

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

#code_eighty_two?Boolean

Returns:



2222
2223
2224
# File 'lib/code/object/integer.rb', line 2222

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

#code_eleven?Boolean

Returns:



1938
1939
1940
# File 'lib/code/object/integer.rb', line 1938

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

#code_even?Boolean

Returns:



1625
1626
1627
# File 'lib/code/object/integer.rb', line 1625

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

#code_fifteen?Boolean

Returns:



1954
1955
1956
# File 'lib/code/object/integer.rb', line 1954

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

#code_fifty?Boolean

Returns:



2094
2095
2096
# File 'lib/code/object/integer.rb', line 2094

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

#code_fifty_eight?Boolean

Returns:



2126
2127
2128
# File 'lib/code/object/integer.rb', line 2126

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

#code_fifty_five?Boolean

Returns:



2114
2115
2116
# File 'lib/code/object/integer.rb', line 2114

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

#code_fifty_four?Boolean

Returns:



2110
2111
2112
# File 'lib/code/object/integer.rb', line 2110

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

#code_fifty_nine?Boolean

Returns:



2130
2131
2132
# File 'lib/code/object/integer.rb', line 2130

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

#code_fifty_one?Boolean

Returns:



2098
2099
2100
# File 'lib/code/object/integer.rb', line 2098

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

#code_fifty_seven?Boolean

Returns:



2122
2123
2124
# File 'lib/code/object/integer.rb', line 2122

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

#code_fifty_six?Boolean

Returns:



2118
2119
2120
# File 'lib/code/object/integer.rb', line 2118

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

#code_fifty_three?Boolean

Returns:



2106
2107
2108
# File 'lib/code/object/integer.rb', line 2106

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

#code_fifty_two?Boolean

Returns:



2102
2103
2104
# File 'lib/code/object/integer.rb', line 2102

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

#code_finite?Boolean

Returns:



1874
1875
1876
# File 'lib/code/object/integer.rb', line 1874

def code_finite?
  Boolean.new(true)
end

#code_five?Boolean

Returns:



1914
1915
1916
# File 'lib/code/object/integer.rb', line 1914

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

#code_floor(n = nil) ⇒ Object



1629
1630
1631
1632
1633
# File 'lib/code/object/integer.rb', line 1629

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:



2054
2055
2056
# File 'lib/code/object/integer.rb', line 2054

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

#code_forty_eight?Boolean

Returns:



2086
2087
2088
# File 'lib/code/object/integer.rb', line 2086

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

#code_forty_five?Boolean

Returns:



2074
2075
2076
# File 'lib/code/object/integer.rb', line 2074

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

#code_forty_four?Boolean

Returns:



2070
2071
2072
# File 'lib/code/object/integer.rb', line 2070

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

#code_forty_nine?Boolean

Returns:



2090
2091
2092
# File 'lib/code/object/integer.rb', line 2090

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

#code_forty_one?Boolean

Returns:



2058
2059
2060
# File 'lib/code/object/integer.rb', line 2058

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

#code_forty_seven?Boolean

Returns:



2082
2083
2084
# File 'lib/code/object/integer.rb', line 2082

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

#code_forty_six?Boolean

Returns:



2078
2079
2080
# File 'lib/code/object/integer.rb', line 2078

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

#code_forty_three?Boolean

Returns:



2066
2067
2068
# File 'lib/code/object/integer.rb', line 2066

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

#code_forty_two?Boolean

Returns:



2062
2063
2064
# File 'lib/code/object/integer.rb', line 2062

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

#code_four?Boolean

Returns:



1910
1911
1912
# File 'lib/code/object/integer.rb', line 1910

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

#code_fourteen?Boolean

Returns:



1950
1951
1952
# File 'lib/code/object/integer.rb', line 1950

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

#code_greatest_common_denominator(other) ⇒ Object



1648
1649
1650
1651
# File 'lib/code/object/integer.rb', line 1648

def code_greatest_common_denominator(other)
  code_other = other.to_code
  Integer.new(raw.gcd(code_other.raw))
end

#code_hoursObject



1830
1831
1832
# File 'lib/code/object/integer.rb', line 1830

def code_hours
  Duration.new(raw.hours)
end

#code_increment(n = nil) ⇒ Object



1642
1643
1644
1645
1646
# File 'lib/code/object/integer.rb', line 1642

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



1635
1636
1637
1638
1639
1640
# File 'lib/code/object/integer.rb', line 1635

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_infinite?Boolean

Returns:



1878
1879
1880
# File 'lib/code/object/integer.rb', line 1878

def code_infinite?
  Boolean.new(false)
end

#code_integer?Boolean

Returns:



1870
1871
1872
# File 'lib/code/object/integer.rb', line 1870

def code_integer?
  Boolean.new(true)
end

#code_left_shift(other) ⇒ Object



1658
1659
1660
1661
# File 'lib/code/object/integer.rb', line 1658

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

#code_lowest_common_multiple(other) ⇒ Object



1653
1654
1655
1656
# File 'lib/code/object/integer.rb', line 1653

def code_lowest_common_multiple(other)
  code_other = other.to_code
  Integer.new(raw.lcm(code_other.raw))
end

#code_magnitudeObject



1890
1891
1892
# File 'lib/code/object/integer.rb', line 1890

def code_magnitude
  code_abs
end

#code_many?Boolean

Returns:



1822
1823
1824
# File 'lib/code/object/integer.rb', line 1822

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

#code_minus(other) ⇒ Object



1663
1664
1665
1666
1667
1668
1669
1670
1671
# File 'lib/code/object/integer.rb', line 1663

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_minutesObject



1834
1835
1836
# File 'lib/code/object/integer.rb', line 1834

def code_minutes
  Duration.new(raw.minutes)
end

#code_modulo(other) ⇒ Object



1673
1674
1675
1676
1677
1678
1679
1680
1681
# File 'lib/code/object/integer.rb', line 1673

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_monthsObject



1838
1839
1840
# File 'lib/code/object/integer.rb', line 1838

def code_months
  Duration.new(raw.months)
end

#code_multiplication(other) ⇒ Object



1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
# File 'lib/code/object/integer.rb', line 1683

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:



1862
1863
1864
# File 'lib/code/object/integer.rb', line 1862

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

#code_nine?Boolean

Returns:



1930
1931
1932
# File 'lib/code/object/integer.rb', line 1930

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

#code_nineteen?Boolean

Returns:



1970
1971
1972
# File 'lib/code/object/integer.rb', line 1970

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

#code_ninety?Boolean

Returns:



2254
2255
2256
# File 'lib/code/object/integer.rb', line 2254

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

#code_ninety_eight?Boolean

Returns:



2286
2287
2288
# File 'lib/code/object/integer.rb', line 2286

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

#code_ninety_five?Boolean

Returns:



2274
2275
2276
# File 'lib/code/object/integer.rb', line 2274

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

#code_ninety_four?Boolean

Returns:



2270
2271
2272
# File 'lib/code/object/integer.rb', line 2270

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

#code_ninety_nine?Boolean

Returns:



2290
2291
2292
# File 'lib/code/object/integer.rb', line 2290

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

#code_ninety_one?Boolean

Returns:



2258
2259
2260
# File 'lib/code/object/integer.rb', line 2258

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

#code_ninety_seven?Boolean

Returns:



2282
2283
2284
# File 'lib/code/object/integer.rb', line 2282

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

#code_ninety_six?Boolean

Returns:



2278
2279
2280
# File 'lib/code/object/integer.rb', line 2278

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

#code_ninety_three?Boolean

Returns:



2266
2267
2268
# File 'lib/code/object/integer.rb', line 2266

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

#code_ninety_two?Boolean

Returns:



2262
2263
2264
# File 'lib/code/object/integer.rb', line 2262

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

#code_no_bits?(mask) ⇒ Boolean

Returns:



1571
1572
1573
1574
1575
# File 'lib/code/object/integer.rb', line 1571

def code_no_bits?(mask)
  code_mask = mask.to_code

  Boolean.new(raw.nobits?(code_mask.raw))
end

#code_non_zero?Boolean

Returns:



1866
1867
1868
# File 'lib/code/object/integer.rb', line 1866

def code_non_zero?
  Boolean.new(!raw.zero?)
end

#code_numeratorObject



1882
1883
1884
# File 'lib/code/object/integer.rb', line 1882

def code_numerator
  Integer.new(raw.numerator)
end

#code_odd?Boolean

Returns:



1695
1696
1697
# File 'lib/code/object/integer.rb', line 1695

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

#code_one?Boolean

Returns:



1898
1899
1900
# File 'lib/code/object/integer.rb', line 1898

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

#code_one_hundred?Boolean

Returns:



2294
2295
2296
# File 'lib/code/object/integer.rb', line 2294

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

#code_plus(other) ⇒ Object



1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
# File 'lib/code/object/integer.rb', line 1699

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:



1858
1859
1860
# File 'lib/code/object/integer.rb', line 1858

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

#code_power(other) ⇒ Object



1711
1712
1713
1714
1715
1716
1717
1718
1719
# File 'lib/code/object/integer.rb', line 1711

def code_power(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_power_modulo(power, modulo) ⇒ Object



1721
1722
1723
1724
1725
1726
# File 'lib/code/object/integer.rb', line 1721

def code_power_modulo(power, modulo)
  code_power = power.to_code
  code_modulo = modulo.to_code

  Integer.new(raw.pow(code_power.raw, code_modulo.raw))
end

#code_right_shift(other) ⇒ Object



1728
1729
1730
1731
# File 'lib/code/object/integer.rb', line 1728

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

#code_round(n = nil) ⇒ Object



1733
1734
1735
1736
1737
1738
# File 'lib/code/object/integer.rb', line 1733

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_secondsObject



1842
1843
1844
# File 'lib/code/object/integer.rb', line 1842

def code_seconds
  Duration.new(raw.seconds)
end

#code_seven?Boolean

Returns:



1922
1923
1924
# File 'lib/code/object/integer.rb', line 1922

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

#code_seventeen?Boolean

Returns:



1962
1963
1964
# File 'lib/code/object/integer.rb', line 1962

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

#code_seventy?Boolean

Returns:



2174
2175
2176
# File 'lib/code/object/integer.rb', line 2174

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

#code_seventy_eight?Boolean

Returns:



2206
2207
2208
# File 'lib/code/object/integer.rb', line 2206

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

#code_seventy_five?Boolean

Returns:



2194
2195
2196
# File 'lib/code/object/integer.rb', line 2194

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

#code_seventy_four?Boolean

Returns:



2190
2191
2192
# File 'lib/code/object/integer.rb', line 2190

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

#code_seventy_nine?Boolean

Returns:



2210
2211
2212
# File 'lib/code/object/integer.rb', line 2210

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

#code_seventy_one?Boolean

Returns:



2178
2179
2180
# File 'lib/code/object/integer.rb', line 2178

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

#code_seventy_seven?Boolean

Returns:



2202
2203
2204
# File 'lib/code/object/integer.rb', line 2202

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

#code_seventy_six?Boolean

Returns:



2198
2199
2200
# File 'lib/code/object/integer.rb', line 2198

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

#code_seventy_three?Boolean

Returns:



2186
2187
2188
# File 'lib/code/object/integer.rb', line 2186

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

#code_seventy_two?Boolean

Returns:



2182
2183
2184
# File 'lib/code/object/integer.rb', line 2182

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

#code_six?Boolean

Returns:



1918
1919
1920
# File 'lib/code/object/integer.rb', line 1918

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

#code_sixteen?Boolean

Returns:



1958
1959
1960
# File 'lib/code/object/integer.rb', line 1958

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

#code_sixty?Boolean

Returns:



2134
2135
2136
# File 'lib/code/object/integer.rb', line 2134

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

#code_sixty_eight?Boolean

Returns:



2166
2167
2168
# File 'lib/code/object/integer.rb', line 2166

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

#code_sixty_five?Boolean

Returns:



2154
2155
2156
# File 'lib/code/object/integer.rb', line 2154

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

#code_sixty_four?Boolean

Returns:



2150
2151
2152
# File 'lib/code/object/integer.rb', line 2150

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

#code_sixty_nine?Boolean

Returns:



2170
2171
2172
# File 'lib/code/object/integer.rb', line 2170

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

#code_sixty_one?Boolean

Returns:



2138
2139
2140
# File 'lib/code/object/integer.rb', line 2138

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

#code_sixty_seven?Boolean

Returns:



2162
2163
2164
# File 'lib/code/object/integer.rb', line 2162

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

#code_sixty_six?Boolean

Returns:



2158
2159
2160
# File 'lib/code/object/integer.rb', line 2158

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

#code_sixty_three?Boolean

Returns:



2146
2147
2148
# File 'lib/code/object/integer.rb', line 2146

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

#code_sixty_two?Boolean

Returns:



2142
2143
2144
# File 'lib/code/object/integer.rb', line 2142

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

#code_sqrtObject



1740
1741
1742
# File 'lib/code/object/integer.rb', line 1740

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

#code_ten?Boolean

Returns:



1934
1935
1936
# File 'lib/code/object/integer.rb', line 1934

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

#code_thirteen?Boolean

Returns:



1946
1947
1948
# File 'lib/code/object/integer.rb', line 1946

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

#code_thirty?Boolean

Returns:



2014
2015
2016
# File 'lib/code/object/integer.rb', line 2014

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

#code_thirty_eight?Boolean

Returns:



2046
2047
2048
# File 'lib/code/object/integer.rb', line 2046

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

#code_thirty_five?Boolean

Returns:



2034
2035
2036
# File 'lib/code/object/integer.rb', line 2034

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

#code_thirty_four?Boolean

Returns:



2030
2031
2032
# File 'lib/code/object/integer.rb', line 2030

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

#code_thirty_nine?Boolean

Returns:



2050
2051
2052
# File 'lib/code/object/integer.rb', line 2050

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

#code_thirty_one?Boolean

Returns:



2018
2019
2020
# File 'lib/code/object/integer.rb', line 2018

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

#code_thirty_seven?Boolean

Returns:



2042
2043
2044
# File 'lib/code/object/integer.rb', line 2042

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

#code_thirty_six?Boolean

Returns:



2038
2039
2040
# File 'lib/code/object/integer.rb', line 2038

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

#code_thirty_three?Boolean

Returns:



2026
2027
2028
# File 'lib/code/object/integer.rb', line 2026

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

#code_thirty_two?Boolean

Returns:



2022
2023
2024
# File 'lib/code/object/integer.rb', line 2022

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

#code_three?Boolean

Returns:



1906
1907
1908
# File 'lib/code/object/integer.rb', line 1906

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

#code_times(argument, **globals) ⇒ Object



1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
# File 'lib/code/object/integer.rb', line 1752

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
    )
  rescue Error::Next => e
    e.code_value
  end

  self
rescue Error::Break => e
  e.code_value
end

#code_to_decimalObject



1744
1745
1746
# File 'lib/code/object/integer.rb', line 1744

def code_to_decimal
  Decimal.new(raw)
end

#code_to_integerObject



1748
1749
1750
# File 'lib/code/object/integer.rb', line 1748

def code_to_integer
  Integer.new(raw)
end

#code_truncate(n = nil) ⇒ Object



1811
1812
1813
1814
1815
1816
# File 'lib/code/object/integer.rb', line 1811

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:



1942
1943
1944
# File 'lib/code/object/integer.rb', line 1942

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

#code_twenty?Boolean

Returns:



1974
1975
1976
# File 'lib/code/object/integer.rb', line 1974

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

#code_twenty_eight?Boolean

Returns:



2006
2007
2008
# File 'lib/code/object/integer.rb', line 2006

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

#code_twenty_five?Boolean

Returns:



1994
1995
1996
# File 'lib/code/object/integer.rb', line 1994

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

#code_twenty_four?Boolean

Returns:



1990
1991
1992
# File 'lib/code/object/integer.rb', line 1990

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

#code_twenty_nine?Boolean

Returns:



2010
2011
2012
# File 'lib/code/object/integer.rb', line 2010

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

#code_twenty_one?Boolean

Returns:



1978
1979
1980
# File 'lib/code/object/integer.rb', line 1978

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

#code_twenty_seven?Boolean

Returns:



2002
2003
2004
# File 'lib/code/object/integer.rb', line 2002

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

#code_twenty_six?Boolean

Returns:



1998
1999
2000
# File 'lib/code/object/integer.rb', line 1998

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

#code_twenty_three?Boolean

Returns:



1986
1987
1988
# File 'lib/code/object/integer.rb', line 1986

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

#code_twenty_two?Boolean

Returns:



1982
1983
1984
# File 'lib/code/object/integer.rb', line 1982

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

#code_two?Boolean

Returns:



1902
1903
1904
# File 'lib/code/object/integer.rb', line 1902

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

#code_unary_minusObject



1818
1819
1820
# File 'lib/code/object/integer.rb', line 1818

def code_unary_minus
  Integer.new(-raw)
end

#code_up_to(value, function, **globals) ⇒ Object



1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
# File 'lib/code/object/integer.rb', line 1790

def code_up_to(value, function, **globals)
  code_value = value.to_code
  code_function = function.to_code

  raw
    .upto(code_value.raw)
    .with_index do |element, index|
      code_function.call(
        arguments:
          List.new([Integer.new(element), Integer.new(index), self]),
        **globals
      )
    rescue Error::Next => e
      e.code_value
    end

  self
rescue Error::Break => e
  e.code_value
end

#code_weeksObject



1846
1847
1848
# File 'lib/code/object/integer.rb', line 1846

def code_weeks
  Duration.new(raw.weeks)
end

#code_yearsObject



1850
1851
1852
# File 'lib/code/object/integer.rb', line 1850

def code_years
  Duration.new(raw.years)
end

#code_zero?Boolean

Returns:



1894
1895
1896
# File 'lib/code/object/integer.rb', line 1894

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