Class: Efl::EinaList::REinaList
- Inherits:
-
Object
- Object
- Efl::EinaList::REinaList
- Includes:
- ClassHelper, Enumerable
- Defined in:
- lib/efl/eina_list.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#append(p) ⇒ Object
(also: #<<)
for fun and tests.
- #each ⇒ Object
- #free ⇒ Object
-
#initialize(o = nil) ⇒ REinaList
constructor
A new instance of REinaList.
- #prepend(p) ⇒ Object (also: #unshift)
- #to_a(ptrt = nil) ⇒ Object (also: #to_ary)
Methods included from ClassHelper
#===, #address, included, #method_missing, #null?, #to_ptr, #to_s
Constructor Details
#initialize(o = nil) ⇒ REinaList
Returns a new instance of REinaList.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/efl/eina_list.rb', line 26 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
Class Method Details
Instance Method Details
#append(p) ⇒ Object Also known as: <<
for fun and tests
66 67 68 |
# File 'lib/efl/eina_list.rb', line 66 def append p @ptr = Native.eina_list_append @ptr, p end |
#each ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/efl/eina_list.rb', line 51 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 |
#free ⇒ Object
40 41 42 43 |
# File 'lib/efl/eina_list.rb', line 40 def free Native.eina_list_free @ptr @ptr = nil end |
#prepend(p) ⇒ Object Also known as: unshift
70 71 72 |
# File 'lib/efl/eina_list.rb', line 70 def prepend p @ptr = Native.eina_list_prepend @ptr, p end |
#to_a(ptrt = nil) ⇒ Object Also known as: to_ary
60 61 62 63 |
# File 'lib/efl/eina_list.rb', line 60 def to_a ptrt=nil return inject([]) { |s,e| s<<e } if ptrt.nil? inject([]) { |s,e| s<< e.send('read_'+ptrt.to_s) } end |