lib/inspec/resources/default_gateway.rb
def ipaddress
      # @routing_info is the hash populated in routing_table resource
      # @routing_info contain values as:
      # {
      #   destination1: [ [gateway1x, interface1x], [gateway1y, interface1y] ],
      #   destination2: [gateway2, interface2]
      # }
      %w{default 0.0.0.0}.each do |destination|
        return @routing_info[destination][0][0] if @routing_info.key?(destination)
      end
      # raise exception because no destination with value default or 0.0.0.0 is found in the routing table
      raise Inspec::Exceptions::ResourceFailed, "No routing found as part of default gateway"
    end
# fetches the ipaddress assigned to the default gateway
# default gateway's destination is either `default` or `0.0.0.0`
fetches the ipaddress assigned to the default gateway
default gateway's destination is either `default` or `0.0.0.0`
fetches the ipaddress assigned to the default gateway default gateway ' s destination is either ` default ` or ` 0 . 0 . 0 . 0 `
def ipaddress
      %w{default 0.0.0.0}.each do |destination|
        return @routing_info[destination][0][0] if @routing_info.key?(destination)
      end
      raise Inspec::Exceptions::ResourceFailed, "No routing found as part of default gateway"
    end
def ipaddress %w{ default 0.0.0.0 } . each do | destination | return @routing_info [ destination ] [ 0 ] [ 0 ] if @routing_info . key? ( destination ) end raise Inspec :: Exceptions :: ResourceFailed , "No routing found as part of default gateway" end
fetches the ipaddress assigned to the default gateway
default gateway's destination is either `default` or `0.0.0.0`
fetches the ipaddress assigned to the default gateway default gateway ' s destination is either ` default ` or ` 0 . 0 . 0 . 0 `
# @routing_info is the hash populated in routing_table resource # @routing_info contain values as: # { #   destination1: [ [gateway1x, interface1x], [gateway1y, interface1y] ], #   destination2: [gateway2, interface2] # } # raise exception because no destination with value default or 0.0.0.0 is found in the routing table