Method: JSS::PeripheralType#fields

Defined in:
lib/jss/api_object/peripheral_type.rb

#fieldsArray<Hash>

The definitions of the fields stored for this peripheral type.

Each Hash defines a field of data to store. The keys are:

  • :name, String, the name of the field

  • :type, String or Symbol, the kind of data to be stored in the field, either :text or :menu

  • :choices, Array of Strings - if type is :menu, these are the menu choices.

  • :order, the one-based index of this field amongst it’s peers.

Since Arrays are zero-based, and the field order is one-based, keeping a nil at the front of the Array will keep the :order number in sync with the Array index of each field definition. This is done automatically by the field-editing methods: #fields=, #set_field, #append_field, #prepend_field, #insert_field, and #delete_field.

So the Array from the API comes like this:

[ {:type=>"text", :order=>1, :choices=>[], :name=>"make"},
  {:type=>"text", :order=>2, :choices=>[], :name=>"model"},
  {:type=>"text", :order=>3, :choices=>[], :name=>"family"},
  {:type=>"text", :order=>4, :choices=>[], :name=>"serialnum"} ]

But will be stored in a PeripheralType instance like this:

[ nil,
  {:type=>"text", :order=>1, :choices=>[], :name=>"make"},
  {:type=>"text", :order=>2, :choices=>[], :name=>"model"},
  {:type=>"text", :order=>3, :choices=>[], :name=>"family"},
  {:type=>"text", :order=>4, :choices=>[], :name=>"serialnum"} ]

therefore

myPerifType.fields[2]

will get you the second field, which has :order => 2.

Returns:



134
135
136
# File 'lib/jss/api_object/peripheral_type.rb', line 134

def fields
  @fields
end