Class: Sas2ircu::Parser
- Inherits:
-
Object
- Object
- Sas2ircu::Parser
- Defined in:
- lib/disk_reporter/sas2ircu_parser.rb
Instance Attribute Summary collapse
-
#cards ⇒ Object
Returns the value of attribute cards.
Instance Method Summary collapse
-
#initialize ⇒ Parser
constructor
A new instance of Parser.
- #number_of_cards ⇒ Object
- #populate ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize ⇒ Parser
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
#cards ⇒ Object
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_cards ⇒ Object
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 |
#populate ⇒ Object
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_h ⇒ Object
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 |