Class: Delphi::Resource

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

Overview

Class to encapsulate an RC file.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rcfile, dproj_version, halt_on_fail = true) ⇒ Resource

You need to tell this class what version of Delphi to use, because there is no metadata in an rc file that it can use to determine it.



14
15
16
17
18
# File 'lib/delphi/resource.rb', line 14

def initialize(rcfile, dproj_version, halt_on_fail = true)
  @rcfile = rcfile
  @haltonfail = halt_on_fail
  @compiler = Delphi::Compiler.new(dproj_version)
end

Instance Attribute Details

#haltonfailObject

Returns the value of attribute haltonfail.



9
10
11
# File 'lib/delphi/resource.rb', line 9

def haltonfail
  @haltonfail
end

#rcfileObject (readonly)

Returns the value of attribute rcfile.



10
11
12
# File 'lib/delphi/resource.rb', line 10

def rcfile
  @rcfile
end

Instance Method Details

#compileObject



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

def compile
  output = @compiler.compile_rc(@rcfile)
  fail "Error compiling #{@rcfile}:\n#{output}" if @haltOnFail && !$CHILD_STATUS
end

#outputObject



25
26
27
# File 'lib/delphi/resource.rb', line 25

def output
  File.join(File.dirname(@rcfile), File.basename(@rcfile, '.rc') + '.res')
end