Class: EnfCli::IPV6Cidr
- Inherits:
-
Object
- Object
- EnfCli::IPV6Cidr
- Defined in:
- lib/enfcli.rb
Instance Method Summary collapse
-
#initialize(ipv6cidr) ⇒ IPV6Cidr
constructor
A new instance of IPV6Cidr.
- #prefix_bytes ⇒ Object
- #prefix_len ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(ipv6cidr) ⇒ IPV6Cidr
Returns a new instance of IPV6Cidr.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/enfcli.rb', line 81 def initialize(ipv6cidr) # split on / tokens = ipv6cidr.split("/") # raise exception if not cidr format raise EnfCli::ERROR, "#{ipv6cidr} is not a valid CIDR notation." unless tokens.length == 2 # store in prefix/len @prefix = EnfCli::IPV6.new tokens[0] @len = tokens[1].to_i # raise if len is not 0 raise EnfCli::ERROR, "#{ipv6cidr} is not a valid CIDR notation." unless len > 2 end |
Instance Method Details
#prefix_bytes ⇒ Object
96 97 98 |
# File 'lib/enfcli.rb', line 96 def prefix_bytes @prefix.hton end |
#prefix_len ⇒ Object
100 101 102 |
# File 'lib/enfcli.rb', line 100 def prefix_len @len end |
#to_s ⇒ Object
104 105 106 |
# File 'lib/enfcli.rb', line 104 def to_s "#{@prefix.to_s}/#{@len}" end |