Class: Cloudkick::Nodes
Instance Attribute Summary collapse
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
Instance Method Summary collapse
- #each ⇒ Object
- #get ⇒ Object
-
#initialize(query = nil) ⇒ Nodes
constructor
A new instance of Nodes.
Methods inherited from Base
Constructor Details
#initialize(query = nil) ⇒ Nodes
Returns a new instance of Nodes.
47 48 49 50 |
# File 'lib/cloudkick/node.rb', line 47 def initialize(query=nil) @query = query @nodes = get end |
Instance Attribute Details
#nodes ⇒ Object (readonly)
Returns the value of attribute nodes.
45 46 47 |
# File 'lib/cloudkick/node.rb', line 45 def nodes @nodes end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
45 46 47 |
# File 'lib/cloudkick/node.rb', line 45 def query @query end |
Instance Method Details
#each ⇒ Object
52 53 54 |
# File 'lib/cloudkick/node.rb', line 52 def each @nodes.each { |node| yield node } end |
#get ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/cloudkick/node.rb', line 56 def get if @query escaped = URI.escape(@query) resp, data = access_token.get("/1.0/query/nodes?query=#{escaped}") else resp, data = access_token.get("/1.0/query/nodes") end hash = Crack::JSON.parse(data) nodes = hash.map do |node| Node.new(node['agent_state'], node['color'], node['id'], node['ipaddress'], node['name'], node['provider_id'], node['provider_name'], node['status'], node['tags']) end end |