class CiteProc::Number
Constants
- FACTORS
- MAX_ROMAN
Public Class Methods
Source
# File lib/citeproc/number.rb, line 16 def pluralize?(string) /\S[\s,&–-]\S|\df/ === string end
Source
# File lib/citeproc/number.rb, line 22 def romanize(number) number, roman = number.to_i, '' return number unless number > 0 || number < MAX_ROMAN FACTORS.each do |code, factor| count, number = number.divmod(factor) roman << (code * count) end roman end
@param number [#to_i] the number to convert @return [String] roman equivalent of the passed-in number
Public Instance Methods
Source
# File lib/citeproc/number.rb, line 36 def <=>(other) case when other.nil? 1 when numeric? if other.respond_to?(:to_i) to_i <=> other.to_i else nil end when other.is_a?(Variable) || other.is_a?(String) to_s <=> other.to_s else nil end end