Class: Machine
- Inherits:
-
Object
- Object
- Machine
- Defined in:
- lib/lab_manager/machine.rb
Instance Attribute Summary collapse
-
#external_ip ⇒ Object
readonly
Returns the value of attribute external_ip.
-
#internal_ip ⇒ Object
readonly
Returns the value of attribute internal_ip.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(machine) ⇒ Machine
constructor
A new instance of Machine.
- #to_csv ⇒ Object
Constructor Details
#initialize(machine) ⇒ Machine
Returns a new instance of Machine.
26 27 28 29 30 |
# File 'lib/lab_manager/machine.rb', line 26 def initialize(machine) @name = machine["name"] @internal_ip = machine["internalIP"] @external_ip = machine["externalIP"] end |
Instance Attribute Details
#external_ip ⇒ Object (readonly)
Returns the value of attribute external_ip.
24 25 26 |
# File 'lib/lab_manager/machine.rb', line 24 def external_ip @external_ip end |
#internal_ip ⇒ Object (readonly)
Returns the value of attribute internal_ip.
24 25 26 |
# File 'lib/lab_manager/machine.rb', line 24 def internal_ip @internal_ip end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
24 25 26 |
# File 'lib/lab_manager/machine.rb', line 24 def name @name end |
Class Method Details
.from_list(data) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/lab_manager/machine.rb', line 3 def self.from_list(data) return [] if data.nil? return [] if data["ListMachinesResult"].nil? return [] if data["ListMachinesResult"]["Machine"].nil? machine_list = data["ListMachinesResult"]["Machine"] if (machine_list.is_a? Array) machine_list.collect { |machine| Machine.new(machine) } else [Machine.new(machine_list)] end end |
.to_csv(machines) ⇒ Object
18 19 20 21 22 |
# File 'lib/lab_manager/machine.rb', line 18 def self.to_csv(machines) machines.each do |machine| puts machine.to_csv end end |
Instance Method Details
#to_csv ⇒ Object
32 33 34 |
# File 'lib/lab_manager/machine.rb', line 32 def to_csv "#{name},#{internal_ip},#{external_ip}" end |