Class: Dashed::Button
- Inherits:
-
Object
- Object
- Dashed::Button
- Defined in:
- lib/dashed/button.rb
Constant Summary collapse
- TIMEOUT =
45- SNAPLENGTH =
65535
Instance Attribute Summary collapse
-
#last_press ⇒ Object
readonly
Returns the value of attribute last_press.
-
#mac_address ⇒ Object
readonly
Returns the value of attribute mac_address.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
-
#initialize(mac_address, interface, timeout = TIMEOUT) ⇒ Button
constructor
A new instance of Button.
- #on_press ⇒ Object
Constructor Details
#initialize(mac_address, interface, timeout = TIMEOUT) ⇒ Button
Returns a new instance of Button.
12 13 14 15 16 17 |
# File 'lib/dashed/button.rb', line 12 def initialize(mac_address, interface, timeout = TIMEOUT) @mac_address = mac_address @interface = interface @timeout = timeout @last_press = nil end |
Instance Attribute Details
#last_press ⇒ Object (readonly)
Returns the value of attribute last_press.
10 11 12 |
# File 'lib/dashed/button.rb', line 10 def last_press @last_press end |
#mac_address ⇒ Object (readonly)
Returns the value of attribute mac_address.
10 11 12 |
# File 'lib/dashed/button.rb', line 10 def mac_address @mac_address end |
#timeout ⇒ Object
Returns the value of attribute timeout.
9 10 11 |
# File 'lib/dashed/button.rb', line 9 def timeout @timeout end |
Instance Method Details
#on_press ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/dashed/button.rb', line 19 def on_press capture.each_packet do |raw_packet| packet = Packet.new(raw_packet) if packet.host_mac_address == mac_address && !duplicate_arp? @last_press = Time.now yield if block_given? end end end |