Class: Rule

Inherits:
Object
  • Object
show all
Defined in:
lib/Rule.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRule

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

#lengthObject

Returns the value of attribute length.



8
9
10
# File 'lib/Rule.rb', line 8

def length
  @length
end

#maxObject

Returns the value of attribute max.



7
8
9
# File 'lib/Rule.rb', line 7

def max
  @max
end

#minObject

Returns the value of attribute min.



6
7
8
# File 'lib/Rule.rb', line 6

def min
  @min
end

#typeObject

Returns the value of attribute type.



5
6
7
# File 'lib/Rule.rb', line 5

def type
  @type
end

#typesObject

Returns the value of attribute types.



9
10
11
# File 'lib/Rule.rb', line 9

def types
  @types
end

#valuesObject

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

Returns:

  • (Boolean)


34
35
36
# File 'lib/Rule.rb', line 34

def is_number?
  @types.include? Integer
end