Class: RPM::MatchIterator

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/rpm/match_iterator.rb

Instance Method Summary collapse

Constructor Details

#initialize(ptr) ⇒ MatchIterator

Returns a new instance of MatchIterator



19
20
21
# File 'lib/rpm/match_iterator.rb', line 19

def initialize(ptr)
  @ptr = ptr
end

Instance Method Details

#eachObject



23
24
25
26
27
# File 'lib/rpm/match_iterator.rb', line 23

def each
  while (pkg = next_iterator)
    yield pkg
  end
end

#get_iterator_countObject Also known as: count, length



65
66
67
# File 'lib/rpm/match_iterator.rb', line 65

def get_iterator_count
  RPM::C.rpmdbGetIteratorCount(@ptr)
end

#next_iteratorObject



29
30
31
32
33
34
35
# 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

#offsetObject

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



39
40
41
# File 'lib/rpm/match_iterator.rb', line 39

def offset
  RPM::C.rpmdbGetIteratorOffset(@ptr)
end

#set_iterator_re(tag, mode, string) ⇒ Object Also known as: regexp



43
44
45
46
47
# 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

#set_iterator_version(version) ⇒ Object Also known as: version



51
52
53
54
55
56
57
58
59
60
61
# 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