Sha256: 62ebbe8777d4aa9e7ca6cdbf783e4b3f1293b5ad78d0eb2027c25c5de7dbf85e

Contents?: true

Size: 457 Bytes

Versions: 6

Compression:

Stored size: 457 Bytes

Contents

module ServiceObjects
  class NetworkInformation
    def self.self_mac(interface)
      @self_mac ||= `ifconfig "#{interface}" | head -n1 | tr -s ' ' | cut -d' ' -f5`.strip
    end

    def self.gateway_ip
      @gateway_ip ||= `netstat -rn | grep 0.0.0.0 | awk '{print $2}' | grep -v "0.0.0.0"`.strip
    end

    def self.self_ip(interface)
      @self_ip ||= `ip addr ls "#{interface}" | awk '/inet / {print $2}' | cut -d"/" -f1`.strip
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ownlan-0.4.6 lib/ownlan/service_objects/network_information.rb
ownlan-0.4.4 lib/ownlan/service_objects/network_information.rb
ownlan-0.4.3 lib/ownlan/service_objects/network_information.rb
ownlan-0.4.2 lib/ownlan/service_objects/network_information.rb
ownlan-0.4.1 lib/ownlan/service_objects/network_information.rb
ownlan-0.4.0 lib/ownlan/service_objects/network_information.rb