Sha256: 7d185c2c905f3a5e64b6a3053410d72fc6a2718dad945c381441973abc0a4476

Contents?: true

Size: 537 Bytes

Versions: 1

Compression:

Stored size: 537 Bytes

Contents

module Pinoccio
  class ScoutCollection
    def initialize(client, troop)
      @client = client
      @troop = troop
    end

    def first
      all.first
    end

    def lead
      all.find {|scout| scout.lead? }
    end

    def all
      result = @client.get("#{@troop.id}/scouts")
      result = [result] unless result.is_a?(Array)
      result.map {|s| Scout.new(@client, @troop, s) }
    end

    def get(scout_id)
      result = @client.get("#{@troop.id}/#{scout_id}")
      Scout.new(@client, @troop, result)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pinoccio-0.1.0 lib/scout_collection.rb