Class: Cocupu::Pool

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(values, conn) ⇒ Pool

Returns a new instance of Pool.



4
5
6
7
# File 'lib/cocupu/pool.rb', line 4

def initialize(values, conn)
  self.conn = conn
  self.values = values
end

Instance Attribute Details

#connObject

Returns the value of attribute conn.



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

def conn
  @conn
end

#valuesObject

Returns the value of attribute values.



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

def values
  @values
end

Instance Method Details

#modelsObject



16
17
18
19
20
21
22
23
24
# File 'lib/cocupu/pool.rb', line 16

def models
  return @models if @models
  # req_url = "http://#{host}:#{port}#{url}/models.json?auth_token=#{token}"
  # puts "Calling #{req_url}"
  response = conn.get("#{url}/models.json")
  #puts "RESP: #{response}"
  raise "Error getting models: #{response}" unless response.code == 200
  @pools = response.map {|val| Model.new(val, conn)}
end

#short_nameObject



8
9
10
# File 'lib/cocupu/pool.rb', line 8

def short_name
  values["short_name"]
end

#urlObject



12
13
14
# File 'lib/cocupu/pool.rb', line 12

def url
  values["url"]
end