Class: Middleman::PreviewServer::NetworkInterfaceInventory::All

Inherits:
Object
  • Object
show all
Defined in:
lib/middleman-core/preview_server/network_interface_inventory.rb

Overview

Return all ip interfaces

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.match?Boolean


16
17
18
# File 'lib/middleman-core/preview_server/network_interface_inventory.rb', line 16

def self.match?(*)
  true
end

Instance Method Details

#network_interfacesObject


9
10
11
12
13
14
# File 'lib/middleman-core/preview_server/network_interface_inventory.rb', line 9

def network_interfaces
  ipv4_addresses = Socket.ip_address_list.select(&:ipv4?).map { |ai| ServerIpv4Address.new(ai.ip_address) }
  ipv6_addresses = Socket.ip_address_list.select(&:ipv6?).map { |ai| ServerIpv6Address.new(ai.ip_address) }

  ipv4_addresses + ipv6_addresses
end