Class: ValidatesHost::Ip
- Inherits:
-
Object
- Object
- ValidatesHost::Ip
- Defined in:
- lib/validates_host/ip.rb
Instance Method Summary collapse
-
#initialize(value) ⇒ Ip
constructor
A new instance of Ip.
- #valid? ⇒ Boolean
Constructor Details
#initialize(value) ⇒ Ip
Returns a new instance of Ip.
7 8 9 |
# File 'lib/validates_host/ip.rb', line 7 def initialize(value) @value = value end |
Instance Method Details
#valid? ⇒ Boolean
11 12 13 14 15 |
# File 'lib/validates_host/ip.rb', line 11 def valid? return true if @value.blank? @value =~ Regexp.union(Resolv::IPv4::Regex, Resolv::IPv6::Regex) end |