Class: Rubyipmi::Ipmitool::FruData
- Inherits:
-
Hash
- Object
- Hash
- Rubyipmi::Ipmitool::FruData
- Defined in:
- lib/rubyipmi/ipmitool/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.
113 114 115 |
# File 'lib/rubyipmi/ipmitool/commands/fru.rb', line 113 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)
138 139 140 |
# File 'lib/rubyipmi/ipmitool/commands/fru.rb', line 138 def method_missing(method, *args, &block) self.fetch(method.to_s, nil) end |
Instance Method Details
#name ⇒ Object
109 110 111 |
# File 'lib/rubyipmi/ipmitool/commands/fru.rb', line 109 def name self[:name] end |
#parse(data) ⇒ Object
parse the fru information that should be an array of lines
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/rubyipmi/ipmitool/commands/fru.rb', line 118 def parse(data) if ! data.nil? data.each do |line| key, value = line.split(':', 2) if key =~ /^FRU\s+Device.*/ if value =~ /([\w\s]*)\(.*\)/ self[:name] = $~[1].strip.gsub(/\ /, '_').downcase end else key = key.strip.gsub(/\ /, '_').downcase if ! value.nil? self[key] = value.strip end end end end end |