Class: Code::Object::Decimal

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

Constant Summary collapse

CLASS_DOCUMENTATION =
{
  name: "Decimal",
  description:
    "represents fractional numbers with arithmetic, rounding, formatting, duration helpers, and numeric predicates.",
  examples: ["Decimal.new(1.5)", "Decimal.new(\"2.5\") + 1", "1.5.days"]
}.freeze
INSTANCE_FUNCTIONS =
{
  "%" => {
    name: "%",
    description: "returns the decimal modulo another number.",
    examples: ["5.5 % 2", "4.0 % 2", "7.5 % 3"]
  },
  "modulo" => {
    name: "modulo",
    description: "returns the decimal modulo another number.",
    examples: %w[5.5.modulo(2) 4.0.modulo(2) 7.5.modulo(3)]
  },
  "&" => {
    name: "&",
    description:
      "returns the bitwise and of the decimal integer value and another number.",
    examples: ["5.5 & 3", "4.0 & 1", "7.0 & 2"]
  },
  "bitwise_and" => {
    name: "bitwise_and",
    description:
      "returns the bitwise and of the decimal integer value and another number.",
    examples: %w[5.5.bitwise_and(3) 4.0.bitwise_and(1) 7.0.bitwise_and(2)]
  },
  "*" => {
    name: "*",
    description: "returns the decimal multiplied by another number.",
    examples: ["2.5 * 2", "1.5 * 3", "4.0 * 2"]
  },
  "multiplication" => {
    name: "multiplication",
    description: "returns the decimal multiplied by another number.",
    examples: %w[
      2.5.multiplication(2)
      1.5.multiplication(3)
      4.0.multiplication(2)
    ]
  },
  "**" => {
    name: "**",
    description: "returns the decimal raised to a power.",
    examples: ["2.5 ** 2", "4.0 ** 2", "9.0 ** 0.5"]
  },
  "power" => {
    name: "power",
    description: "returns the decimal raised to a power.",
    examples: %w[2.5.power(2) 4.0.power(2) 9.0.power(0.5)]
  },
  "+" => {
    name: "+",
    description:
      "returns the decimal itself when unary, adds numbers, or joins other values as text.",
    examples: ["1.5 + 2", "1.5 + 2.5", "+1.5"]
  },
  "plus" => {
    name: "plus",
    description: "adds numbers or joins non-numeric values as text.",
    examples: %w[1.5.plus(2) 1.5.plus(2.5) 1.5.plus(:x)]
  },
  "-" => {
    name: "-",
    description:
      "returns the decimal negated when unary or minus another number.",
    examples: ["5.5 - 1", "5.5 - 2.5", "-5.5"]
  },
  "minus" => {
    name: "minus",
    description: "returns the decimal minus another number.",
    examples: %w[5.5.minus(1) 5.5.minus(2.5) 1.5.minus(3)]
  },
  "/" => {
    name: "/",
    description: "returns the decimal divided by another number.",
    examples: ["5.5 / 2", "4.0 / 2", "7.5 / 3"]
  },
  "division" => {
    name: "division",
    description: "returns the decimal divided by another number.",
    examples: %w[5.5.division(2) 4.0.division(2) 7.5.division(3)]
  },
  "decimal_divide" => {
    name: "decimal_divide",
    description: "returns the decimal divided by another number.",
    examples: %w[
      5.5.decimal_divide(2)
      4.0.decimal_divide(2)
      7.5.decimal_divide(3)
    ]
  },
  "<<" => {
    name: "<<",
    description: "returns the decimal integer value shifted left.",
    examples: ["5.5 << 1", "4.0 << 2", "1.0 << 3"]
  },
  "left_shift" => {
    name: "left_shift",
    description: "returns the decimal integer value shifted left.",
    examples: %w[5.5.left_shift(1) 4.0.left_shift(2) 1.0.left_shift(3)]
  },
  ">>" => {
    name: ">>",
    description: "returns the decimal integer value shifted right.",
    examples: ["5.5 >> 1", "4.0 >> 1", "8.0 >> 2"]
  },
  "right_shift" => {
    name: "right_shift",
    description: "returns the decimal integer value shifted right.",
    examples: %w[5.5.right_shift(1) 4.0.right_shift(1) 8.0.right_shift(2)]
  },
  "^" => {
    name: "^",
    description:
      "returns the bitwise xor of the decimal integer value and another number.",
    examples: ["5.5 ^ 3", "4.0 ^ 1", "7.0 ^ 2"]
  },
  "bitwise_xor" => {
    name: "bitwise_xor",
    description:
      "returns the bitwise xor of the decimal integer value and another number.",
    examples: %w[5.5.bitwise_xor(3) 4.0.bitwise_xor(1) 7.0.bitwise_xor(2)]
  },
  "abs" => {
    name: "abs",
    description: "returns the absolute value of the decimal.",
    examples: %w[-1.5.abs 1.5.abs 0.0.abs]
  },
  "between?" => {
    name: "between?",
    description: "returns whether the decimal is between two bounds.",
    examples: [
      "1.5.between?(1, 2)",
      "3.5.between?(1, 2)",
      "2.0.between?(1.5, 2.5)"
    ]
  },
  "clamp" => {
    name: "clamp",
    description: "returns the decimal constrained between two bounds.",
    examples: ["5.5.clamp(1, 3)", "0.5.clamp(1, 3)", "2.5.clamp(1, 3)"]
  },
  "divide" => {
    name: "divide",
    description:
      "returns integer division of the decimal by another number.",
    examples: %w[5.5.divide(2) 10.5.divide(3) 9.5.divide(2)]
  },
  "divide_modulo" => {
    name: "divide_modulo",
    description: "returns integer division and modulo as a list.",
    examples: %w[
      5.5.divide_modulo(2)
      10.5.divide_modulo(3)
      9.5.divide_modulo(2)
    ]
  },
  "ceil" => {
    name: "ceil",
    description: "returns the decimal rounded up.",
    examples: %w[1.2.ceil 1.234.ceil(2) -1.2.ceil]
  },
  "day" => {
    name: "day",
    description: "returns a duration of this many days.",
    examples: %w[1.5.day 2.0.day 0.5.day]
  },
  "days" => {
    name: "days",
    description: "returns a duration of this many days.",
    examples: %w[1.5.days 2.0.days 0.5.days]
  },
  "floor" => {
    name: "floor",
    description: "returns the decimal rounded down.",
    examples: %w[1.8.floor 1.234.floor(2) -1.2.floor]
  },
  "hour" => {
    name: "hour",
    description: "returns a duration of this many hours.",
    examples: %w[1.5.hour 2.0.hour 0.5.hour]
  },
  "hours" => {
    name: "hours",
    description: "returns a duration of this many hours.",
    examples: %w[1.5.hours 2.0.hours 0.5.hours]
  },
  "minute" => {
    name: "minute",
    description: "returns a duration of this many minutes.",
    examples: %w[1.5.minute 2.0.minute 0.5.minute]
  },
  "minutes" => {
    name: "minutes",
    description: "returns a duration of this many minutes.",
    examples: %w[1.5.minutes 2.0.minutes 0.5.minutes]
  },
  "month" => {
    name: "month",
    description: "returns a duration of this many months.",
    examples: %w[1.5.month 2.0.month 0.5.month]
  },
  "months" => {
    name: "months",
    description: "returns a duration of this many months.",
    examples: %w[1.5.months 2.0.months 0.5.months]
  },
  "next_decimal" => {
    name: "next_decimal",
    description: "alias for next.",
    examples: %w[1.5.next_decimal 0.0.next_decimal -1.5.next_decimal]
  },
  "previous_decimal" => {
    name: "previous_decimal",
    description: "alias for previous.",
    examples: %w[
      1.5.previous_decimal
      0.0.previous_decimal
      -1.5.previous_decimal
    ]
  },
  "round" => {
    name: "round",
    description: "returns the decimal rounded to a precision.",
    examples: %w[1.5.round 1.234.round(2) -1.5.round]
  },
  "second" => {
    name: "second",
    description: "returns a duration of this many seconds.",
    examples: %w[1.5.second 2.0.second 0.5.second]
  },
  "seconds" => {
    name: "seconds",
    description: "returns a duration of this many seconds.",
    examples: %w[1.5.seconds 2.0.seconds 0.5.seconds]
  },
  "sqrt" => {
    name: "sqrt",
    description: "returns the square root of the decimal.",
    examples: %w[4.0.sqrt 9.0.sqrt 2.25.sqrt]
  },
  "truncate" => {
    name: "truncate",
    description: "returns the decimal truncated to a precision.",
    examples: %w[1.9.truncate 1.234.truncate(2) -1.9.truncate]
  },
  "to_fixed" => {
    name: "to_fixed",
    description:
      "returns the decimal formatted with a fixed number of fractional digits.",
    examples: %w[1.5.to_fixed 1.5.to_fixed(2) 1.234.to_fixed(1)]
  },
  "to_precision" => {
    name: "to_precision",
    description:
      "returns the decimal formatted with a fixed number of significant digits.",
    examples: %w[
      1.5.to_precision
      1.234.to_precision(2)
      123.4.to_precision(3)
    ]
  },
  "to_exponential" => {
    name: "to_exponential",
    description:
      "returns the decimal formatted with exponential notation.",
    examples: %w[
      1.5.to_exponential
      1.5.to_exponential(2)
      123.4.to_exponential(1)
    ]
  },
  "week" => {
    name: "week",
    description: "returns a duration of this many weeks.",
    examples: %w[1.5.week 2.0.week 0.5.week]
  },
  "weeks" => {
    name: "weeks",
    description: "returns a duration of this many weeks.",
    examples: %w[1.5.weeks 2.0.weeks 0.5.weeks]
  },
  "year" => {
    name: "year",
    description: "returns a duration of this many years.",
    examples: %w[1.5.year 2.0.year 0.5.year]
  },
  "years" => {
    name: "years",
    description: "returns a duration of this many years.",
    examples: %w[1.5.years 2.0.years 0.5.years]
  },
  "|" => {
    name: "|",
    description:
      "returns the bitwise or of the decimal integer value and another number.",
    examples: ["5.5 | 2", "4.0 | 1", "7.0 | 2"]
  },
  "bitwise_or" => {
    name: "bitwise_or",
    description:
      "returns the bitwise or of the decimal integer value and another number.",
    examples: %w[5.5.bitwise_or(2) 4.0.bitwise_or(1) 7.0.bitwise_or(2)]
  },
  "many?" => {
    name: "many?",
    description: "returns whether the decimal is greater than one.",
    examples: %w[2.0.many? 1.0.many? 0.5.many?]
  },
  "any?" => {
    name: "any?",
    description: "returns whether the decimal is positive.",
    examples: %w[1.0.any? 0.0.any? -1.0.any?]
  },
  "positive?" => {
    name: "positive?",
    description: "returns whether the decimal is positive.",
    examples: %w[1.0.positive? 0.0.positive? -1.0.positive?]
  },
  "negative?" => {
    name: "negative?",
    description: "returns whether the decimal is negative.",
    examples: %w[-1.0.negative? 0.0.negative? 1.0.negative?]
  },
  "next" => {
    name: "next",
    description: "returns the decimal plus one.",
    examples: %w[1.5.next 0.0.next -1.5.next]
  },
  "successor" => {
    name: "successor",
    description: "alias for next.",
    examples: %w[1.5.successor 0.0.successor -1.5.successor]
  },
  "previous" => {
    name: "previous",
    description: "returns the decimal minus one.",
    examples: %w[1.5.previous 0.0.previous -1.5.previous]
  },
  "predecessor" => {
    name: "predecessor",
    description: "alias for previous.",
    examples: %w[1.5.predecessor 0.0.predecessor -1.5.predecessor]
  },
  "remainder" => {
    name: "remainder",
    description:
      "returns the remainder after division by another number.",
    examples: %w[5.5.remainder(2) 10.5.remainder(3) 9.5.remainder(2)]
  },
  "non_zero?" => {
    name: "non_zero?",
    description: "returns whether the decimal is not zero.",
    examples: %w[1.0.non_zero? 0.0.non_zero? -1.0.non_zero?]
  },
  "integer?" => {
    name: "integer?",
    description: "returns whether the decimal has no fractional part.",
    examples: %w[1.0.integer? 1.5.integer? 0.0.integer?]
  },
  "finite?" => {
    name: "finite?",
    description: "returns whether the decimal is finite.",
    examples: %w[1.0.finite? 0.0.finite? -1.0.finite?]
  },
  "infinite?" => {
    name: "infinite?",
    description: "returns whether the decimal is infinite.",
    examples: %w[1.0.infinite? 0.0.infinite? -1.0.infinite?]
  },
  "not_a_number?" => {
    name: "not_a_number?",
    description: "returns whether the decimal is not a number.",
    examples: %w[1.0.not_a_number? 0.0.not_a_number? -1.0.not_a_number?]
  },
  "numerator" => {
    name: "numerator",
    description: "returns the decimal numerator.",
    examples: %w[1.5.numerator 2.0.numerator 0.5.numerator]
  },
  "denominator" => {
    name: "denominator",
    description: "returns the decimal denominator.",
    examples: %w[1.5.denominator 2.0.denominator 0.5.denominator]
  },
  "magnitude" => {
    name: "magnitude",
    description: "returns the absolute value of the decimal.",
    examples: %w[-1.5.magnitude 1.5.magnitude 0.0.magnitude]
  },
  "zero?" => {
    name: "zero?",
    description: "returns whether the decimal is zero.",
    examples: %w[0.0.zero? 1.0.zero? 0.5.zero?]
  },
  "one?" => {
    name: "one?",
    description: "returns whether the decimal is one.",
    examples: %w[1.0.one? 2.0.one? 0.5.one?]
  },
  "two?" => {
    name: "two?",
    description: "returns whether the decimal is two.",
    examples: %w[2.0.two? 3.0.two? 0.5.two?]
  },
  "three?" => {
    name: "three?",
    description: "returns whether the decimal is three.",
    examples: %w[3.0.three? 4.0.three? 0.5.three?]
  },
  "four?" => {
    name: "four?",
    description: "returns whether the decimal is four.",
    examples: %w[4.0.four? 5.0.four? 0.5.four?]
  },
  "five?" => {
    name: "five?",
    description: "returns whether the decimal is five.",
    examples: %w[5.0.five? 6.0.five? 0.5.five?]
  },
  "six?" => {
    name: "six?",
    description: "returns whether the decimal is six.",
    examples: %w[6.0.six? 7.0.six? 0.5.six?]
  },
  "seven?" => {
    name: "seven?",
    description: "returns whether the decimal is seven.",
    examples: %w[7.0.seven? 8.0.seven? 0.5.seven?]
  },
  "eight?" => {
    name: "eight?",
    description: "returns whether the decimal is eight.",
    examples: %w[8.0.eight? 9.0.eight? 0.5.eight?]
  },
  "nine?" => {
    name: "nine?",
    description: "returns whether the decimal is nine.",
    examples: %w[9.0.nine? 10.0.nine? 0.5.nine?]
  },
  "ten?" => {
    name: "ten?",
    description: "returns whether the decimal is ten.",
    examples: %w[10.0.ten? 11.0.ten? 0.5.ten?]
  },
  "eleven?" => {
    name: "eleven?",
    description: "returns whether the decimal is eleven.",
    examples: %w[11.0.eleven? 12.0.eleven? 0.5.eleven?]
  },
  "twelve?" => {
    name: "twelve?",
    description: "returns whether the decimal is twelve.",
    examples: %w[12.0.twelve? 13.0.twelve? 0.5.twelve?]
  },
  "thirteen?" => {
    name: "thirteen?",
    description: "returns whether the decimal is thirteen.",
    examples: %w[13.0.thirteen? 14.0.thirteen? 0.5.thirteen?]
  },
  "fourteen?" => {
    name: "fourteen?",
    description: "returns whether the decimal is fourteen.",
    examples: %w[14.0.fourteen? 15.0.fourteen? 0.5.fourteen?]
  },
  "fifteen?" => {
    name: "fifteen?",
    description: "returns whether the decimal is fifteen.",
    examples: %w[15.0.fifteen? 16.0.fifteen? 0.5.fifteen?]
  },
  "sixteen?" => {
    name: "sixteen?",
    description: "returns whether the decimal is sixteen.",
    examples: %w[16.0.sixteen? 17.0.sixteen? 0.5.sixteen?]
  },
  "seventeen?" => {
    name: "seventeen?",
    description: "returns whether the decimal is seventeen.",
    examples: %w[17.0.seventeen? 18.0.seventeen? 0.5.seventeen?]
  },
  "eighteen?" => {
    name: "eighteen?",
    description: "returns whether the decimal is eighteen.",
    examples: %w[18.0.eighteen? 19.0.eighteen? 0.5.eighteen?]
  },
  "nineteen?" => {
    name: "nineteen?",
    description: "returns whether the decimal is nineteen.",
    examples: %w[19.0.nineteen? 20.0.nineteen? 0.5.nineteen?]
  },
  "twenty?" => {
    name: "twenty?",
    description: "returns whether the decimal is twenty.",
    examples: %w[20.0.twenty? 21.0.twenty? 0.5.twenty?]
  },
  "twenty_one?" => {
    name: "twenty_one?",
    description: "returns whether the decimal is twenty one.",
    examples: %w[21.0.twenty_one? 22.0.twenty_one? 0.5.twenty_one?]
  },
  "twenty_two?" => {
    name: "twenty_two?",
    description: "returns whether the decimal is twenty two.",
    examples: %w[22.0.twenty_two? 23.0.twenty_two? 0.5.twenty_two?]
  },
  "twenty_three?" => {
    name: "twenty_three?",
    description: "returns whether the decimal is twenty three.",
    examples: %w[23.0.twenty_three? 24.0.twenty_three? 0.5.twenty_three?]
  },
  "twenty_four?" => {
    name: "twenty_four?",
    description: "returns whether the decimal is twenty four.",
    examples: %w[24.0.twenty_four? 25.0.twenty_four? 0.5.twenty_four?]
  },
  "twenty_five?" => {
    name: "twenty_five?",
    description: "returns whether the decimal is twenty five.",
    examples: %w[25.0.twenty_five? 26.0.twenty_five? 0.5.twenty_five?]
  },
  "twenty_six?" => {
    name: "twenty_six?",
    description: "returns whether the decimal is twenty six.",
    examples: %w[26.0.twenty_six? 27.0.twenty_six? 0.5.twenty_six?]
  },
  "twenty_seven?" => {
    name: "twenty_seven?",
    description: "returns whether the decimal is twenty seven.",
    examples: %w[27.0.twenty_seven? 28.0.twenty_seven? 0.5.twenty_seven?]
  },
  "twenty_eight?" => {
    name: "twenty_eight?",
    description: "returns whether the decimal is twenty eight.",
    examples: %w[28.0.twenty_eight? 29.0.twenty_eight? 0.5.twenty_eight?]
  },
  "twenty_nine?" => {
    name: "twenty_nine?",
    description: "returns whether the decimal is twenty nine.",
    examples: %w[29.0.twenty_nine? 30.0.twenty_nine? 0.5.twenty_nine?]
  },
  "thirty?" => {
    name: "thirty?",
    description: "returns whether the decimal is thirty.",
    examples: %w[30.0.thirty? 31.0.thirty? 0.5.thirty?]
  },
  "thirty_one?" => {
    name: "thirty_one?",
    description: "returns whether the decimal is thirty one.",
    examples: %w[31.0.thirty_one? 32.0.thirty_one? 0.5.thirty_one?]
  },
  "thirty_two?" => {
    name: "thirty_two?",
    description: "returns whether the decimal is thirty two.",
    examples: %w[32.0.thirty_two? 33.0.thirty_two? 0.5.thirty_two?]
  },
  "thirty_three?" => {
    name: "thirty_three?",
    description: "returns whether the decimal is thirty three.",
    examples: %w[33.0.thirty_three? 34.0.thirty_three? 0.5.thirty_three?]
  },
  "thirty_four?" => {
    name: "thirty_four?",
    description: "returns whether the decimal is thirty four.",
    examples: %w[34.0.thirty_four? 35.0.thirty_four? 0.5.thirty_four?]
  },
  "thirty_five?" => {
    name: "thirty_five?",
    description: "returns whether the decimal is thirty five.",
    examples: %w[35.0.thirty_five? 36.0.thirty_five? 0.5.thirty_five?]
  },
  "thirty_six?" => {
    name: "thirty_six?",
    description: "returns whether the decimal is thirty six.",
    examples: %w[36.0.thirty_six? 37.0.thirty_six? 0.5.thirty_six?]
  },
  "thirty_seven?" => {
    name: "thirty_seven?",
    description: "returns whether the decimal is thirty seven.",
    examples: %w[37.0.thirty_seven? 38.0.thirty_seven? 0.5.thirty_seven?]
  },
  "thirty_eight?" => {
    name: "thirty_eight?",
    description: "returns whether the decimal is thirty eight.",
    examples: %w[38.0.thirty_eight? 39.0.thirty_eight? 0.5.thirty_eight?]
  },
  "thirty_nine?" => {
    name: "thirty_nine?",
    description: "returns whether the decimal is thirty nine.",
    examples: %w[39.0.thirty_nine? 40.0.thirty_nine? 0.5.thirty_nine?]
  },
  "forty?" => {
    name: "forty?",
    description: "returns whether the decimal is forty.",
    examples: %w[40.0.forty? 41.0.forty? 0.5.forty?]
  },
  "forty_one?" => {
    name: "forty_one?",
    description: "returns whether the decimal is forty one.",
    examples: %w[41.0.forty_one? 42.0.forty_one? 0.5.forty_one?]
  },
  "forty_two?" => {
    name: "forty_two?",
    description: "returns whether the decimal is forty two.",
    examples: %w[42.0.forty_two? 43.0.forty_two? 0.5.forty_two?]
  },
  "forty_three?" => {
    name: "forty_three?",
    description: "returns whether the decimal is forty three.",
    examples: %w[43.0.forty_three? 44.0.forty_three? 0.5.forty_three?]
  },
  "forty_four?" => {
    name: "forty_four?",
    description: "returns whether the decimal is forty four.",
    examples: %w[44.0.forty_four? 45.0.forty_four? 0.5.forty_four?]
  },
  "forty_five?" => {
    name: "forty_five?",
    description: "returns whether the decimal is forty five.",
    examples: %w[45.0.forty_five? 46.0.forty_five? 0.5.forty_five?]
  },
  "forty_six?" => {
    name: "forty_six?",
    description: "returns whether the decimal is forty six.",
    examples: %w[46.0.forty_six? 47.0.forty_six? 0.5.forty_six?]
  },
  "forty_seven?" => {
    name: "forty_seven?",
    description: "returns whether the decimal is forty seven.",
    examples: %w[47.0.forty_seven? 48.0.forty_seven? 0.5.forty_seven?]
  },
  "forty_eight?" => {
    name: "forty_eight?",
    description: "returns whether the decimal is forty eight.",
    examples: %w[48.0.forty_eight? 49.0.forty_eight? 0.5.forty_eight?]
  },
  "forty_nine?" => {
    name: "forty_nine?",
    description: "returns whether the decimal is forty nine.",
    examples: %w[49.0.forty_nine? 50.0.forty_nine? 0.5.forty_nine?]
  },
  "fifty?" => {
    name: "fifty?",
    description: "returns whether the decimal is fifty.",
    examples: %w[50.0.fifty? 51.0.fifty? 0.5.fifty?]
  },
  "fifty_one?" => {
    name: "fifty_one?",
    description: "returns whether the decimal is fifty one.",
    examples: %w[51.0.fifty_one? 52.0.fifty_one? 0.5.fifty_one?]
  },
  "fifty_two?" => {
    name: "fifty_two?",
    description: "returns whether the decimal is fifty two.",
    examples: %w[52.0.fifty_two? 53.0.fifty_two? 0.5.fifty_two?]
  },
  "fifty_three?" => {
    name: "fifty_three?",
    description: "returns whether the decimal is fifty three.",
    examples: %w[53.0.fifty_three? 54.0.fifty_three? 0.5.fifty_three?]
  },
  "fifty_four?" => {
    name: "fifty_four?",
    description: "returns whether the decimal is fifty four.",
    examples: %w[54.0.fifty_four? 55.0.fifty_four? 0.5.fifty_four?]
  },
  "fifty_five?" => {
    name: "fifty_five?",
    description: "returns whether the decimal is fifty five.",
    examples: %w[55.0.fifty_five? 56.0.fifty_five? 0.5.fifty_five?]
  },
  "fifty_six?" => {
    name: "fifty_six?",
    description: "returns whether the decimal is fifty six.",
    examples: %w[56.0.fifty_six? 57.0.fifty_six? 0.5.fifty_six?]
  },
  "fifty_seven?" => {
    name: "fifty_seven?",
    description: "returns whether the decimal is fifty seven.",
    examples: %w[57.0.fifty_seven? 58.0.fifty_seven? 0.5.fifty_seven?]
  },
  "fifty_eight?" => {
    name: "fifty_eight?",
    description: "returns whether the decimal is fifty eight.",
    examples: %w[58.0.fifty_eight? 59.0.fifty_eight? 0.5.fifty_eight?]
  },
  "fifty_nine?" => {
    name: "fifty_nine?",
    description: "returns whether the decimal is fifty nine.",
    examples: %w[59.0.fifty_nine? 60.0.fifty_nine? 0.5.fifty_nine?]
  },
  "sixty?" => {
    name: "sixty?",
    description: "returns whether the decimal is sixty.",
    examples: %w[60.0.sixty? 61.0.sixty? 0.5.sixty?]
  },
  "sixty_one?" => {
    name: "sixty_one?",
    description: "returns whether the decimal is sixty one.",
    examples: %w[61.0.sixty_one? 62.0.sixty_one? 0.5.sixty_one?]
  },
  "sixty_two?" => {
    name: "sixty_two?",
    description: "returns whether the decimal is sixty two.",
    examples: %w[62.0.sixty_two? 63.0.sixty_two? 0.5.sixty_two?]
  },
  "sixty_three?" => {
    name: "sixty_three?",
    description: "returns whether the decimal is sixty three.",
    examples: %w[63.0.sixty_three? 64.0.sixty_three? 0.5.sixty_three?]
  },
  "sixty_four?" => {
    name: "sixty_four?",
    description: "returns whether the decimal is sixty four.",
    examples: %w[64.0.sixty_four? 65.0.sixty_four? 0.5.sixty_four?]
  },
  "sixty_five?" => {
    name: "sixty_five?",
    description: "returns whether the decimal is sixty five.",
    examples: %w[65.0.sixty_five? 66.0.sixty_five? 0.5.sixty_five?]
  },
  "sixty_six?" => {
    name: "sixty_six?",
    description: "returns whether the decimal is sixty six.",
    examples: %w[66.0.sixty_six? 67.0.sixty_six? 0.5.sixty_six?]
  },
  "sixty_seven?" => {
    name: "sixty_seven?",
    description: "returns whether the decimal is sixty seven.",
    examples: %w[67.0.sixty_seven? 68.0.sixty_seven? 0.5.sixty_seven?]
  },
  "sixty_eight?" => {
    name: "sixty_eight?",
    description: "returns whether the decimal is sixty eight.",
    examples: %w[68.0.sixty_eight? 69.0.sixty_eight? 0.5.sixty_eight?]
  },
  "sixty_nine?" => {
    name: "sixty_nine?",
    description: "returns whether the decimal is sixty nine.",
    examples: %w[69.0.sixty_nine? 70.0.sixty_nine? 0.5.sixty_nine?]
  },
  "seventy?" => {
    name: "seventy?",
    description: "returns whether the decimal is seventy.",
    examples: %w[70.0.seventy? 71.0.seventy? 0.5.seventy?]
  },
  "seventy_one?" => {
    name: "seventy_one?",
    description: "returns whether the decimal is seventy one.",
    examples: %w[71.0.seventy_one? 72.0.seventy_one? 0.5.seventy_one?]
  },
  "seventy_two?" => {
    name: "seventy_two?",
    description: "returns whether the decimal is seventy two.",
    examples: %w[72.0.seventy_two? 73.0.seventy_two? 0.5.seventy_two?]
  },
  "seventy_three?" => {
    name: "seventy_three?",
    description: "returns whether the decimal is seventy three.",
    examples: %w[
      73.0.seventy_three?
      74.0.seventy_three?
      0.5.seventy_three?
    ]
  },
  "seventy_four?" => {
    name: "seventy_four?",
    description: "returns whether the decimal is seventy four.",
    examples: %w[74.0.seventy_four? 75.0.seventy_four? 0.5.seventy_four?]
  },
  "seventy_five?" => {
    name: "seventy_five?",
    description: "returns whether the decimal is seventy five.",
    examples: %w[75.0.seventy_five? 76.0.seventy_five? 0.5.seventy_five?]
  },
  "seventy_six?" => {
    name: "seventy_six?",
    description: "returns whether the decimal is seventy six.",
    examples: %w[76.0.seventy_six? 77.0.seventy_six? 0.5.seventy_six?]
  },
  "seventy_seven?" => {
    name: "seventy_seven?",
    description: "returns whether the decimal is seventy seven.",
    examples: %w[
      77.0.seventy_seven?
      78.0.seventy_seven?
      0.5.seventy_seven?
    ]
  },
  "seventy_eight?" => {
    name: "seventy_eight?",
    description: "returns whether the decimal is seventy eight.",
    examples: %w[
      78.0.seventy_eight?
      79.0.seventy_eight?
      0.5.seventy_eight?
    ]
  },
  "seventy_nine?" => {
    name: "seventy_nine?",
    description: "returns whether the decimal is seventy nine.",
    examples: %w[79.0.seventy_nine? 80.0.seventy_nine? 0.5.seventy_nine?]
  },
  "eighty?" => {
    name: "eighty?",
    description: "returns whether the decimal is eighty.",
    examples: %w[80.0.eighty? 81.0.eighty? 0.5.eighty?]
  },
  "eighty_one?" => {
    name: "eighty_one?",
    description: "returns whether the decimal is eighty one.",
    examples: %w[81.0.eighty_one? 82.0.eighty_one? 0.5.eighty_one?]
  },
  "eighty_two?" => {
    name: "eighty_two?",
    description: "returns whether the decimal is eighty two.",
    examples: %w[82.0.eighty_two? 83.0.eighty_two? 0.5.eighty_two?]
  },
  "eighty_three?" => {
    name: "eighty_three?",
    description: "returns whether the decimal is eighty three.",
    examples: %w[83.0.eighty_three? 84.0.eighty_three? 0.5.eighty_three?]
  },
  "eighty_four?" => {
    name: "eighty_four?",
    description: "returns whether the decimal is eighty four.",
    examples: %w[84.0.eighty_four? 85.0.eighty_four? 0.5.eighty_four?]
  },
  "eighty_five?" => {
    name: "eighty_five?",
    description: "returns whether the decimal is eighty five.",
    examples: %w[85.0.eighty_five? 86.0.eighty_five? 0.5.eighty_five?]
  },
  "eighty_six?" => {
    name: "eighty_six?",
    description: "returns whether the decimal is eighty six.",
    examples: %w[86.0.eighty_six? 87.0.eighty_six? 0.5.eighty_six?]
  },
  "eighty_seven?" => {
    name: "eighty_seven?",
    description: "returns whether the decimal is eighty seven.",
    examples: %w[87.0.eighty_seven? 88.0.eighty_seven? 0.5.eighty_seven?]
  },
  "eighty_eight?" => {
    name: "eighty_eight?",
    description: "returns whether the decimal is eighty eight.",
    examples: %w[88.0.eighty_eight? 89.0.eighty_eight? 0.5.eighty_eight?]
  },
  "eighty_nine?" => {
    name: "eighty_nine?",
    description: "returns whether the decimal is eighty nine.",
    examples: %w[89.0.eighty_nine? 90.0.eighty_nine? 0.5.eighty_nine?]
  },
  "ninety?" => {
    name: "ninety?",
    description: "returns whether the decimal is ninety.",
    examples: %w[90.0.ninety? 91.0.ninety? 0.5.ninety?]
  },
  "ninety_one?" => {
    name: "ninety_one?",
    description: "returns whether the decimal is ninety one.",
    examples: %w[91.0.ninety_one? 92.0.ninety_one? 0.5.ninety_one?]
  },
  "ninety_two?" => {
    name: "ninety_two?",
    description: "returns whether the decimal is ninety two.",
    examples: %w[92.0.ninety_two? 93.0.ninety_two? 0.5.ninety_two?]
  },
  "ninety_three?" => {
    name: "ninety_three?",
    description: "returns whether the decimal is ninety three.",
    examples: %w[93.0.ninety_three? 94.0.ninety_three? 0.5.ninety_three?]
  },
  "ninety_four?" => {
    name: "ninety_four?",
    description: "returns whether the decimal is ninety four.",
    examples: %w[94.0.ninety_four? 95.0.ninety_four? 0.5.ninety_four?]
  },
  "ninety_five?" => {
    name: "ninety_five?",
    description: "returns whether the decimal is ninety five.",
    examples: %w[95.0.ninety_five? 96.0.ninety_five? 0.5.ninety_five?]
  },
  "ninety_six?" => {
    name: "ninety_six?",
    description: "returns whether the decimal is ninety six.",
    examples: %w[96.0.ninety_six? 97.0.ninety_six? 0.5.ninety_six?]
  },
  "ninety_seven?" => {
    name: "ninety_seven?",
    description: "returns whether the decimal is ninety seven.",
    examples: %w[97.0.ninety_seven? 98.0.ninety_seven? 0.5.ninety_seven?]
  },
  "ninety_eight?" => {
    name: "ninety_eight?",
    description: "returns whether the decimal is ninety eight.",
    examples: %w[98.0.ninety_eight? 99.0.ninety_eight? 0.5.ninety_eight?]
  },
  "ninety_nine?" => {
    name: "ninety_nine?",
    description: "returns whether the decimal is ninety nine.",
    examples: %w[99.0.ninety_nine? 100.0.ninety_nine? 0.5.ninety_nine?]
  },
  "one_hundred?" => {
    name: "one_hundred?",
    description: "returns whether the decimal is one hundred.",
    examples: %w[100.0.one_hundred? 101.0.one_hundred? 0.5.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_decimal, #code_to_dictionary, #code_to_duration, #code_to_integer, #code_to_json, #code_to_list, #code_to_nothing, #code_to_parameter, #code_to_range, #code_to_time, #code_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) ⇒ Decimal

Returns a new instance of Decimal.



924
925
926
927
928
929
930
931
932
933
934
935
936
937
# File 'lib/code/object/decimal.rb', line 924

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

Class Method Details

.function_documentation(scope) ⇒ Object



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

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

  {}
end

Instance Method Details

#call(**args) ⇒ Object



939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
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
# File 'lib/code/object/decimal.rb', line 939

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

  case code_operator.to_s
  when "%", "modulo"
    sig(args) { Integer | Decimal }
    code_modulo(code_value)
  when "&", "bitwise_and"
    sig(args) { Integer | Decimal }
    code_bitwise_and(code_value)
  when "*", "multiplication"
    sig(args) { Integer | Decimal }
    code_multiplication(code_value)
  when "**", "power"
    sig(args) { Integer | Decimal }
    code_power(code_value)
  when "+", "plus"
    sig(args) { Object.maybe }
    code_arguments.any? ? code_plus(code_value) : self
  when "-", "minus"
    sig(args) { (Integer | Decimal).maybe }
    code_arguments.any? ? code_minus(code_value) : code_unary_minus
  when "/", "division"
    sig(args) { Integer | Decimal }
    code_division(code_value)
  when "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 "<<", "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 "clamp"
    sig(args) { [Integer | Decimal, Integer | Decimal] }
    code_clamp(*code_arguments.raw)
  when "day", "days"
    sig(args)
    code_days
  when "floor"
    sig(args) { Integer.maybe }
    code_floor(code_value)
  when "hour", "hours"
    sig(args)
    code_hours
  when "minute", "minutes"
    sig(args)
    code_minutes
  when "month", "months"
    sig(args)
    code_months
  when "next", "successor"
    sig(args)
    code_next
  when "next_decimal"
    sig(args)
    code_next_decimal
  when "previous", "predecessor"
    sig(args)
    code_previous
  when "previous_decimal"
    sig(args)
    code_previous_decimal
  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 "truncate"
    sig(args) { Integer.maybe }
    code_truncate(code_value)
  when "to_fixed"
    sig(args) { Integer.maybe }
    code_to_fixed(code_value)
  when "to_precision"
    sig(args) { Integer.maybe }
    code_to_precision(code_value)
  when "to_exponential"
    sig(args) { Integer.maybe }
    code_to_exponential(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 "not_a_number?"
    sig(args)
    code_not_a_number?
  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



1400
1401
1402
# File 'lib/code/object/decimal.rb', line 1400

def code_abs
  Decimal.new(raw.abs)
end

#code_any?Boolean

Returns:



1576
1577
1578
# File 'lib/code/object/decimal.rb', line 1576

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

#code_bitwise_and(other) ⇒ Object



1404
1405
1406
1407
1408
# File 'lib/code/object/decimal.rb', line 1404

def code_bitwise_and(other)
  code_other = other.to_code

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

#code_bitwise_or(other) ⇒ Object



1410
1411
1412
1413
1414
# File 'lib/code/object/decimal.rb', line 1410

def code_bitwise_or(other)
  code_other = other.to_code

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

#code_bitwise_xor(other) ⇒ Object



1416
1417
1418
1419
1420
# File 'lib/code/object/decimal.rb', line 1416

def code_bitwise_xor(other)
  code_other = other.to_code

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

#code_ceil(n = nil) ⇒ Object



1422
1423
1424
1425
1426
1427
# File 'lib/code/object/decimal.rb', line 1422

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

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

#code_daysObject



1446
1447
1448
# File 'lib/code/object/decimal.rb', line 1446

def code_days
  Duration.new(raw.days)
end

#code_decimal_divide(other) ⇒ Object



1435
1436
1437
# File 'lib/code/object/decimal.rb', line 1435

def code_decimal_divide(other)
  code_division(other)
end

#code_denominatorObject



1620
1621
1622
# File 'lib/code/object/decimal.rb', line 1620

def code_denominator
  Integer.new(raw.to_r.denominator)
end

#code_division(other) ⇒ Object



1429
1430
1431
1432
1433
# File 'lib/code/object/decimal.rb', line 1429

def code_division(other)
  code_other = other.to_code

  Decimal.new(raw / code_other.raw)
end

#code_eight?Boolean

Returns:



1660
1661
1662
# File 'lib/code/object/decimal.rb', line 1660

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

#code_eighteen?Boolean

Returns:



1700
1701
1702
# File 'lib/code/object/decimal.rb', line 1700

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

#code_eighty?Boolean

Returns:



1948
1949
1950
# File 'lib/code/object/decimal.rb', line 1948

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

#code_eighty_eight?Boolean

Returns:



1980
1981
1982
# File 'lib/code/object/decimal.rb', line 1980

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

#code_eighty_five?Boolean

Returns:



1968
1969
1970
# File 'lib/code/object/decimal.rb', line 1968

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

#code_eighty_four?Boolean

Returns:



1964
1965
1966
# File 'lib/code/object/decimal.rb', line 1964

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

#code_eighty_nine?Boolean

Returns:



1984
1985
1986
# File 'lib/code/object/decimal.rb', line 1984

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

#code_eighty_one?Boolean

Returns:



1952
1953
1954
# File 'lib/code/object/decimal.rb', line 1952

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

#code_eighty_seven?Boolean

Returns:



1976
1977
1978
# File 'lib/code/object/decimal.rb', line 1976

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

#code_eighty_six?Boolean

Returns:



1972
1973
1974
# File 'lib/code/object/decimal.rb', line 1972

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

#code_eighty_three?Boolean

Returns:



1960
1961
1962
# File 'lib/code/object/decimal.rb', line 1960

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

#code_eighty_two?Boolean

Returns:



1956
1957
1958
# File 'lib/code/object/decimal.rb', line 1956

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

#code_eleven?Boolean

Returns:



1672
1673
1674
# File 'lib/code/object/decimal.rb', line 1672

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

#code_fifteen?Boolean

Returns:



1688
1689
1690
# File 'lib/code/object/decimal.rb', line 1688

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

#code_fifty?Boolean

Returns:



1828
1829
1830
# File 'lib/code/object/decimal.rb', line 1828

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

#code_fifty_eight?Boolean

Returns:



1860
1861
1862
# File 'lib/code/object/decimal.rb', line 1860

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

#code_fifty_five?Boolean

Returns:



1848
1849
1850
# File 'lib/code/object/decimal.rb', line 1848

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

#code_fifty_four?Boolean

Returns:



1844
1845
1846
# File 'lib/code/object/decimal.rb', line 1844

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

#code_fifty_nine?Boolean

Returns:



1864
1865
1866
# File 'lib/code/object/decimal.rb', line 1864

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

#code_fifty_one?Boolean

Returns:



1832
1833
1834
# File 'lib/code/object/decimal.rb', line 1832

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

#code_fifty_seven?Boolean

Returns:



1856
1857
1858
# File 'lib/code/object/decimal.rb', line 1856

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

#code_fifty_six?Boolean

Returns:



1852
1853
1854
# File 'lib/code/object/decimal.rb', line 1852

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

#code_fifty_three?Boolean

Returns:



1840
1841
1842
# File 'lib/code/object/decimal.rb', line 1840

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

#code_fifty_two?Boolean

Returns:



1836
1837
1838
# File 'lib/code/object/decimal.rb', line 1836

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

#code_finite?Boolean

Returns:



1604
1605
1606
# File 'lib/code/object/decimal.rb', line 1604

def code_finite?
  Boolean.new(raw.finite?)
end

#code_five?Boolean

Returns:



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

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

#code_floor(n = nil) ⇒ Object



1439
1440
1441
1442
1443
1444
# File 'lib/code/object/decimal.rb', line 1439

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

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

#code_forty?Boolean

Returns:



1788
1789
1790
# File 'lib/code/object/decimal.rb', line 1788

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

#code_forty_eight?Boolean

Returns:



1820
1821
1822
# File 'lib/code/object/decimal.rb', line 1820

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

#code_forty_five?Boolean

Returns:



1808
1809
1810
# File 'lib/code/object/decimal.rb', line 1808

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

#code_forty_four?Boolean

Returns:



1804
1805
1806
# File 'lib/code/object/decimal.rb', line 1804

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

#code_forty_nine?Boolean

Returns:



1824
1825
1826
# File 'lib/code/object/decimal.rb', line 1824

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

#code_forty_one?Boolean

Returns:



1792
1793
1794
# File 'lib/code/object/decimal.rb', line 1792

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

#code_forty_seven?Boolean

Returns:



1816
1817
1818
# File 'lib/code/object/decimal.rb', line 1816

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

#code_forty_six?Boolean

Returns:



1812
1813
1814
# File 'lib/code/object/decimal.rb', line 1812

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

#code_forty_three?Boolean

Returns:



1800
1801
1802
# File 'lib/code/object/decimal.rb', line 1800

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

#code_forty_two?Boolean

Returns:



1796
1797
1798
# File 'lib/code/object/decimal.rb', line 1796

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

#code_four?Boolean

Returns:



1644
1645
1646
# File 'lib/code/object/decimal.rb', line 1644

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

#code_fourteen?Boolean

Returns:



1684
1685
1686
# File 'lib/code/object/decimal.rb', line 1684

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

#code_hoursObject



1450
1451
1452
# File 'lib/code/object/decimal.rb', line 1450

def code_hours
  Duration.new(raw.hours)
end

#code_infinite?Boolean

Returns:



1608
1609
1610
# File 'lib/code/object/decimal.rb', line 1608

def code_infinite?
  Boolean.new(!!raw.infinite?)
end

#code_integer?Boolean

Returns:



1600
1601
1602
# File 'lib/code/object/decimal.rb', line 1600

def code_integer?
  Boolean.new(raw.frac.zero?)
end

#code_left_shift(other) ⇒ Object



1474
1475
1476
1477
1478
# File 'lib/code/object/decimal.rb', line 1474

def code_left_shift(other)
  code_other = other.to_code

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

#code_magnitudeObject



1624
1625
1626
# File 'lib/code/object/decimal.rb', line 1624

def code_magnitude
  code_abs
end

#code_many?Boolean

Returns:



1572
1573
1574
# File 'lib/code/object/decimal.rb', line 1572

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

#code_minus(other) ⇒ Object



1480
1481
1482
1483
1484
# File 'lib/code/object/decimal.rb', line 1480

def code_minus(other)
  code_other = other.to_code

  Decimal.new(raw - code_other.raw)
end

#code_minutesObject



1454
1455
1456
# File 'lib/code/object/decimal.rb', line 1454

def code_minutes
  Duration.new(raw.minutes)
end

#code_modulo(other) ⇒ Object



1486
1487
1488
1489
1490
# File 'lib/code/object/decimal.rb', line 1486

def code_modulo(other)
  code_other = other.to_code

  Decimal.new(raw % code_other.raw)
end

#code_monthsObject



1458
1459
1460
# File 'lib/code/object/decimal.rb', line 1458

def code_months
  Duration.new(::ActiveSupport::Duration.months(raw))
end

#code_multiplication(other) ⇒ Object



1492
1493
1494
1495
1496
# File 'lib/code/object/decimal.rb', line 1492

def code_multiplication(other)
  code_other = other.to_code

  Decimal.new(raw * code_other.raw)
end

#code_negative?Boolean

Returns:



1592
1593
1594
# File 'lib/code/object/decimal.rb', line 1592

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

#code_next_decimalObject



1580
1581
1582
# File 'lib/code/object/decimal.rb', line 1580

def code_next_decimal
  code_next
end

#code_nine?Boolean

Returns:



1664
1665
1666
# File 'lib/code/object/decimal.rb', line 1664

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

#code_nineteen?Boolean

Returns:



1704
1705
1706
# File 'lib/code/object/decimal.rb', line 1704

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

#code_ninety?Boolean

Returns:



1988
1989
1990
# File 'lib/code/object/decimal.rb', line 1988

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

#code_ninety_eight?Boolean

Returns:



2020
2021
2022
# File 'lib/code/object/decimal.rb', line 2020

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

#code_ninety_five?Boolean

Returns:



2008
2009
2010
# File 'lib/code/object/decimal.rb', line 2008

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

#code_ninety_four?Boolean

Returns:



2004
2005
2006
# File 'lib/code/object/decimal.rb', line 2004

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

#code_ninety_nine?Boolean

Returns:



2024
2025
2026
# File 'lib/code/object/decimal.rb', line 2024

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

#code_ninety_one?Boolean

Returns:



1992
1993
1994
# File 'lib/code/object/decimal.rb', line 1992

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

#code_ninety_seven?Boolean

Returns:



2016
2017
2018
# File 'lib/code/object/decimal.rb', line 2016

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

#code_ninety_six?Boolean

Returns:



2012
2013
2014
# File 'lib/code/object/decimal.rb', line 2012

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

#code_ninety_three?Boolean

Returns:



2000
2001
2002
# File 'lib/code/object/decimal.rb', line 2000

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

#code_ninety_two?Boolean

Returns:



1996
1997
1998
# File 'lib/code/object/decimal.rb', line 1996

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

#code_non_zero?Boolean

Returns:



1596
1597
1598
# File 'lib/code/object/decimal.rb', line 1596

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

#code_not_a_number?Boolean

Returns:



1612
1613
1614
# File 'lib/code/object/decimal.rb', line 1612

def code_not_a_number?
  Boolean.new(raw.nan?)
end

#code_numeratorObject



1616
1617
1618
# File 'lib/code/object/decimal.rb', line 1616

def code_numerator
  Integer.new(raw.to_r.numerator)
end

#code_one?Boolean

Returns:



1632
1633
1634
# File 'lib/code/object/decimal.rb', line 1632

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

#code_one_hundred?Boolean

Returns:



2028
2029
2030
# File 'lib/code/object/decimal.rb', line 2028

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

#code_plus(other) ⇒ Object



1498
1499
1500
1501
1502
1503
1504
1505
1506
# File 'lib/code/object/decimal.rb', line 1498

def code_plus(other)
  code_other = other.to_code

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

#code_positive?Boolean

Returns:



1588
1589
1590
# File 'lib/code/object/decimal.rb', line 1588

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

#code_power(other) ⇒ Object



1508
1509
1510
1511
1512
# File 'lib/code/object/decimal.rb', line 1508

def code_power(other)
  code_other = other.to_code

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

#code_previous_decimalObject



1584
1585
1586
# File 'lib/code/object/decimal.rb', line 1584

def code_previous_decimal
  code_previous
end

#code_right_shift(other) ⇒ Object



1514
1515
1516
1517
1518
# File 'lib/code/object/decimal.rb', line 1514

def code_right_shift(other)
  code_other = other.to_code

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

#code_round(n = nil) ⇒ Object



1520
1521
1522
1523
1524
1525
# File 'lib/code/object/decimal.rb', line 1520

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

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

#code_secondsObject



1462
1463
1464
# File 'lib/code/object/decimal.rb', line 1462

def code_seconds
  Duration.new(raw.seconds)
end

#code_seven?Boolean

Returns:



1656
1657
1658
# File 'lib/code/object/decimal.rb', line 1656

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

#code_seventeen?Boolean

Returns:



1696
1697
1698
# File 'lib/code/object/decimal.rb', line 1696

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

#code_seventy?Boolean

Returns:



1908
1909
1910
# File 'lib/code/object/decimal.rb', line 1908

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

#code_seventy_eight?Boolean

Returns:



1940
1941
1942
# File 'lib/code/object/decimal.rb', line 1940

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

#code_seventy_five?Boolean

Returns:



1928
1929
1930
# File 'lib/code/object/decimal.rb', line 1928

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

#code_seventy_four?Boolean

Returns:



1924
1925
1926
# File 'lib/code/object/decimal.rb', line 1924

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

#code_seventy_nine?Boolean

Returns:



1944
1945
1946
# File 'lib/code/object/decimal.rb', line 1944

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

#code_seventy_one?Boolean

Returns:



1912
1913
1914
# File 'lib/code/object/decimal.rb', line 1912

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

#code_seventy_seven?Boolean

Returns:



1936
1937
1938
# File 'lib/code/object/decimal.rb', line 1936

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

#code_seventy_six?Boolean

Returns:



1932
1933
1934
# File 'lib/code/object/decimal.rb', line 1932

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

#code_seventy_three?Boolean

Returns:



1920
1921
1922
# File 'lib/code/object/decimal.rb', line 1920

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

#code_seventy_two?Boolean

Returns:



1916
1917
1918
# File 'lib/code/object/decimal.rb', line 1916

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

#code_six?Boolean

Returns:



1652
1653
1654
# File 'lib/code/object/decimal.rb', line 1652

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

#code_sixteen?Boolean

Returns:



1692
1693
1694
# File 'lib/code/object/decimal.rb', line 1692

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

#code_sixty?Boolean

Returns:



1868
1869
1870
# File 'lib/code/object/decimal.rb', line 1868

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

#code_sixty_eight?Boolean

Returns:



1900
1901
1902
# File 'lib/code/object/decimal.rb', line 1900

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

#code_sixty_five?Boolean

Returns:



1888
1889
1890
# File 'lib/code/object/decimal.rb', line 1888

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

#code_sixty_four?Boolean

Returns:



1884
1885
1886
# File 'lib/code/object/decimal.rb', line 1884

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

#code_sixty_nine?Boolean

Returns:



1904
1905
1906
# File 'lib/code/object/decimal.rb', line 1904

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

#code_sixty_one?Boolean

Returns:



1872
1873
1874
# File 'lib/code/object/decimal.rb', line 1872

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

#code_sixty_seven?Boolean

Returns:



1896
1897
1898
# File 'lib/code/object/decimal.rb', line 1896

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

#code_sixty_six?Boolean

Returns:



1892
1893
1894
# File 'lib/code/object/decimal.rb', line 1892

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

#code_sixty_three?Boolean

Returns:



1880
1881
1882
# File 'lib/code/object/decimal.rb', line 1880

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

#code_sixty_two?Boolean

Returns:



1876
1877
1878
# File 'lib/code/object/decimal.rb', line 1876

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

#code_sqrtObject



1527
1528
1529
# File 'lib/code/object/decimal.rb', line 1527

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

#code_ten?Boolean

Returns:



1668
1669
1670
# File 'lib/code/object/decimal.rb', line 1668

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

#code_thirteen?Boolean

Returns:



1680
1681
1682
# File 'lib/code/object/decimal.rb', line 1680

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

#code_thirty?Boolean

Returns:



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

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

#code_thirty_eight?Boolean

Returns:



1780
1781
1782
# File 'lib/code/object/decimal.rb', line 1780

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

#code_thirty_five?Boolean

Returns:



1768
1769
1770
# File 'lib/code/object/decimal.rb', line 1768

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

#code_thirty_four?Boolean

Returns:



1764
1765
1766
# File 'lib/code/object/decimal.rb', line 1764

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

#code_thirty_nine?Boolean

Returns:



1784
1785
1786
# File 'lib/code/object/decimal.rb', line 1784

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

#code_thirty_one?Boolean

Returns:



1752
1753
1754
# File 'lib/code/object/decimal.rb', line 1752

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

#code_thirty_seven?Boolean

Returns:



1776
1777
1778
# File 'lib/code/object/decimal.rb', line 1776

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

#code_thirty_six?Boolean

Returns:



1772
1773
1774
# File 'lib/code/object/decimal.rb', line 1772

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

#code_thirty_three?Boolean

Returns:



1760
1761
1762
# File 'lib/code/object/decimal.rb', line 1760

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

#code_thirty_two?Boolean

Returns:



1756
1757
1758
# File 'lib/code/object/decimal.rb', line 1756

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

#code_three?Boolean

Returns:



1640
1641
1642
# File 'lib/code/object/decimal.rb', line 1640

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

#code_to_exponential(digits = nil) ⇒ Object



1554
1555
1556
1557
1558
1559
# File 'lib/code/object/decimal.rb', line 1554

def code_to_exponential(digits = nil)
  code_digits = digits.to_code
  code_digits = Integer.new(6) if code_digits.nothing?

  String.new(format("%.#{code_digits.raw}e", raw))
end

#code_to_fixed(digits = nil) ⇒ Object



1535
1536
1537
1538
1539
1540
# File 'lib/code/object/decimal.rb', line 1535

def code_to_fixed(digits = nil)
  code_digits = digits.to_code
  code_digits = Integer.new(0) if code_digits.nothing?

  String.new(format("%.#{code_digits.raw}f", raw))
end

#code_to_precision(precision = nil) ⇒ Object



1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
# File 'lib/code/object/decimal.rb', line 1542

def code_to_precision(precision = nil)
  code_precision = precision.to_code
  if code_precision.nothing?
    code_precision =
      Integer.new(
        raw.to_s("F").delete(".-").length
      )
  end

  String.new(format("%.#{code_precision.raw}g", raw))
end

#code_to_stringObject



1531
1532
1533
# File 'lib/code/object/decimal.rb', line 1531

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

#code_truncate(n = nil) ⇒ Object



1561
1562
1563
1564
1565
1566
# File 'lib/code/object/decimal.rb', line 1561

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

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

#code_twelve?Boolean

Returns:



1676
1677
1678
# File 'lib/code/object/decimal.rb', line 1676

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

#code_twenty?Boolean

Returns:



1708
1709
1710
# File 'lib/code/object/decimal.rb', line 1708

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

#code_twenty_eight?Boolean

Returns:



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

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

#code_twenty_five?Boolean

Returns:



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

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

#code_twenty_four?Boolean

Returns:



1724
1725
1726
# File 'lib/code/object/decimal.rb', line 1724

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

#code_twenty_nine?Boolean

Returns:



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

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

#code_twenty_one?Boolean

Returns:



1712
1713
1714
# File 'lib/code/object/decimal.rb', line 1712

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

#code_twenty_seven?Boolean

Returns:



1736
1737
1738
# File 'lib/code/object/decimal.rb', line 1736

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

#code_twenty_six?Boolean

Returns:



1732
1733
1734
# File 'lib/code/object/decimal.rb', line 1732

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

#code_twenty_three?Boolean

Returns:



1720
1721
1722
# File 'lib/code/object/decimal.rb', line 1720

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

#code_twenty_two?Boolean

Returns:



1716
1717
1718
# File 'lib/code/object/decimal.rb', line 1716

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

#code_two?Boolean

Returns:



1636
1637
1638
# File 'lib/code/object/decimal.rb', line 1636

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

#code_unary_minusObject



1568
1569
1570
# File 'lib/code/object/decimal.rb', line 1568

def code_unary_minus
  Decimal.new(-raw)
end

#code_weeksObject



1466
1467
1468
# File 'lib/code/object/decimal.rb', line 1466

def code_weeks
  Duration.new(raw.weeks)
end

#code_yearsObject



1470
1471
1472
# File 'lib/code/object/decimal.rb', line 1470

def code_years
  Duration.new(::ActiveSupport::Duration.years(raw))
end

#code_zero?Boolean

Returns:



1628
1629
1630
# File 'lib/code/object/decimal.rb', line 1628

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