Class: ServiceObjects::SendArpPackets

Inherits:
Object
  • Object
show all
Defined in:
lib/ownlan/service_objects/send_arp_packets.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, packets) ⇒ SendArpPackets

Returns a new instance of SendArpPackets.



5
6
7
8
# File 'lib/ownlan/service_objects/send_arp_packets.rb', line 5

def initialize(config, packets)
  @config  = config
  @packets = [packets].flatten
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



3
4
5
# File 'lib/ownlan/service_objects/send_arp_packets.rb', line 3

def config
  @config
end

#packetsObject (readonly)

Returns the value of attribute packets.



3
4
5
# File 'lib/ownlan/service_objects/send_arp_packets.rb', line 3

def packets
  @packets
end

Instance Method Details

#callObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/ownlan/service_objects/send_arp_packets.rb', line 10

def call
  @i = 0

  loop do
    packets.each do |packet|
      @i += 1
      packet.to_w(config.interface)

      print "\r The ARP packet has been sent successfully #{@i} times"

      sleep config.delay
    end
  end
end