Class: ULS::DatFile

Inherits:
Object
  • Object
show all
Defined in:
lib/uls/dat_file.rb

Overview

Used to interact with the FCC DAT file.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ DatFile

Returns a new instance of DatFile.



6
7
8
# File 'lib/uls/dat_file.rb', line 6

def initialize(path)
  self.path = path
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



4
5
6
# File 'lib/uls/dat_file.rb', line 4

def path
  @path
end

Instance Method Details

#each_line(&_block) ⇒ Object



10
11
12
13
14
# File 'lib/uls/dat_file.rb', line 10

def each_line(&_block)
  return unless File.exist?(path)

  File.foreach(path) { |line| yield(line) }
end

#each_record(&_block) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/uls/dat_file.rb', line 16

def each_record(&_block)
  return unless File.exist?(path)

  File.foreach(path) do |line|
    record = line_to_record(line)
    yield(record)
  end
end