Class: Svn::Utils::Factory
- Inherits:
-
Object
- Object
- Svn::Utils::Factory
- Includes:
- FFI::DataConverter
- Defined in:
- lib/svn/utils.rb
Overview
a generic factory class for use with FFI data types that adds default arguments to constructor calls
# when NativeHash is created, the args are [ptr, :string, :string]
bind :get_hash, :returning => NativeHash.factory( :string, :string )
Instance Method Summary collapse
- #from_native(ptr, ctx) ⇒ Object
-
#initialize(klass, *args) ⇒ Factory
constructor
A new instance of Factory.
- #native_type ⇒ Object
- #new(*args) ⇒ Object
- #real_class ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(klass, *args) ⇒ Factory
Returns a new instance of Factory.
33 34 35 36 |
# File 'lib/svn/utils.rb', line 33 def initialize( klass, *args ) @klass = klass @added_args = args end |
Instance Method Details
#from_native(ptr, ctx) ⇒ Object
42 43 44 |
# File 'lib/svn/utils.rb', line 42 def from_native( ptr, ctx ) @klass.new( ptr, *@added_args ) end |
#native_type ⇒ Object
46 47 48 |
# File 'lib/svn/utils.rb', line 46 def native_type @klass.native_type end |
#new(*args) ⇒ Object
38 39 40 |
# File 'lib/svn/utils.rb', line 38 def new( *args ) @klass.new( *(args + @added_args) ) end |
#real_class ⇒ Object
50 51 52 |
# File 'lib/svn/utils.rb', line 50 def real_class @klass end |
#size ⇒ Object
54 55 56 |
# File 'lib/svn/utils.rb', line 54 def size @klass.size end |