Class: Hydra::IpBasedGroups::Group

Inherits:
Object
  • Object
show all
Defined in:
lib/hydra/ip_based_groups.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(h) ⇒ Group

Returns a new instance of Group.

Parameters:

  • h (Hash)


11
12
13
14
# File 'lib/hydra/ip_based_groups.rb', line 11

def initialize(h)
  @name = h.fetch('name')
  @subnet_strings = h.fetch('subnets')
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



9
10
11
# File 'lib/hydra/ip_based_groups.rb', line 9

def name
  @name
end

Instance Method Details

#include_ip?(ip_string) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
# 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