class Asciidoctor::PDF::RomanNumeral
Constants
- BaseDigits
Public Class Methods
Source
# File lib/asciidoctor/pdf/roman_numeral.rb, line 85 def self.int_to_roman value result = [] BaseDigits.keys.reverse_each do |ival| while value >= ival value -= ival result << BaseDigits[ival] end end result.join end
Source
# File lib/asciidoctor/pdf/roman_numeral.rb, line 51 def initialize initial_value, letter_case @integer_value = ::Integer === initial_value ? initial_value : (RomanNumeral.roman_to_int initial_value) @letter_case = letter_case end
Source
# File lib/asciidoctor/pdf/roman_numeral.rb, line 96 def self.roman_to_int value value = value.upcase result = 0 BaseDigits.values.reverse_each do |rval| while value.start_with? rval offset = rval.length value = value[offset..offset] result += BaseDigits.key rval end end result end
Public Instance Methods
Source
# File lib/asciidoctor/pdf/roman_numeral.rb, line 68 def next RomanNumeral.new @integer_value + 1, @letter_case end
Source
# File lib/asciidoctor/pdf/roman_numeral.rb, line 72 def next! @integer_value += 1 self end
Source
# File lib/asciidoctor/pdf/roman_numeral.rb, line 81 def nil_or_empty? false end
Source
# File lib/asciidoctor/pdf/roman_numeral.rb, line 77 def pred RomanNumeral.new @integer_value - 1, @letter_case end
Source
# File lib/asciidoctor/pdf/roman_numeral.rb, line 60 def to_r if (int = @integer_value) < 1 return int.to_s end roman = RomanNumeral.int_to_roman int @letter_case == :lower ? roman.downcase : roman end