Sha256: f67cadf4ab7dd39fd0045f17a84a6902713dd8e028d40c80903bed187d736c75
Contents?: true
Size: 697 Bytes
Versions: 1
Compression:
Stored size: 697 Bytes
Contents
# frozen_string_literal: true require 'bindata' require 'pio/ipv4_address' module Pio module Type # IP address class IpAddress < BinData::Primitive array :octets, type: :uint8, initial_length: 4 def set(value) self.octets = IPv4Address.new(value).to_a end def get IPv4Address.new(octets.map { |each| format('%d', each) }.join('.')) end def >>(other) get.to_i >> other end def &(other) get.to_i & other end def ==(other) get == other end def to_bytes octets.map(&:to_hex).join(', ') end def inspect %("#{get}") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pio-0.30.2 | lib/pio/type/ip_address.rb |