Class: CrateAPI::Items

Inherits:
Object
  • Object
show all
Defined in:
lib/crate_api/items.rb

Overview

Items class which is used to get a set of items from the service.

Constant Summary collapse

ITEM_ACTIONS =

Hash of available actions to take upon the Items endpoint.

{
  :upload => "upload.json",
  :list => "list.json",
  :show => "show/%s.json",
  :destroy => "destroy/%s.json"
}

Class Method Summary collapse

Class Method Details

.from_array(array) ⇒ Array

Creates an array of Item objects.

Parameters:

  • array (Array)

    to be used as the generation source.

Returns:

  • (Array)

    either an empty array if the input array is nil or a fully inialized array of Item objects.



15
16
17
18
19
20
21
22
# File 'lib/crate_api/items.rb', line 15

def self.from_array(array)
  return [] unless array != nil
  files = Array.new
  array.each do |file|
    files.push(Item.new(file))
  end
  return files
end