Class: CVFFI::Params

Inherits:
Object
  • Object
show all
Defined in:
lib/opencv-ffi-wrappers/misc/params.rb

Direct Known Subclasses

GoodFeaturesParams, SIFT::Params

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

#paramsObject (readonly)

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

.defaultsObject



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

#defaultsObject



9
# File 'lib/opencv-ffi-wrappers/misc/params.rb', line 9

def defaults;      self.class.defaults; end

#to_hashObject



29
30
31
# File 'lib/opencv-ffi-wrappers/misc/params.rb', line 29

def to_hash
  @params
end