Class: Rubyipmi::Ipmitool::Fru
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- BaseCommand
- Rubyipmi::Ipmitool::Fru
- Defined in:
- lib/rubyipmi/ipmitool/commands/fru.rb
Constant Summary collapse
- DEFAULT_FRU =
'builtin_fru_device'
Instance Attribute Summary collapse
-
#list ⇒ Object
return the list of fru information in a hash.
Attributes inherited from BaseCommand
#cmd, #lastcall, #max_retry_count, #options, #passfile, #result
Instance Method Summary collapse
-
#getfrus ⇒ Object
method to retrieve the raw fru data.
-
#initialize(opts = ObservableHash.new) ⇒ Fru
constructor
A new instance of Fru.
- #manufacturer ⇒ Object
- #model ⇒ Object
- #names ⇒ Object
- #serial ⇒ Object
Methods inherited from BaseCommand
#find_fix, #makecommand, #max_retry_count, #setpass
Methods inherited from BaseCommand
#dump_command, #find_fix, #locate_command, #makecommand, #removepass, #run, #runcmd, #setpass, #update, #validate_status
Constructor Details
#initialize(opts = ObservableHash.new) ⇒ Fru
Returns a new instance of Fru.
10 11 12 13 |
# File 'lib/rubyipmi/ipmitool/commands/fru.rb', line 10 def initialize(opts = ObservableHash.new) super("ipmitool", opts) @list = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object (private)
I use method missing to allow the user to say Fru.<name> which returns a frudata object unless the user passes a keyname from the default fru device
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/rubyipmi/ipmitool/commands/fru.rb', line 48 def method_missing(method, *args, &block) name = method.to_s fru = list.fetch(name, nil) # if the user wanted some data from the default fru, lets show the data for the fru. Otherwise # we return the Fru with the given name if fru.nil? if list[DEFAULT_FRU].keys.include?(name) return list[DEFAULT_FRU][name] else # maybe we should return nil instead? hmm... raise NoMethodError end else return fru end end |
Instance Attribute Details
#list ⇒ Object
return the list of fru information in a hash
32 33 34 |
# File 'lib/rubyipmi/ipmitool/commands/fru.rb', line 32 def list @list end |
Instance Method Details
#getfrus ⇒ Object
method to retrieve the raw fru data
40 41 42 |
# File 'lib/rubyipmi/ipmitool/commands/fru.rb', line 40 def getfrus command end |
#manufacturer ⇒ Object
19 20 21 |
# File 'lib/rubyipmi/ipmitool/commands/fru.rb', line 19 def manufacturer list[DEFAULT_FRU]['product_manufacturer'] end |
#model ⇒ Object
27 28 29 |
# File 'lib/rubyipmi/ipmitool/commands/fru.rb', line 27 def model list[DEFAULT_FRU]['product_manufacturer'] end |
#names ⇒ Object
15 16 17 |
# File 'lib/rubyipmi/ipmitool/commands/fru.rb', line 15 def names list.keys end |
#serial ⇒ Object
23 24 25 |
# File 'lib/rubyipmi/ipmitool/commands/fru.rb', line 23 def serial list[DEFAULT_FRU]['board_serial'] end |