Class: Hydra::IpBasedGroups::Group
- Inherits:
-
Object
- Object
- Hydra::IpBasedGroups::Group
- Defined in:
- lib/hydra/ip_based_groups.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #include_ip?(ip_string) ⇒ Boolean
-
#initialize(h) ⇒ Group
constructor
A new instance of Group.
Constructor Details
#initialize(h) ⇒ Group
Returns a new instance of Group.
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
#name ⇒ Object
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
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 |