class OHServer
Attributes
cpu[RW]
The /servers/<uuid>/info location returns a hash which looks like this as of API v?? on Fri Feb 6 01:40:45 UTC 2015
mem[RW]
The /servers/<uuid>/info location returns a hash which looks like this as of API v?? on Fri Feb 6 01:40:45 UTC 2015
name[RW]
The /servers/<uuid>/info location returns a hash which looks like this as of API v?? on Fri Feb 6 01:40:45 UTC 2015
options[RW]
The /servers/<uuid>/info location returns a hash which looks like this as of API v?? on Fri Feb 6 01:40:45 UTC 2015
persistent[RW]
The /servers/<uuid>/info location returns a hash which looks like this as of API v?? on Fri Feb 6 01:40:45 UTC 2015
Public Class Methods
from_json(o)
click to toggle source
# File lib/servers.rb, line 163 def self.from_json(o) new(options.first) end
new(name, persistent=true, cpu=1000, mem=512, *options)
click to toggle source
# File lib/servers.rb, line 136 def initialize(name, persistent=true, cpu=1000, mem=512, *options) # method argument fun times # http://www.skorks.com/2009/08/method-arguments-in-ruby/ @name = name.to_s @persistent = persistent.to_s @cpu = cpu.to_s @mem = mem.to_s @options = options.first end
Public Instance Methods
to_json(*a)
click to toggle source
we’re going to have to serialize the object to JSON and merge the options www.skorks.com/2010/04/serializing-and-deserializing-objects-with-ruby/
# File lib/servers.rb, line 148 def to_json(*a) # here's a more concise version of what I figured out myself! # https://stackoverflow.com/questions/5030553/ruby-convert-object-to-hash h = {} self.instance_variables.each do |i| n = i.to_s.delete("@") h[n] = self.instance_variable_get(i) end # merge in options hash and delete raw argument post-merge # http://www.ruby-doc.org/core-1.9.3/Hash.html#method-i-delete obj = h.merge @options obj.delete("options") return obj.to_json(*a) end