Class: Pinoccio::TroopCollection

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

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ TroopCollection

Returns a new instance of TroopCollection.



3
4
5
# File 'lib/troop_collection.rb', line 3

def initialize(client)
  @client = client
end

Instance Method Details

#allObject



11
12
13
14
15
# File 'lib/troop_collection.rb', line 11

def all
  result = @client.get("troops")
  result = [result] unless result.is_a?(Array)
  result.map {|t| Troop.new(@client, t) }
end

#firstObject



7
8
9
# File 'lib/troop_collection.rb', line 7

def first
  all.first
end

#get(troop_id) ⇒ Object



17
18
19
20
# File 'lib/troop_collection.rb', line 17

def get(troop_id)
  result = @client.get("troops/#{troop_id}")
  Troop.new(@client, result)
end