Class: RPM::Dependency

Inherits:
Object
  • Object
show all
Defined in:
lib/rpm/dependency.rb

Direct Known Subclasses

Conflict, Provide, Require

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, version, flags, owner) ⇒ Dependency



20
21
22
23
24
25
26
27
28
# File 'lib/rpm/dependency.rb', line 20

def initialize(name, version, flags, owner)

  RPM::Utils.check_type(version, RPM::Version)
  
  @name = name
  @version = version
  @flags = flags
  @owner = owner
end

Instance Attribute Details

#flagsString



12
13
14
# File 'lib/rpm/dependency.rb', line 12

def flags
  @flags
end

#flagstagObject

Returns the value of attribute flagstag



18
19
20
# File 'lib/rpm/dependency.rb', line 18

def flagstag
  @flagstag
end

#nameString



8
9
10
# File 'lib/rpm/dependency.rb', line 8

def name
  @name
end

#nametagObject

Returns the value of attribute nametag



16
17
18
# File 'lib/rpm/dependency.rb', line 16

def nametag
  @nametag
end

#ownerPackage



14
15
16
# File 'lib/rpm/dependency.rb', line 14

def owner
  @owner
end

#versionString



10
11
12
# File 'lib/rpm/dependency.rb', line 10

def version
  @version
end

#versiontagObject

Returns the value of attribute versiontag



17
18
19
# File 'lib/rpm/dependency.rb', line 17

def versiontag
  @versiontag
end

Instance Method Details

#eq?Boolean



67
68
69
# File 'lib/rpm/dependency.rb', line 67

def eq?
  flags & RPM::SENSE[:equal] 
end

#ge?Boolean



77
78
79
# File 'lib/rpm/dependency.rb', line 77

def ge?
  (flags & RPM::SENSE[:greater]) && (flags & RPMSENSE[:equal])
end

#gt?Boolean



62
63
64
# File 'lib/rpm/dependency.rb', line 62

def gt?
  flags & RPM::SENSE[:greater]
end

#le?Boolean



72
73
74
# File 'lib/rpm/dependency.rb', line 72

def le?
  (flags & RPM::SENSE[:less]) && (flags & RPMSENSE[:equal])
end

#lt?Boolean



57
58
59
# File 'lib/rpm/dependency.rb', line 57

def lt?
  flags & RPM::SENSE[:less]
end

#pre?Boolean



82
83
84
# File 'lib/rpm/dependency.rb', line 82

def pre?
  flags & RPM::SENSE[:prereq] 
end

#satisfy?(other) ⇒ Boolean



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/rpm/dependency.rb', line 32

def satisfy?(other)
  case other
    when RPM::Package then
      other.provides.each do |prov|
        return true if self.satisfy?(prov)
      end
      return false
    when RPM::Dependency then
      RPM::FFI.rpmdsCompare(
        RPM::FFI.rpmdsSingle(:providename, other.name,
          other.version.to_vre, other.flags),
        RPM::FFI.rpmdsSingle(:providename, name,
          version.to_vre, flags)) != 0
    when RPM::Version then
      RPM::FFI.rpmdsCompare(
        RPM::FFI.rpmdsSingle(:providename, name,
          other.to_vre, other.to_vre.empty? ? 0 : :equal),
        RPM::FFI.rpmdsSingle(:providename, name,
          version.to_vre, flags)) != 0
    else
      raise(TypeError, "#{other} is not a Version or Dependency")
    end
end