Sha256: 4d5cdbff83dd2fe71fabbb8696369fdf58753f286dadd38052f156358137c0fe

Contents?: true

Size: 540 Bytes

Versions: 19

Compression:

Stored size: 540 Bytes

Contents

# frozen_string_literal: true

# Monkey patches for +Integer+
#
class Integer
  ROMAN_NUMERALS = %w[0 i ii iii iv v vi vii viii ix x xi xii xiii xiv xv xvi xvii xviii xix xx].freeze

  # Formats as different types of integers, including roman numerals.
  #
  # @return [String]
  #
  def to_format(format)
    case format
    when :arabic
      to_s
    when :roman
      raise 'Unknown conversion to Roman numerals' if self >= ROMAN_NUMERALS.size

      ROMAN_NUMERALS[self]
    else
      raise 'Unknown integer format'
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
openstax_kitchen-16.0.0 lib/kitchen/patches/integer.rb
openstax_kitchen-15.0.0 lib/kitchen/patches/integer.rb
openstax_kitchen-14.0.0 lib/kitchen/patches/integer.rb
openstax_kitchen-13.0.0 lib/kitchen/patches/integer.rb
openstax_kitchen-12.2.0 lib/kitchen/patches/integer.rb
openstax_kitchen-12.1.0 lib/kitchen/patches/integer.rb
openstax_kitchen-12.0.0 lib/kitchen/patches/integer.rb
openstax_kitchen-11.2.0 lib/kitchen/patches/integer.rb
openstax_kitchen-11.1.0 lib/kitchen/patches/integer.rb
openstax_kitchen-11.0.0 lib/kitchen/patches/integer.rb
openstax_kitchen-10.0.0 lib/kitchen/patches/integer.rb
openstax_kitchen-9.2.0 lib/kitchen/patches/integer.rb
openstax_kitchen-9.1.0 lib/kitchen/patches/integer.rb
openstax_kitchen-9.0.0 lib/kitchen/patches/integer.rb
openstax_kitchen-8.0.1 lib/kitchen/patches/integer.rb
openstax_kitchen-8.0.0 lib/kitchen/patches/integer.rb
openstax_kitchen-7.0.0 lib/kitchen/patches/integer.rb
openstax_kitchen-6.1.0 lib/kitchen/patches/integer.rb
openstax_kitchen-6.0.0 lib/kitchen/patches/integer.rb