Class: Candle::Utility::XcodeUUIDGenerator
- Inherits:
-
Object
- Object
- Candle::Utility::XcodeUUIDGenerator
- Defined in:
- lib/candle/utility.rb
Instance Method Summary collapse
- #generate ⇒ Object
-
#getMAC(interface = 'en0') ⇒ Object
Get the ethernet hardware address (“MAC”).
-
#initialize ⇒ XcodeUUIDGenerator
constructor
A new instance of XcodeUUIDGenerator.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ XcodeUUIDGenerator
Returns a new instance of XcodeUUIDGenerator.
6 7 8 |
# File 'lib/candle/utility.rb', line 6 def initialize @num = [Time.now.to_i, Process.pid, getMAC] end |
Instance Method Details
#generate ⇒ Object
19 20 21 22 |
# File 'lib/candle/utility.rb', line 19 def generate @num[0] += 1 self end |
#getMAC(interface = 'en0') ⇒ Object
Get the ethernet hardware address (“MAC”). This version works on Mac OS X 10.6 (Snow Leopard); it has not been tested on other versions.
14 15 16 17 |
# File 'lib/candle/utility.rb', line 14 def getMAC(interface='en0') addrMAC = `ifconfig #{interface} ether`.split("\n")[1] addrMAC ? addrMAC.strip.split[1].gsub(':','').to_i(16) : 0 end |
#to_s ⇒ Object
24 25 26 |
# File 'lib/candle/utility.rb', line 24 def to_s "%08X%04X%012X" % @num end |