Class: Rack::IpRestrictor::IpGroup
- Inherits:
-
Object
- Object
- Rack::IpRestrictor::IpGroup
- Defined in:
- lib/rack_ip_restrictor/ip_group.rb
Overview
Stores and handles groups of IP's added as String, converted into hash of IpAddr
Instance Method Summary (collapse)
-
- (Object) add(ip_arg)
Adds an IP address to the list of addresses as instance of IPAddr.
- - (Boolean) include?(remote_addr)
-
- (IpGroup) initialize
constructor
A new instance of IpGroup.
-
- (Array) ips
Keys of addresses set.
Constructor Details
- (IpGroup) initialize
A new instance of IpGroup
5 6 7 |
# File 'lib/rack_ip_restrictor/ip_group.rb', line 5 def initialize @addresses = {} end |
Instance Method Details
- (Object) add(ip_arg)
Adds an IP address to the list of addresses as instance of IPAddr
12 13 14 |
# File 'lib/rack_ip_restrictor/ip_group.rb', line 12 def add(ip_arg) @addresses[ip_arg] = IPAddr.new(ip_arg) end |
- (Boolean) include?(remote_addr)
22 23 24 25 26 27 |
# File 'lib/rack_ip_restrictor/ip_group.rb', line 22 def include?(remote_addr) @addresses.each do |key, value| return true if value.include? remote_addr end false end |
- (Array) ips
Keys of addresses set
17 18 19 |
# File 'lib/rack_ip_restrictor/ip_group.rb', line 17 def ips @addresses.keys end |