lib/validates_host/subnet.rb in validates_host-1.1.0 vs lib/validates_host/subnet.rb in validates_host-1.2.0
- old
+ new
@@ -1,12 +1,15 @@
+# frozen_string_literal: true
+
module ValidatesHost
class Subnet
def initialize(subnet)
@subnet = subnet
end
def valid?
return true if @subnet.blank?
- @subnet =~ /^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}\/(2[4-9]|30)$/
+
+ @subnet =~ %r{^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}/(2[4-9]|30)$}
end
end
-end
\ No newline at end of file
+end