Class: CVFFI::Sequence

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/opencv-ffi-wrappers/sequence.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Enumerable

#inject_with_index

Constructor Details

#initialize(seq) ⇒ Sequence

Returns a new instance of Sequence.



11
12
13
14
# File 'lib/opencv-ffi-wrappers/sequence.rb', line 11

def initialize( seq )
  raise "Don't know how to handle class #{seq.class}" unless seq.is_a?(CvSeq)
  @seq = seq
end

Instance Attribute Details

#seqObject

Returns the value of attribute seq.



9
10
11
# File 'lib/opencv-ffi-wrappers/sequence.rb', line 9

def seq
  @seq
end

Instance Method Details

#[](i) ⇒ Object



31
32
33
# File 'lib/opencv-ffi-wrappers/sequence.rb', line 31

def [](i)
  CVFFI::cvGetSeqElem( @seq, i )
end

#eachObject



16
17
18
19
20
# File 'lib/opencv-ffi-wrappers/sequence.rb', line 16

def each
  size.times { |i|
    yield CVFFI::cvGetSeqElem( @seq, i )
  }
end

#push(a) ⇒ Object



22
23
24
# File 'lib/opencv-ffi-wrappers/sequence.rb', line 22

def push( a )
  CVFFI::cvSeqPush( @seq, a )
end

#sizeObject Also known as: length



26
27
28
# File 'lib/opencv-ffi-wrappers/sequence.rb', line 26

def size
  @seq.total
end