Class: Anodator::InputSpecItem

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

Constant Summary collapse

TYPE_STRING =
"STRING"
TYPE_NUMERIC =
"NUMERIC"
TYPE_DATE =
"DATE"

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#numberObject (readonly)

Returns the value of attribute number.



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

def number
  @number
end

#typeObject (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