Class: Voucher::Validator

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(segments_file) ⇒ Validator

Returns a new instance of Validator.



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

def initialize(segments_file)
  @segments_file = segments_file
end

Class Method Details

.call(segments_file) ⇒ Object



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

def self.call(segments_file)
  new(segments_file).call
end

Instance Method Details

#callObject



13
14
15
16
17
18
19
# File 'lib/voucher/validator.rb', line 13

def call
  segments.each do |segment|
    raise InvalidSegment unless verify(segment)
  end

  true
end