Class: RubyHome::DeviceID
- Inherits:
-
Object
- Object
- RubyHome::DeviceID
- Defined in:
- lib/ruby_home/device_id.rb
Constant Summary collapse
- DELIMITER =
':'
Class Method Summary collapse
-
.generate(digits = 12) ⇒ Object
Device ID of the accessory must be a unique random number generated at every factory reset and must persist across reboots.
- .random_hexadecimal ⇒ Object
- .random_hexadecimals(digits = 12) ⇒ Object
Class Method Details
.generate(digits = 12) ⇒ Object
Device ID of the accessory must be a unique random number generated at every factory reset and must persist across reboots
10 11 12 13 14 15 16 |
# File 'lib/ruby_home/device_id.rb', line 10 def generate(digits=12) random_hexadecimals(digits) .map(&:upcase) .each_slice(2) .map(&:join) .join(DELIMITER) end |
.random_hexadecimal ⇒ Object
18 19 20 |
# File 'lib/ruby_home/device_id.rb', line 18 def random_hexadecimal rand(15).to_s(16) end |
.random_hexadecimals(digits = 12) ⇒ Object
22 23 24 25 26 |
# File 'lib/ruby_home/device_id.rb', line 22 def random_hexadecimals(digits=12) digits .times .map { random_hexadecimal } end |