Module: IERS::Parsers::LeapSecond

Defined in:
lib/iers/parsers/leap_second.rb

Defined Under Namespace

Classes: Entry

Class Method Summary collapse

Class Method Details

.parse(path) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/iers/parsers/leap_second.rb', line 12

def parse(path)
  path = Pathname(path)

  unless path.exist?
    raise FileNotFoundError.new(
      "File not found: #{path}",
      path: path.to_s
    )
  end

  entries = []

  path.each_line.with_index(1) do |line, line_number|
    next if line.strip.empty? || line.strip.start_with?("#")

    entries << parse_line(line, path, line_number)
  end

  entries.freeze
end