Class: Boxcutter::Server
- Inherits:
-
Object
- Object
- Boxcutter::Server
- Defined in:
- lib/boxcutter/server.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
Class Method Summary collapse
Instance Method Summary collapse
- #cpu ⇒ Object
- #description ⇒ Object
- #hostname ⇒ Object
- #id ⇒ Object
-
#initialize(api, attrs) ⇒ Server
constructor
A new instance of Server.
- #ips ⇒ Object
- #lb_applications ⇒ Object
- #location_id ⇒ Object
- #memory ⇒ Object
- #status ⇒ Object
- #storage ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(api, attrs) ⇒ Server
Returns a new instance of Server.
14 15 16 17 |
# File 'lib/boxcutter/server.rb', line 14 def initialize(api, attrs) @api = api @attrs = attrs end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
12 13 14 |
# File 'lib/boxcutter/server.rb', line 12 def api @api end |
Class Method Details
.all ⇒ Object
3 4 5 6 |
# File 'lib/boxcutter/server.rb', line 3 def self.all api = Api.new(*ENV['BBG_API_KEY'].split(':')) api.servers.map {|attrs| new(api, attrs)} end |
.find_by_hostname(hostname) ⇒ Object
8 9 10 |
# File 'lib/boxcutter/server.rb', line 8 def self.find_by_hostname(hostname) all.detect {|server| server.hostname == hostname} end |
Instance Method Details
#cpu ⇒ Object
51 52 53 |
# File 'lib/boxcutter/server.rb', line 51 def cpu @attrs["cpu"] end |
#description ⇒ Object
47 48 49 |
# File 'lib/boxcutter/server.rb', line 47 def description @attrs["description"] end |
#hostname ⇒ Object
43 44 45 |
# File 'lib/boxcutter/server.rb', line 43 def hostname @attrs["hostname"] end |
#id ⇒ Object
31 32 33 |
# File 'lib/boxcutter/server.rb', line 31 def id @attrs["id"] end |
#ips ⇒ Object
23 24 25 |
# File 'lib/boxcutter/server.rb', line 23 def ips @attrs["ips"].map {|ip| ip["address"]} end |
#lb_applications ⇒ Object
59 60 61 62 63 |
# File 'lib/boxcutter/server.rb', line 59 def lb_applications @attrs["lb_applications"].map do |lb_app_attrs| LoadBalancer::Application.find(lb_app_attrs["lb_application_id"], api) end end |
#location_id ⇒ Object
39 40 41 |
# File 'lib/boxcutter/server.rb', line 39 def location_id @attrs["location_id"] end |
#memory ⇒ Object
27 28 29 |
# File 'lib/boxcutter/server.rb', line 27 def memory @attrs["memory"] end |
#status ⇒ Object
55 56 57 |
# File 'lib/boxcutter/server.rb', line 55 def status @attrs["status"] end |
#storage ⇒ Object
35 36 37 |
# File 'lib/boxcutter/server.rb', line 35 def storage @attrs["storage"] end |
#to_s ⇒ Object
19 20 21 |
# File 'lib/boxcutter/server.rb', line 19 def to_s "#<Server id:'#{id}' hostname:'#{hostname}' description:'#{description}' status:'#{status}'>" end |