Class: Rubyipmi::Freeipmi::FruData
- Inherits:
-
Hash
- Object
- Hash
- Rubyipmi::Freeipmi::FruData
- Defined in:
- lib/rubyipmi/freeipmi/commands/fru.rb
Instance Method Summary collapse
-
#initialize(data) ⇒ FruData
constructor
A new instance of FruData.
- #name ⇒ Object
-
#parse(data) ⇒ Object
parse the fru information that should be an array of lines.
Constructor Details
#initialize(data) ⇒ FruData
Returns a new instance of FruData.
122 123 124 |
# File 'lib/rubyipmi/freeipmi/commands/fru.rb', line 122 def initialize(data) parse(data) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object (private)
148 149 150 |
# File 'lib/rubyipmi/freeipmi/commands/fru.rb', line 148 def method_missing(method, *args, &block) self.fetch(method.to_s, nil) end |
Instance Method Details
#name ⇒ Object
118 119 120 |
# File 'lib/rubyipmi/freeipmi/commands/fru.rb', line 118 def name self[:name] end |
#parse(data) ⇒ Object
parse the fru information that should be an array of lines
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/rubyipmi/freeipmi/commands/fru.rb', line 127 def parse(data) if ! data.nil? data.each do |line| key, value = line.split(':', 2) if key =~ /^FRU.*/ if value =~ /([\w\s]*)\(.*\)/ self[:name] = $~[1].strip.gsub(/\ /, '_').downcase end else key = key.strip.gsub(/\ /, '_').downcase.gsub(/fru_/, '') if ! value.nil? self[key] = value.strip end end end end end |