Class: Bitmapped::Validators::ValidateSegmentInput

Inherits:
Object
  • Object
show all
Defined in:
lib/bitmapped/validators/validate_segment_input.rb

Class Method Summary collapse

Class Method Details

.parse_and_validate(input) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/bitmapped/validators/validate_segment_input.rb', line 8

def parse_and_validate(input)
  begin
    raise ArgumentError unless input.size == 4

    segement_a = Integer(input[0])
    segement_b = Integer(input[1])
    segement_c = Integer(input[2])
    color = ValidationHelper.parse_color(input[3].strip)
    [segement_a, segement_b, segement_c, color]
  rescue ArgumentError => ae
    raise ParsingError
  end
end