Class: AsciiDataTools::RecordType::TypeDeterminer

Inherits:
Object
  • Object
show all
Defined in:
lib/ascii-data-tools/record_type.rb

Instance Method Summary collapse

Constructor Details

#initialize(type_repo = RecordTypeRepository.new) ⇒ TypeDeterminer

Returns a new instance of TypeDeterminer.



78
79
80
81
# File 'lib/ascii-data-tools/record_type.rb', line 78

def initialize(type_repo = RecordTypeRepository.new)
  @all_types = type_repo
  @previously_matched_types = RecordTypeRepository.new
end

Instance Method Details

#determine_type_for(encoded_record) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
# File 'lib/ascii-data-tools/record_type.rb', line 83

def determine_type_for(encoded_record)
  matching_type = 
    @previously_matched_types.identify_type_for(encoded_record) || 
    @all_types.identify_type_for(encoded_record)
  if matching_type.nil?
    return UnknownType.new
  else
    @previously_matched_types << matching_type
    return matching_type
  end
end