class R0man::Digit

Constants

C
D
I
Invalid
L
LOOKUP
M
V
X

Attributes

allowed_next_digits[R]
max_consecutive_allowed[R]
name[R]
value[R]

Public Class Methods

parse(letter) click to toggle source
# File lib/r0man/digit.rb, line 63
def parse(letter)
  LOOKUP[letter.upcase] || Invalid.new(letter)
end

Protected Class Methods

new(options) click to toggle source
# File lib/r0man/digit.rb, line 5
def initialize(options)
  @value                   = options[:value]
  @name                    = options[:name]
  @max_consecutive_allowed = options[:max_consecutive_allowed]
  @allowed_next_digits     = options[:allowed_next_digits]
end

Public Instance Methods

allows_next_digit?(other_digit) click to toggle source
# File lib/r0man/digit.rb, line 32
def allows_next_digit?(other_digit)
  allowed_next_digits.include?(other_digit)
end
greater_than?(other_digit) click to toggle source
# File lib/r0man/digit.rb, line 24
def greater_than?(other_digit)
  value > other_digit.value
end
inspect() click to toggle source
# File lib/r0man/digit.rb, line 20
def inspect
  to_s
end
to_s() click to toggle source
# File lib/r0man/digit.rb, line 16
def to_s
  "#{name}(#{value})"
end
valid?() click to toggle source
# File lib/r0man/digit.rb, line 12
def valid?
  true
end
value_compared_to(other_digit) click to toggle source
# File lib/r0man/digit.rb, line 28
def value_compared_to(other_digit)
  other_digit.greater_than?(self) ? -value : value
end