class RallyAPI::RallyCollection

Attributes

results[R]
values[R]

Public Class Methods

new(results) click to toggle source
# File lib/rally_api/rally_collection.rb, line 16
def initialize(results)
  @results = results
end

Public Instance Methods

<<(item) click to toggle source
# File lib/rally_api/rally_collection.rb, line 62
def <<(item)
  push(item)
end
[](index) click to toggle source
# File lib/rally_api/rally_collection.rb, line 20
def [](index)
  if (index.kind_of? Fixnum)
    @results[index]
  else
    all = @results.find_all { |object| object.name == index }
    all.length == 1 ? all[0] : all
  end
end
each(&block) click to toggle source
# File lib/rally_api/rally_collection.rb, line 29
def each(&block)
  # check for parameters method so we don't blow up on Ruby 1.8.7
  if (block.respond_to?('parameters') && block.parameters.length == 2)
    @results.each do |record|
      block.call(record.to_s, record)
    end
  else
    @results.each &block
  end
end
Also aliased as: each_value
each_value(&block)
Alias for: each
empty?() click to toggle source
# File lib/rally_api/rally_collection.rb, line 53
def empty?
  length == 0
end
include?(name) click to toggle source
# File lib/rally_api/rally_collection.rb, line 49
def include?(name)
  self[name.to_s] != []
end
length() click to toggle source
# File lib/rally_api/rally_collection.rb, line 45
def length
  @results.count
end
push(item) click to toggle source
# File lib/rally_api/rally_collection.rb, line 57
def push(item)
  item = RallyObject.new(@rally_rest, item) if item.is_a?(Hash)
  @results.push(item)
end
size() click to toggle source
# File lib/rally_api/rally_collection.rb, line 41
def size
  length
end