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.
99 100 101 |
# File 'lib/rubyipmi/ipmitool/commands/fru.rb', line 99 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)
121 122 123 |
# File 'lib/rubyipmi/ipmitool/commands/fru.rb', line 121 def method_missing(method, *_args, &_block) fetch(method.to_s, nil) end |
Instance Method Details
#name ⇒ Object
95 96 97 |
# File 'lib/rubyipmi/ipmitool/commands/fru.rb', line 95 def name self[:name] end |
#parse(data) ⇒ Object
parse the fru information that should be an array of lines
104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/rubyipmi/ipmitool/commands/fru.rb', line 104 def parse(data) return unless data 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 self[key] = value.strip unless value.nil? end end end |