Class: Require
- Inherits:
-
Object
- Object
- Require
- Defined in:
- lib/crequire/crequire.rb
Instance Method Summary collapse
-
#initialize(file_path) ⇒ Require
constructor
A new instance of Require.
- #interface(source = nil, &block) ⇒ Object
- #require(options = {}, &block) ⇒ Object
Constructor Details
#initialize(file_path) ⇒ Require
Returns a new instance of Require.
5 6 7 8 9 |
# File 'lib/crequire/crequire.rb', line 5 def initialize(file_path) @full_path = File. file_path @path = File.dirname @full_path @name = File.basename file_path end |
Instance Method Details
#interface(source = nil, &block) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/crequire/crequire.rb', line 33 def interface(source=nil, &block) if source source else swig = SWIG::Context.new(@name) swig.input &block if block swig.interface end end |
#require(options = {}, &block) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/crequire/crequire.rb', line 11 def require( = {}, &block) if [:force] or !File.exists? "#{@full_path}.o" @src = [:src] @cflags = [:cflags] @dump_interface = [:interface] if [:dump] dir = [:dump] FileUtils.mkpath dir save dir, &block install dir else Dir.mktmpdir do |tmp| save tmp, &block install tmp end end end Kernel.require @name end |