Class: Hdmake::Image

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

Constant Summary collapse

DEFAULT_HDMAKE_PATH =
'c:/program files/microsoft research/hd view utilities/hdmake.exe'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(image_path, hdmake_path = DEFAULT_HDMAKE_PATH) ⇒ Image

Returns a new instance of Image.



20
21
22
23
# File 'lib/hdmake.rb', line 20

def initialize(image_path, hdmake_path = DEFAULT_HDMAKE_PATH)
  @image_path  = image_path
  @hdmake_path = hdmake_path
end

Instance Attribute Details

#hdmake_pathObject (readonly)

Returns the value of attribute hdmake_path.



17
18
19
# File 'lib/hdmake.rb', line 17

def hdmake_path
  @hdmake_path
end

#image_pathObject (readonly)

Returns the value of attribute image_path.



16
17
18
# File 'lib/hdmake.rb', line 16

def image_path
  @image_path
end

Instance Method Details

#process(options = nil) ⇒ Object

Raises:



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/hdmake.rb', line 25

def process(options = nil)
  raise PlattformError, "RubyHdMake requires Microsoft Windows" if not windows?
  raise ImageNotFoundError if not File.exists?(@image_path)
  raise ImageNotReadableError if not File.readable?(@image_path)
  raise CommandNotFoundError if not File.exists?(@hdmake_path)
  raise CommandNotExecutableError if not File.executable?(@hdmake_path)
  output = %x[ #{@hdmake_path} -src #{@image_path} #{options} ]
  status = $?
  
  if status.exitstatus == 0
    output
  else
    raise CommandLineError, "Hdmake command failed: #{{:status_code => status, :output => output}.inspect}"
  end
end