class Iface::RangeFile

Represents a range config file (a range of IP addresses)

These are files named like “ifcfg-eth0-range0”.

Attributes

start_clone_num[R]

Public Class Methods

new(filename, device, range_num, clone_num, io) click to toggle source
Calls superclass method Iface::ConfigFile::new
# File lib/iface/config_file.rb, line 175
def initialize(filename, device, range_num, clone_num, io)
  super
  @start_ip_num = string_to_ip_num(vars['ipaddr_start'])
  @end_ip_num = string_to_ip_num(vars['ipaddr_end'])
  @start_clone_num = vars['clonenum_start']&.to_i
end
recognize?(_device, range_num, _clone_num) click to toggle source
# File lib/iface/config_file.rb, line 171
def self.recognize?(_device, range_num, _clone_num)
  !range_num.nil?
end

Public Instance Methods

end_ip_num() click to toggle source
# File lib/iface/config_file.rb, line 195
def end_ip_num
  @end_ip_num.to_ip
end
include?(ip) click to toggle source
# File lib/iface/config_file.rb, line 186
def include?(ip)
  ip_num = string_to_ip_num(ip)
  @start_ip_num <= ip_num && ip_num <= @end_ip_num
end
start_ip_num() click to toggle source
# File lib/iface/config_file.rb, line 191
def start_ip_num
  @start_ip_num.to_ip
end
static?() click to toggle source
# File lib/iface/config_file.rb, line 182
def static?
  true
end
string_to_ip_num(str) click to toggle source
# File lib/iface/config_file.rb, line 199
def string_to_ip_num(str)
  str.split('.').collect { |x| x.to_i.to_s(16).rjust(2, '0') }.join.hex
end