Class: Sas2ircu::Backplane

Inherits:
Object
  • Object
show all
Defined in:
lib/disk_reporter/sas2ircu_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(card = nil, enclosure = nil, logical_id = nil, num_slots = nil, start_slot = nil) ⇒ Backplane

Returns a new instance of Backplane.



53
54
55
56
57
58
59
60
# File 'lib/disk_reporter/sas2ircu_parser.rb', line 53

def initialize(card = nil, enclosure = nil, logical_id = nil, num_slots = nil, start_slot = nil)
  self.card = card
  self.enclosure = enclosure,
  self.logical_id = logical_id
  self.num_slots = num_slots
  self.start_slot = start_slot
  self.slots = {}
end

Instance Attribute Details

#cardObject

Returns the value of attribute card.



52
53
54
# File 'lib/disk_reporter/sas2ircu_parser.rb', line 52

def card
  @card
end

#enclosureObject

Returns the value of attribute enclosure.



52
53
54
# File 'lib/disk_reporter/sas2ircu_parser.rb', line 52

def enclosure
  @enclosure
end

#logical_idObject

Returns the value of attribute logical_id.



52
53
54
# File 'lib/disk_reporter/sas2ircu_parser.rb', line 52

def logical_id
  @logical_id
end

#num_slotsObject

Returns the value of attribute num_slots.



52
53
54
# File 'lib/disk_reporter/sas2ircu_parser.rb', line 52

def num_slots
  @num_slots
end

#slotsObject

Returns the value of attribute slots.



52
53
54
# File 'lib/disk_reporter/sas2ircu_parser.rb', line 52

def slots
  @slots
end

#start_slotObject

Returns the value of attribute start_slot.



52
53
54
# File 'lib/disk_reporter/sas2ircu_parser.rb', line 52

def start_slot
  @start_slot
end

Instance Method Details

#expand_slotsObject



62
63
64
65
66
67
# File 'lib/disk_reporter/sas2ircu_parser.rb', line 62

def expand_slots
  (start_slot..start_slot+num_slots-1).each do |slot_number|
    self.slots[slot_number] = Disk.new(self) unless slots[slot_number]
  end
  self
end

#to_hObject



69
70
71
72
73
74
75
# File 'lib/disk_reporter/sas2ircu_parser.rb', line 69

def to_h
  ss = {}
  slots.each do |_k,s|
    ss[s.slot] = s.to_h
  end
  { enclosure: enclosure, logical_id: logical_id, num_slots: num_slots, start_slot: start_slot, slots: ss }
end