Class: OVIRT::BaseObject

Inherits:
Object
  • Object
show all
Defined in:
lib/ovirt/base_object.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, id, href, name) ⇒ BaseObject

Returns a new instance of BaseObject.



6
7
8
9
10
# File 'lib/ovirt/base_object.rb', line 6

def initialize(client, id, href, name)
  @id, @href, @name = id, href, name
  @client = client
  self
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



4
5
6
# File 'lib/ovirt/base_object.rb', line 4

def client
  @client
end

#hrefObject

Returns the value of attribute href.



3
4
5
# File 'lib/ovirt/base_object.rb', line 3

def href
  @href
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/ovirt/base_object.rb', line 3

def id
  @id
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/ovirt/base_object.rb', line 3

def name
  @name
end

Instance Method Details

#parse_bool(text) ⇒ Object



16
17
18
19
20
# File 'lib/ovirt/base_object.rb', line 16

def parse_bool text
  return true if text =~ /^true$/i
  return false if text =~ /^false$/i
  raise ArgumentError.new %Q[The string "#{text}" isn't a valid boolean, it should be "true" or "false"]
end

#parse_version(xml) ⇒ Object



12
13
14
# File 'lib/ovirt/base_object.rb', line 12

def parse_version xml
  (xml/'version').first[:major] +"."+ (xml/'version').first[:minor]
end