class Arke::Resource::Collection

Attributes

parent[R]

Public Class Methods

new(parent, array) click to toggle source
# File lib/arke/resource/collection.rb, line 9
def initialize(parent, array)
  raise Errors::UnexpectedResponse.
          new("#all expected to receive an Array from the resource, instead a #{array.class} was received.") unless array.is_a? Array
  @parent = parent
  @array = array.collect { |item| @parent.new(item) }
end

Public Instance Methods

[](key) click to toggle source
# File lib/arke/resource/collection.rb, line 20
def [](key)
  @array[key]
end
each(&block) click to toggle source
# File lib/arke/resource/collection.rb, line 16
def each(&block)
  @array.each &block
end
first() click to toggle source
# File lib/arke/resource/collection.rb, line 24
def first
  self[0]
end
inspect() click to toggle source
# File lib/arke/resource/collection.rb, line 36
def inspect
  "#<#{self.class.name}:0x%08x record_count: #{self.length}>" % (object_id * 2)
end
last() click to toggle source
# File lib/arke/resource/collection.rb, line 28
def last
  self[-1]
end
length() click to toggle source
# File lib/arke/resource/collection.rb, line 32
def length
  @array.length
end