Module: IPIPX

Defined in:
lib/ipip.rb,
lib/ipip/ipv4_database_x.rb

Defined Under Namespace

Classes: IPv4DatabaseX

Class Method Summary collapse

Class Method Details

.data_loaded?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/ipip.rb', line 50

def data_loaded?
  @data_was_loaded ||= false
end

.find(ip) ⇒ Object



33
34
35
36
37
# File 'lib/ipip.rb', line 33

def find(ip)
  raise 'pls call `IPIPX.load_data!` first' unless data_loaded?

  ipv4_database.find(ip)
end

.ipv4_database(data_file = nil) ⇒ Object



46
47
48
# File 'lib/ipip.rb', line 46

def ipv4_database(data_file = nil)
  @ipv4_database ||= IPv4DatabaseX.new(data_file)
end

.load_data!(data_file) ⇒ Object



39
40
41
42
43
44
# File 'lib/ipip.rb', line 39

def load_data!(data_file)
  raise 'No such file' unless File.exists?(data_file)

  ipv4_database(data_file)
  @data_was_loaded = true
end