Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Getting started fixes #59

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions docs/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ This example uses {VirtualBox::VM}, which will probably be the most common
model you search for.

vm = VirtualBox::VM.find("MyVM")
puts "This VM has #{vm.memory} MB of RAM allocated to it."
puts "This VM has #{vm.memory_size} MB of RAM allocated to it."

Find can also be used with UUIDs:

Expand Down Expand Up @@ -90,10 +90,10 @@ Reading attributes is simple. Let's use a {VirtualBox::VM} as an example:
vm = VirtualBox::VM.find("FooVM")

# Accessing attributes:
vm.memory
vm.memory_size
vm.name
vm.boot1
vm.ioapic
vm.boot_order[0]
vm.bios.io_apic_enabled

### Relationships

Expand All @@ -105,7 +105,7 @@ Relationships are read the exact same way as attributes. Again using a
# storage_controllers is a relationship containing an array of all the
# storage controllers on this VM
vm.storage_controllers.each do |sc|
puts "Storage Controller: #{sc.uuid}"
puts "Storage Controller: #{sc.name}"
end

The difference from an attribute is that while attributes are typically ruby
Expand Down Expand Up @@ -140,7 +140,7 @@ Attributes which support modification are modified like standard ruby attributes
following example uses {VirtualBox::HardDrive}:

hd = VirtualBox::HardDrive.new
hd.size = 2000 # megabytes
hd.logical_size = 2000 # megabytes
hd.format = "VMDK"

As you can see, there is nothing sneaky going on here, and does what you expect.
Expand Down Expand Up @@ -172,25 +172,22 @@ Saving models is _really_ easy: you simply call `save`. That's all! Well, there
some subtleties, but that's the basic idea. `save` will typically **also save relationships**
so if you modify a relationship object or relationship itself, calling `save` on the
parent object will typically save the relationships as well. `save` always returns
`true` or `false` depending on whether the operation was a success or not. If you'd like
instead to know why a `save` failed, you can call the method with a `true` parameter
which sets `raise_errors` to `true` and will raise a {VirtualBox::Exceptions::CommandFailedException}
if there is a failure. The message on this object contains the reason.
`true` or `false` depending on whether the operation was a success or not.

Below is an example of saving a simple {VirtualBox::VM} object:

vm = VirtualBox::VM.find("FooVM")

# Double the memory
vm.memory = vm.memory.to_i * 2
vm.memory_size = vm.memory_size.to_i * 2

# This will return true/false depending on success
vm.save

Below is an example where an exception will be raised if an error occurs:
Below is an example which will return `false`:

vm = VirtualBox::VM.find("FooVM")
vm.memory = "INVALID"
vm.memory_size = "INVALID"

# This will raise an exception, since the memory is invalid
vm.save(true)
# This will return false, since the memory is invalid
vm.save