class RPM::MatchIterator

Public Class Methods

from_ptr(ptr) click to toggle source

Creates a managed MatchIterator from a raw pointer @visibility private

# File lib/rpm/match_iterator.rb, line 15
def self.from_ptr(ptr)
  new(::FFI::AutoPointer.new(ptr, MatchIterator.method(:release)))
end
new(ptr) click to toggle source
# File lib/rpm/match_iterator.rb, line 19
def initialize(ptr)
  @ptr = ptr
end
release(ptr) click to toggle source

@visibility private

# File lib/rpm/match_iterator.rb, line 9
def self.release(ptr)
  RPM::C.rpmdbFreeIterator(ptr)
end

Public Instance Methods

count()
Alias for: get_iterator_count
each() { |pkg| ... } click to toggle source
# File lib/rpm/match_iterator.rb, line 23
def each
  while (pkg = next_iterator)
    yield pkg
  end
end
get_iterator_count() click to toggle source
# File lib/rpm/match_iterator.rb, line 65
def get_iterator_count
  RPM::C.rpmdbGetIteratorCount(@ptr)
end
Also aliased as: count, length
length()
Alias for: get_iterator_count
next_iterator() click to toggle source
# File lib/rpm/match_iterator.rb, line 29
def next_iterator
  pkg_ptr = RPM::C.rpmdbNextIterator(@ptr)
    if !pkg_ptr.null?
      return RPM::Package.new(pkg_ptr)
    end
    return nil;
end
offset() click to toggle source

@ return header join key for current position of rpm database iterator

# File lib/rpm/match_iterator.rb, line 39
def offset
  RPM::C.rpmdbGetIteratorOffset(@ptr)
end
regexp(tag, mode, string)
Alias for: set_iterator_re
set_iterator_re(tag, mode, string) click to toggle source
# File lib/rpm/match_iterator.rb, line 43
def set_iterator_re(tag, mode, string)
  ret = RPM::C.rpmdbSetIteratorRE(@ptr, tag, mode, string)
  raise "Error when setting regular expression '#{string}'" if ret != 0
  self
end
Also aliased as: regexp
set_iterator_version(version) click to toggle source
# File lib/rpm/match_iterator.rb, line 51
def set_iterator_version(version)
  if not version.is_a?(RPM::Version)
    raise TypeError, 'illegal argument type'
  end

  set_iterator_re(:version, :default, version.v)
  if (version.r)
    set_iterator_re(:release, :default, version.r)
  end
  self
end
Also aliased as: version
version(version)