Class: ValidatesHost::Ip

Inherits:
Object
  • Object
show all
Defined in:
lib/validates_host/ip.rb

Instance Method Summary collapse

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

Returns:

  • (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