Class: Efl::EinaList::REinaList
- Inherits:
-
Object
- Object
- Efl::EinaList::REinaList
- Includes:
- ClassHelper, Enumerable
- Defined in:
- lib/efl/eina_list.rb
Instance Method Summary (collapse)
-
- (Object) append(p)
(also: #<<)
for fun and tests.
- - (Object) each
- - (Object) free
-
- (REinaList) initialize(o = nil)
constructor
A new instance of REinaList.
- - (Object) prepend(p) (also: #unshift)
- - (Object) to_a (also: #to_ary)
Methods included from ClassHelper
#===, #address, included, #method_missing, #null?, #to_ptr, #to_s
Constructor Details
- (REinaList) initialize(o = nil)
A new instance of REinaList
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/efl/eina_list.rb', line 25 def initialize o=nil @ptr = ( case o when FFI::Pointer o when NilClass FFI::Pointer::NULL when Array o.inject(FFI::Pointer::NULL) { |p,e| Native.eina_list_append p, e } else raise ArgumentError.new "wrong argument #{o.class.name}" end ) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Efl::ClassHelper
Instance Method Details
- (Object) append(p) Also known as: <<
for fun and tests
57 58 59 |
# File 'lib/efl/eina_list.rb', line 57 def append p @ptr = Native.eina_list_append @ptr, p end |
- (Object) each
43 44 45 46 47 48 49 50 51 |
# File 'lib/efl/eina_list.rb', line 43 def each return if not block_given? p = @ptr while p!=::FFI::Pointer::NULL l = Native::EinaListStruct.new p yield l[:data] p = l[:next] end end |
- (Object) free
39 40 41 42 |
# File 'lib/efl/eina_list.rb', line 39 def free Native.eina_list_free @ptr @ptr = nil end |
- (Object) prepend(p) Also known as: unshift
61 62 63 |
# File 'lib/efl/eina_list.rb', line 61 def prepend p @ptr = Native.eina_list_prepend @ptr, p end |
- (Object) to_a Also known as: to_ary
52 53 54 |
# File 'lib/efl/eina_list.rb', line 52 def to_a inject([]) { |s,e| s<<e } end |