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, #logger, #makecommand, #removepass, #run, #runcmd, #setpass, #update, #validate_status
Constructor Details
#initialize(opts = ObservableHash.new) ⇒ Fru
Returns a new instance of Fru.
7 8 9 10 |
# File 'lib/rubyipmi/freeipmi/commands/fru.rb', line 7 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)
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/rubyipmi/freeipmi/commands/fru.rb', line 51 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
44 45 46 |
# File 'lib/rubyipmi/freeipmi/commands/fru.rb', line 44 def list @list end |
Instance Method Details
#board_serial ⇒ Object
21 22 23 |
# File 'lib/rubyipmi/freeipmi/commands/fru.rb', line 21 def board_serial get_from_list('board_serial_number') end |
#get_from_list(key) ⇒ Object
12 13 14 15 |
# File 'lib/rubyipmi/freeipmi/commands/fru.rb', line 12 def get_from_list(key) return unless list.key?(DEFAULT_FRU) list[DEFAULT_FRU][key] if list[DEFAULT_FRU].key?(key) end |
#getfrus ⇒ Object
method to retrieve the raw fru data
34 35 36 37 |
# File 'lib/rubyipmi/freeipmi/commands/fru.rb', line 34 def getfrus command @result end |
#manufacturer ⇒ Object
17 18 19 |
# File 'lib/rubyipmi/freeipmi/commands/fru.rb', line 17 def manufacturer get_from_list('board_manufacturer') end |
#model ⇒ Object
29 30 31 |
# File 'lib/rubyipmi/freeipmi/commands/fru.rb', line 29 def model get_from_list('board_product_name') end |
#names ⇒ Object
39 40 41 |
# File 'lib/rubyipmi/freeipmi/commands/fru.rb', line 39 def names list.keys end |
#serial ⇒ Object
25 26 27 |
# File 'lib/rubyipmi/freeipmi/commands/fru.rb', line 25 def serial get_from_list('board_serial_number') end |