Class: Rightstuff::Server

Inherits:
Base
  • Object
show all
Defined in:
lib/rightstuff/server.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

extract_attributes, load_collection

Constructor Details

#initialize(client, item) ⇒ Server

Returns a new instance of Server.



7
8
9
10
11
# File 'lib/rightstuff/server.rb', line 7

def initialize( client, item )
  @settings = nil
  @inputs   = nil
  super
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/rightstuff/server.rb', line 17

def method_missing( name , *args, &block )
  result = super
  return result unless result.nil?
  return nil    unless @attributes[ :state ] == 'operational'
  settings unless @settings
  return @attributes[ name ]
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



5
6
7
# File 'lib/rightstuff/server.rb', line 5

def attributes
  @attributes
end

Class Method Details

.collection_xpathObject



13
14
15
# File 'lib/rightstuff/server.rb', line 13

def self.collection_xpath
  '/servers/server'
end

Instance Method Details

#idObject



25
26
27
# File 'lib/rightstuff/server.rb', line 25

def id
  @attributes[ :href ].split( '/' ).last
end

#inputsObject



29
30
31
32
33
# File 'lib/rightstuff/server.rb', line 29

def inputs
  return @inputs if @inputs
  # Add inputs to instance data
  # @client.get( @attributes[ 'href' ] )
end

#settingsObject



35
36
37
38
39
40
41
# File 'lib/rightstuff/server.rb', line 35

def settings
  return @settings if @settings
  doc       = @client.get_rest( 'servers/' + id + '/settings' )
  xml       = Nokogiri::XML( doc )
  @settings = Base.extract_attributes( xml.children )
  @attributes.merge!( @settings )
end