class Ouidb::Importer
Constants
- FIRST_LINE
- SECOND_LINE
Public Class Methods
new(io)
click to toggle source
# File lib/ouidb/importer.rb, line 7 def initialize(io) @io = io end
read(io)
click to toggle source
# File lib/ouidb/importer.rb, line 3 def self.read(io) new(io).read end
Public Instance Methods
read()
click to toggle source
# File lib/ouidb/importer.rb, line 11 def read block = [] while (line = @io.gets) block << line if line.strip == '' read_block block block.clear end end end
read_block(lines)
click to toggle source
# File lib/ouidb/importer.rb, line 25 def read_block(lines) return unless (match = FIRST_LINE.match(lines.shift)) hex = match[:hex].delete('-') name = match[:name].gsub(/\s+/, ' ') return unless (match = SECOND_LINE.match(lines.shift)) hex << match[:start][0...3] if match[:end] # TODO addresses manufacturer = Manufacturer[name] manufacturer.ranges << (match[:end] ? MacRange::Range36 : MacRange::Range24).find_or_create(hex, manufacturer) end