Class: OUI::MACAddress
- Inherits:
-
Object
- Object
- OUI::MACAddress
- Defined in:
- lib/oui/mac_address.rb
Constant Summary collapse
- @@part =
'[\d|[a-f]|[A-F]][\d|[a-f]|[A-F]]'
Instance Attribute Summary collapse
-
#organization ⇒ Object
Returns the value of attribute organization.
-
#oui ⇒ Object
Returns the value of attribute oui.
Class Method Summary collapse
- .mac_regex_string ⇒ Object
- .oui_regex ⇒ Object
- .oui_regex_string ⇒ Object
- .parse(string) ⇒ Object
- .part ⇒ Object
Instance Method Summary collapse
-
#initialize(string) ⇒ MACAddress
constructor
A new instance of MACAddress.
Constructor Details
#initialize(string) ⇒ MACAddress
Returns a new instance of MACAddress.
27 28 29 30 31 32 33 34 |
# File 'lib/oui/mac_address.rb', line 27 def initialize(string) string =~ /#{self.class.mac_regex_string}/ @address = "#{$1}:#{$2}:#{$3}:#{$4}:#{$5}:#{$6}" @oui = "#{$1}-#{$2}-#{$3}" raise 'illegal format' if @address == ':::::' end |
Instance Attribute Details
#organization ⇒ Object
Returns the value of attribute organization.
3 4 5 |
# File 'lib/oui/mac_address.rb', line 3 def organization @organization end |
#oui ⇒ Object
Returns the value of attribute oui.
3 4 5 |
# File 'lib/oui/mac_address.rb', line 3 def oui @oui end |
Class Method Details
.mac_regex_string ⇒ Object
19 20 21 |
# File 'lib/oui/mac_address.rb', line 19 def self.mac_regex_string "(#{@@part})[:-]?(#{@@part})[:-]?(#{@@part})[:-]?(#{@@part})[:-]?(#{@@part})[:-]?(#{@@part})" end |
.oui_regex ⇒ Object
11 12 13 |
# File 'lib/oui/mac_address.rb', line 11 def self.oui_regex /#{self.oui_regex_string}/ end |
.oui_regex_string ⇒ Object
15 16 17 |
# File 'lib/oui/mac_address.rb', line 15 def self.oui_regex_string "#{@@part}-#{@@part}-#{@@part}" end |
.parse(string) ⇒ Object
7 8 9 |
# File 'lib/oui/mac_address.rb', line 7 def self.parse(string) new(string) end |
.part ⇒ Object
23 24 25 |
# File 'lib/oui/mac_address.rb', line 23 def self.part @@part end |