class Hydra::IpBasedGroups::Group

Attributes

name[RW]

Public Class Methods

new(h) click to toggle source

@param [Hash] h

# File lib/hydra/ip_based_groups.rb, line 11
def initialize(h)
  @name = h.fetch('name')
  @subnet_strings = h.fetch('subnets')
end

Public Instance Methods

include_ip?(ip_string) click to toggle source
# File lib/hydra/ip_based_groups.rb, line 16
def include_ip?(ip_string)
  ip = IPAddr.new(ip_string)
  subnets.any? { |subnet| subnet.include?(ip) }
end

Private Instance Methods

subnets() click to toggle source
# File lib/hydra/ip_based_groups.rb, line 23
def subnets
  @subnets ||= @subnet_strings.map { |s| IPAddr.new(s) }
end