Class: Anodator::InputSpecItem
- Inherits:
-
Object
- Object
- Anodator::InputSpecItem
- Defined in:
- lib/anodator/input_spec_item.rb
Constant Summary collapse
- TYPE_STRING =
"STRING"
- TYPE_NUMERIC =
"NUMERIC"
- TYPE_DATE =
"DATE"
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(number, name, type = TYPE_STRING) ⇒ InputSpecItem
constructor
A new instance of InputSpecItem.
Constructor Details
#initialize(number, name, type = TYPE_STRING) ⇒ InputSpecItem
Returns a new instance of InputSpecItem.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/anodator/input_spec_item.rb', line 9 def initialize(number, name, type = TYPE_STRING) if number.nil? || number.to_s.split(//).size.zero? raise ArgumentError.new("number cannot be blank") end if name.nil? || name.to_s.split(//).size.zero? raise ArgumentError.new("name cannot be blank") end unless [TYPE_STRING, TYPE_NUMERIC, TYPE_DATE].include?(type) raise ArgumentError.new("unknown data type '#{type}'") end @number = number @name = name @type = type end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/anodator/input_spec_item.rb', line 7 def name @name end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
7 8 9 |
# File 'lib/anodator/input_spec_item.rb', line 7 def number @number end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/anodator/input_spec_item.rb', line 7 def type @type end |
Instance Method Details
#==(other) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/anodator/input_spec_item.rb', line 25 def ==(other) if other.is_a? InputSpecItem self.number == other.number else return false end end |