Class: Glyr::Sources
Instance Attribute Summary collapse
-
#provider ⇒ Object
readonly
Returns the value of attribute provider.
Instance Method Summary collapse
- #[](name) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(pointer, provider) ⇒ Sources
constructor
A new instance of Sources.
- #to_hash ⇒ Object
- #to_native ⇒ Object
Constructor Details
#initialize(pointer, provider) ⇒ Sources
Returns a new instance of Sources.
18 19 20 21 |
# File 'lib/glyr/sources.rb', line 18 def initialize (pointer, provider) @internal = pointer.is_a?(FFI::Pointer) ? C::SourceInfo.new(pointer) : pointer @provider = provider end |
Instance Attribute Details
#provider ⇒ Object (readonly)
Returns the value of attribute provider.
16 17 18 |
# File 'lib/glyr/sources.rb', line 16 def provider @provider end |
Instance Method Details
#[](name) ⇒ Object
33 34 35 |
# File 'lib/glyr/sources.rb', line 33 def [] (name) find { |p| p.name == name || p.key == name } end |
#each(&block) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/glyr/sources.rb', line 23 def each (&block) current = @internal until current.null? block.call(Source.new(current, provider)) current = C::SourceInfo.new(current[:next]) end end |
#to_hash ⇒ Object
37 38 39 |
# File 'lib/glyr/sources.rb', line 37 def to_hash Hash[map { |p| [p.to_sym, p] }] end |
#to_native ⇒ Object
41 42 43 |
# File 'lib/glyr/sources.rb', line 41 def to_native @internal end |