Class: QEMU::Image
- Inherits:
-
Object
- Object
- QEMU::Image
- Defined in:
- lib/qemu/image.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
-
#format ⇒ Object
Returns the value of attribute format.
-
#size ⇒ Object
Returns the value of attribute size.
Instance Method Summary collapse
- #convert(format, output_file = nil) ⇒ Object
- #create ⇒ Object
-
#initialize(file, options = {}) ⇒ Image
constructor
A new instance of Image.
Constructor Details
#initialize(file, options = {}) ⇒ Image
Returns a new instance of Image.
6 7 8 9 10 |
# File 'lib/qemu/image.rb', line 6 def initialize(file, = {}) self.file = file = .merge :format => "raw" .each { |k,v| send "#{k}=", v } end |
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
4 5 6 |
# File 'lib/qemu/image.rb', line 4 def file @file end |
#format ⇒ Object
Returns the value of attribute format.
4 5 6 |
# File 'lib/qemu/image.rb', line 4 def format @format end |
#size ⇒ Object
Returns the value of attribute size.
4 5 6 |
# File 'lib/qemu/image.rb', line 4 def size @size end |
Instance Method Details
#convert(format, output_file = nil) ⇒ Object
16 17 18 19 |
# File 'lib/qemu/image.rb', line 16 def convert(format, output_file = nil) output_file ||= "#{file}.#{format}" system "qemu-img convert -O #{format} #{file} #{output_file}" and output_file end |
#create ⇒ Object
12 13 14 |
# File 'lib/qemu/image.rb', line 12 def create system "qemu-img create -f #{format} #{file} #{size}" end |