class WakeOnLan::MagicPacket
Attributes
mac_address[R]
Public Class Methods
new(mac_address)
click to toggle source
# File lib/wake_on_lan/magic_packet.rb, line 5 def initialize(mac_address) @mac_address = colon_separated mac_address end
Public Instance Methods
assemble_frame()
click to toggle source
# File lib/wake_on_lan/magic_packet.rb, line 10 def assemble_frame six_times_255 = 0xff.chr * 6 binary_mac = mac_address.split(':').reduce('') { |binary, hex| binary << hex.to_i(16).chr } six_times_255 + binary_mac * 16 end
Private Instance Methods
colon_separated(mac_address)
click to toggle source
# File lib/wake_on_lan/magic_packet.rb, line 20 def colon_separated(mac_address) hex_array = mac_address.scan /[0-9a-fA-F]{2}/ hex_array.join ':' end