Class: Pinoccio::TroopCollection
- Inherits:
-
Object
- Object
- Pinoccio::TroopCollection
- Defined in:
- lib/troop_collection.rb
Instance Method Summary collapse
- #all ⇒ Object
- #first ⇒ Object
- #get(troop_id) ⇒ Object
-
#initialize(client) ⇒ TroopCollection
constructor
A new instance of TroopCollection.
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
#all ⇒ Object
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 |
#first ⇒ Object
7 8 9 |
# File 'lib/troop_collection.rb', line 7 def first all.first end |