Class: Web::Rule
Instance Attribute Summary collapse
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#malformed ⇒ Object
readonly
Returns the value of attribute malformed.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#regexp ⇒ Object
readonly
Returns the value of attribute regexp.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Rule
constructor
A new instance of Rule.
Constructor Details
#initialize(params = {}) ⇒ Rule
Returns a new instance of Rule.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/web/validate.rb', line 32 def initialize( params = {} ) [:field, :regexp].each do |k| unless params.has_key? k raise ArgumentError.new( "Web::rule is missing required parameter (:#{k})" ) else self.instance_variable_set("@#{k}".intern, params[k] ) end end [:message, :malformed ].each do |k| if params.has_key? k self.instance_variable_set("@#{k}".intern, params[k] ) end end @field = @field.to_s @malformed ||= :continue end |
Instance Attribute Details
#field ⇒ Object (readonly)
Returns the value of attribute field.
31 32 33 |
# File 'lib/web/validate.rb', line 31 def field @field end |
#malformed ⇒ Object (readonly)
Returns the value of attribute malformed.
31 32 33 |
# File 'lib/web/validate.rb', line 31 def malformed @malformed end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
31 32 33 |
# File 'lib/web/validate.rb', line 31 def @message end |
#regexp ⇒ Object (readonly)
Returns the value of attribute regexp.
31 32 33 |
# File 'lib/web/validate.rb', line 31 def regexp @regexp end |