Module: Institutions::IpAddresses
- Included in:
- Institution
- Defined in:
- lib/institutions/institution/ip_addresses.rb
Overview
:no_doc
Instance Attribute Summary collapse
-
#ip_addresses ⇒ Object
readonly
Returns the value of attribute ip_addresses.
Instance Method Summary collapse
-
#includes_ip?(candidate) ⇒ Boolean
Returns a
boolean
indicating whether the candidate IP address is in the Institution’s IP range.
Instance Attribute Details
#ip_addresses ⇒ Object
Returns the value of attribute ip_addresses.
4 5 6 |
# File 'lib/institutions/institution/ip_addresses.rb', line 4 def ip_addresses @ip_addresses end |
Instance Method Details
#includes_ip?(candidate) ⇒ Boolean
Returns a boolean
indicating whether the candidate IP address is in the Institution’s IP range. Example:
require 'institutions'
institution = Institution.new("my_inst", "My Institution", "ip_addresses" => ["127.0.0.1", 127.0.0.2"])
data.includes_ip?("127.0.0.1") # => true
data.includes_ip?("127.0.0.3") # => false
34 35 36 37 |
# File 'lib/institutions/institution/ip_addresses.rb', line 34 def includes_ip?(candidate) return false if ip_addresses.nil? return ip_addresses.include? candidate end |