class NamesValidator # Checks that first_name and last_name are within certain length def self.valid_length?(name) name.first_name.length < 20 and name.last_name.length < 10 end # Checks that first_name and last_name have the first character capitalized # capitalize turns HELLO into Hello; hello into Hello; etc def self.valid_case?(name) name.first_name == name.first_name.capitalize and name.last_name == name.last_name.capitalize end def self.non_conforming_method # This method will not be called during validation end end class Name < Validatable attr_accessor :first_name, :last_name # create getters and setters for instance variable name def initialize(first_name, last_name) @first_name, @last_name = first_name, last_name end end
Sunday, September 12, 2010
Subscribe to:
Posts (Atom)