Class: CVFFI::Params
- Inherits:
-
Object
show all
- Defined in:
- lib/opencv-ffi-wrappers/misc/params.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(opts = {}) ⇒ Params
Returns a new instance of Params.
20
21
22
23
24
25
26
27
|
# File 'lib/opencv-ffi-wrappers/misc/params.rb', line 20
def initialize( opts = {} )
@params = {}
self.class.defaults.each_key { |k|
@params[k] = (opts[k] or opts[k.to_s] or self.class.defaults[k])
define_singleton_method( k ) { @params[k] }
instance_eval "def #{k}=(a); @params[:#{k}] = a; end"
}
end
|
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params.
18
19
20
|
# File 'lib/opencv-ffi-wrappers/misc/params.rb', line 18
def params
@params
end
|
Class Method Details
.defaults ⇒ Object
8
|
# File 'lib/opencv-ffi-wrappers/misc/params.rb', line 8
def self.defaults; @defaults ||= {}; end
|
.param(*args) ⇒ Object
11
12
13
14
15
16
|
# File 'lib/opencv-ffi-wrappers/misc/params.rb', line 11
def self.param( *args )
while args.length > 0
default,name = [args.pop, args.pop]
defaults[ name ] = default
end
end
|
Instance Method Details
#defaults ⇒ Object
9
|
# File 'lib/opencv-ffi-wrappers/misc/params.rb', line 9
def defaults; self.class.defaults; end
|
#to_hash ⇒ Object
29
30
31
|
# File 'lib/opencv-ffi-wrappers/misc/params.rb', line 29
def to_hash
@params
end
|