Class: Sas2ircu::Parser

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeParser

Returns a new instance of Parser.



151
152
153
154
# File 'lib/disk_reporter/sas2ircu_parser.rb', line 151

def initialize
  self.cards = {}
  populate
end

Instance Attribute Details

#cardsObject

Returns the value of attribute cards.



149
150
151
# File 'lib/disk_reporter/sas2ircu_parser.rb', line 149

def cards
  @cards
end

Instance Method Details

#number_of_cardsObject



156
157
158
159
# File 'lib/disk_reporter/sas2ircu_parser.rb', line 156

def number_of_cards
  @no_cards ||= `sas2ircu list | grep Index| wc -l`
  @no_cards = @no_cards.delete("\n").to_i
end

#populateObject



161
162
163
164
165
# File 'lib/disk_reporter/sas2ircu_parser.rb', line 161

def populate
  (0..(number_of_cards - 1)).each do |card_id|
    self.cards[card_id] = Card.new(card_id)
  end
end

#to_hObject



167
168
169
170
171
172
173
# File 'lib/disk_reporter/sas2ircu_parser.rb', line 167

def to_h
  cr = {} 
  cards.each do |_k,c|
    cr[c.id] = c.to_h
  end
  { cards: cr }
end