Class: Rubyipmi::Freeipmi::Fru
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- BaseCommand
- Rubyipmi::Freeipmi::Fru
- Defined in:
- lib/rubyipmi/freeipmi/commands/fru.rb
Constant Summary collapse
- DEFAULT_FRU =
'default_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
- #board_serial ⇒ Object
- #get_from_list(key) ⇒ Object
-
#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, #validate_status
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.
9 10 11 12 |
# File 'lib/rubyipmi/freeipmi/commands/fru.rb', line 9 def initialize(opts = ObservableHash.new) super("ipmi-fru", opts) @list = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object (private)
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/rubyipmi/freeipmi/commands/fru.rb', line 61 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
52 53 54 |
# File 'lib/rubyipmi/freeipmi/commands/fru.rb', line 52 def list @list end |
Instance Method Details
#board_serial ⇒ Object
29 30 31 |
# File 'lib/rubyipmi/freeipmi/commands/fru.rb', line 29 def board_serial get_from_list('board_serial_number') end |
#get_from_list(key) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/rubyipmi/freeipmi/commands/fru.rb', line 14 def get_from_list(key) if list.has_key?(DEFAULT_FRU) if list[DEFAULT_FRU].has_key?(key) list[DEFAULT_FRU][key] else nil end end end |
#getfrus ⇒ Object
method to retrieve the raw fru data
42 43 44 45 |
# File 'lib/rubyipmi/freeipmi/commands/fru.rb', line 42 def getfrus command return @result end |
#manufacturer ⇒ Object
25 26 27 |
# File 'lib/rubyipmi/freeipmi/commands/fru.rb', line 25 def manufacturer get_from_list('board_manufacturer') end |
#model ⇒ Object
37 38 39 |
# File 'lib/rubyipmi/freeipmi/commands/fru.rb', line 37 def model get_from_list('board_product_name') end |
#names ⇒ Object
47 48 49 |
# File 'lib/rubyipmi/freeipmi/commands/fru.rb', line 47 def names list.keys end |
#serial ⇒ Object
33 34 35 |
# File 'lib/rubyipmi/freeipmi/commands/fru.rb', line 33 def serial get_from_list('board_serial_number') end |