psantos10/Validation

View on GitHub
lib/resize/rules/is_roman.rb

Summary

Maintainability
A
0 mins
Test Coverage
module Resize
  module Validation
    module Rules
      module IsRoman
        private
          def is_valid?(input)
            # Based on Regular Expression Grabbag in the O'Reilly Perl Cookbook, #6.23
            regexp = /^M*(D?C{0,3}|C[DM])(L?X{0,3}|X[LC])(V?I{0,3}|I[VX])$/i
            regexp === input.to_s
          end
      end
    end
  end
end