Class: Rule
- Inherits:
-
Object
- Object
- Rule
- Defined in:
- lib/Rule.rb
Instance Attribute Summary collapse
-
#length ⇒ Object
Returns the value of attribute length.
-
#max ⇒ Object
Returns the value of attribute max.
-
#min ⇒ Object
Returns the value of attribute min.
-
#type ⇒ Object
Returns the value of attribute type.
-
#types ⇒ Object
Returns the value of attribute types.
-
#values ⇒ Object
Returns the value of attribute values.
Instance Method Summary collapse
-
#add_type(type) ⇒ Object
A parameter can accept multiple input types.
- #add_value(value) ⇒ Object
-
#initialize ⇒ Rule
constructor
A new instance of Rule.
- #is_number? ⇒ Boolean
Constructor Details
#initialize ⇒ Rule
Returns a new instance of Rule.
12 13 14 15 16 17 18 19 20 |
# File 'lib/Rule.rb', line 12 def initialize() @types = Set.new @values = Set.new @min = nil @max = nil @length = nil end |
Instance Attribute Details
#length ⇒ Object
Returns the value of attribute length.
8 9 10 |
# File 'lib/Rule.rb', line 8 def length @length end |
#max ⇒ Object
Returns the value of attribute max.
7 8 9 |
# File 'lib/Rule.rb', line 7 def max @max end |
#min ⇒ Object
Returns the value of attribute min.
6 7 8 |
# File 'lib/Rule.rb', line 6 def min @min end |
#type ⇒ Object
Returns the value of attribute type.
5 6 7 |
# File 'lib/Rule.rb', line 5 def type @type end |
#types ⇒ Object
Returns the value of attribute types.
9 10 11 |
# File 'lib/Rule.rb', line 9 def types @types end |
#values ⇒ Object
Returns the value of attribute values.
10 11 12 |
# File 'lib/Rule.rb', line 10 def values @values end |
Instance Method Details
#add_type(type) ⇒ Object
A parameter can accept multiple input types. Duplicates will not be added to the set.
26 27 28 |
# File 'lib/Rule.rb', line 26 def add_type(type) @types.add(type) end |
#add_value(value) ⇒ Object
30 31 32 |
# File 'lib/Rule.rb', line 30 def add_value(value) @values.add(value) end |
#is_number? ⇒ Boolean
34 35 36 |
# File 'lib/Rule.rb', line 34 def is_number? @types.include? Integer end |