Class: Cel::CIDR
- Defined in:
- lib/cel/extensions/network.rb
Instance Attribute Summary
Attributes inherited from Literal
Instance Method Summary collapse
-
#initialize(val) ⇒ CIDR
constructor
A new instance of CIDR.
- #to_str ⇒ Object
Methods inherited from Literal
Methods included from CelMethods
Constructor Details
#initialize(val) ⇒ CIDR
Returns a new instance of CIDR.
178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'lib/cel/extensions/network.rb', line 178 def initialize(val) value = IPAddr.new(val) if value.ipv6? raise EvaluateError, "IP Address with zone value is not allowed" if value.zone_id val, = val.split("/", 2) if Resolv::IPv4::Regex.match?(val.split(":").last) raise EvaluateError, "IPv4-mapped IPv6 address is not allowed" end end super(:cidr, value) end |
Instance Method Details
#to_str ⇒ Object
213 214 215 |
# File 'lib/cel/extensions/network.rb', line 213 def to_str @value.cidr end |