Method: CrateAPI::Crates.from_array

Defined in:
lib/crate_api/crates.rb

.from_array(array) ⇒ Array

Class method to return an array of crate objects.

Returns:

  • (Array)

    an array of initialized Crate objects.



46
47
48
49
50
51
52
53
# File 'lib/crate_api/crates.rb', line 46

def self.from_array(array)
  return [] unless array != nil
  crates = Array.new
  array.each do |crate|
    crates.push(Crate.new(crate))
  end
  return crates
end