Class: LocationCode
- Inherits:
-
Object
- Object
- LocationCode
- Defined in:
- lib/AIX/location_code.rb
Overview
Instance Attribute Summary collapse
-
#_comment ⇒ Object
readonly
Returns the value of attribute _comment.
-
#card ⇒ Object
Returns the value of attribute card.
-
#device_slot ⇒ Object
Returns the value of attribute device_slot.
-
#enclosure_model ⇒ Object
Returns the value of attribute enclosure_model.
-
#location ⇒ Object
Returns the value of attribute location.
-
#location_code_raw ⇒ Object
Returns the value of attribute location_code_raw.
-
#planar ⇒ Object
Returns the value of attribute planar.
-
#port ⇒ Object
Returns the value of attribute port.
-
#serial_number ⇒ Object
Returns the value of attribute serial_number.
-
#unit_enclosure_type ⇒ Object
Returns the value of attribute unit_enclosure_type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(string = nil) ⇒ LocationCode
constructor
A new instance of LocationCode.
- #parse(string) ⇒ Object
-
#parse_location(string) ⇒ Object
Code prefix Description A Air moving device, for example,fan C Card, for example, PCI slots, memory slots D Devices, for example, disk slot, disk drawer E Electrical, for example, power supply L Logical path, for example, Fibre Channel P Planar, for example, a system or I/O back-plane, system board T Interface connector /Port, for example, serial port, usually followed by a number to denote which port U Unit V Virtual planar.
Constructor Details
#initialize(string = nil) ⇒ LocationCode
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/AIX/location_code.rb', line 20 def initialize(string = nil) @unit_enclosure_type = nil @enclosure_model = nil @serial_number = nil @location = nil @planar = nil @virtual_planar = nil @device_slot = nil @card = nil @card2 = nil @port = nil @_comment = nil parse(string) unless string.nil? end |
Instance Attribute Details
#_comment ⇒ Object (readonly)
Returns the value of attribute _comment.
18 19 20 |
# File 'lib/AIX/location_code.rb', line 18 def _comment @_comment end |
#card ⇒ Object
Returns the value of attribute card.
15 16 17 |
# File 'lib/AIX/location_code.rb', line 15 def card @card end |
#device_slot ⇒ Object
Returns the value of attribute device_slot.
14 15 16 |
# File 'lib/AIX/location_code.rb', line 14 def device_slot @device_slot end |
#enclosure_model ⇒ Object
Returns the value of attribute enclosure_model.
9 10 11 |
# File 'lib/AIX/location_code.rb', line 9 def enclosure_model @enclosure_model end |
#location ⇒ Object
Returns the value of attribute location.
11 12 13 |
# File 'lib/AIX/location_code.rb', line 11 def location @location end |
#location_code_raw ⇒ Object
Returns the value of attribute location_code_raw.
7 8 9 |
# File 'lib/AIX/location_code.rb', line 7 def location_code_raw @location_code_raw end |
#planar ⇒ Object
Returns the value of attribute planar.
13 14 15 |
# File 'lib/AIX/location_code.rb', line 13 def planar @planar end |
#port ⇒ Object
Returns the value of attribute port.
16 17 18 |
# File 'lib/AIX/location_code.rb', line 16 def port @port end |
#serial_number ⇒ Object
Returns the value of attribute serial_number.
10 11 12 |
# File 'lib/AIX/location_code.rb', line 10 def serial_number @serial_number end |
#unit_enclosure_type ⇒ Object
Returns the value of attribute unit_enclosure_type.
8 9 10 |
# File 'lib/AIX/location_code.rb', line 8 def unit_enclosure_type @unit_enclosure_type end |
Class Method Details
.regexp_string(type) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/AIX/location_code.rb', line 90 def self.regexp_string(type) if type == 'virtual_planar' '\w{5}\.\w{3}\.[\w#]{7}\-V\d+\-C\d+' elsif type == 'virtual_planar_client' '\w{5}\.\w{3}\.[\w#]{7}\-V\d+\-C\d+|\w{5}\.\w{3}\.[\w#]{7}\-V\d+\-C\d+\-T\d+' elsif type == 'physical_planar' '\w{5}\.\w{3}\.[\w#]{7}\-P\d+\-C\d+\-T\d+|\w{5}\.\w{3}\.[\w#]{7}\-P\d+\-C\d+\-C\d+\-T\d+' else raise Exception, "Wrong type of location code >#{type}<" end end |
Instance Method Details
#parse(string) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/AIX/location_code.rb', line 39 def parse(string) @location_code_raw = string if match = /^\s*(\w{5})\.(\w{3})\.([\w#]{7})\-([CPDTV\d\-]+)\s*$/.match(string) @unit_enclosure_type = match[1] @enclosure_model = match[2] @serial_number = match[3] @location = parse_location(match[4]) else raise Exception, "Can't parse string >#{string}<" end end |
#parse_location(string) ⇒ Object
Code prefix Description A Air moving device, for example,fan C Card, for example, PCI slots, memory slots D Devices, for example, disk slot, disk drawer E Electrical, for example, power supply L Logical path, for example, Fibre Channel P Planar, for example, a system or I/O back-plane, system board T Interface connector /Port, for example, serial port, usually followed by a number to denote which port U Unit V Virtual planar
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/AIX/location_code.rb', line 62 def parse_location(string) if match = /^P(\d+)\-D(\d+)$/.match(string) @planar = match[1] @device_slot = match[2] elsif match = /^P(\d+)\-T(\d+)$/.match(string) @planar = match[1] @port = match[2] @_comment = 'integral (on-board) port' elsif match = /^P(\d+)\-C(\d+)\-T(\d+)$/.match(string) @planar = match[1] @card = match[2] @port = match[3] elsif match = /^P\d+\-C\d+\-C\d+\-T\d+$/.match(string) @planar = match[1] @card = match[2] @card2 = match[3] @port = match[4] elsif match = /^V\d+\-C\d+$/.match(string) @virtual_planar = match[1] @card = match[2] @_comment = 'virtual planar' else raise Exception, "Wrong location code >#{string}<" end string end |