Problem.to_s and Decision.to_s
authorKlaus Kaempf <kkaempf@suse.de>
Wed, 9 Jan 2008 13:53:13 +0000 (13:53 +0000)
committerKlaus Kaempf <kkaempf@suse.de>
Wed, 9 Jan 2008 13:53:13 +0000 (13:53 +0000)
examples/ruby/decision.rb [new file with mode: 0644]
examples/ruby/problem.rb [new file with mode: 0644]

diff --git a/examples/ruby/decision.rb b/examples/ruby/decision.rb
new file mode 100644 (file)
index 0000000..872849e
--- /dev/null
@@ -0,0 +1,21 @@
+#
+# Extend SatSolver::Decision with to_s
+#
+
+class Satsolverx::Decision
+  def to_s
+    case self.op
+      when SatSolver::DEC_INSTALL
+        return "Install #{self.solvable} #{self.reason}"
+      when SatSolver::DEC_REMOVE
+       return "Remove #{self.solvable} #{self.reason}"
+      when SatSolver::DEC_OBSOLETE
+       return "Obsolete #{self.solvable} #{self.reason}"
+      when SatSolver::DEC_UPDATE
+       return "Update #{self.solvable} #{self.reason}"
+      else
+       return "Decision op #{self.op}"
+      end
+    "**Decision**"
+  end
+end
diff --git a/examples/ruby/problem.rb b/examples/ruby/problem.rb
new file mode 100644 (file)
index 0000000..3ffef60
--- /dev/null
@@ -0,0 +1,31 @@
+#
+# Extend SatSolver::Problem with to_s
+#
+
+class Satsolverx::Problem
+  def to_s
+    case self.reason
+      when SatSolver::SOLVER_PROBLEM_UPDATE_RULE #1
+       reason = "problem with installed"
+      when SatSolver::SOLVER_PROBLEM_JOB_RULE #2
+       reason = "conflicting requests"
+      when SatSolver::SOLVER_PROBLEM_JOB_NOTHING_PROVIDES_DEP #3
+       reason = "nothing provides requested"
+      when SatSolver::SOLVER_PROBLEM_NOT_INSTALLABLE #4
+       reason = "not installable"
+      when SatSolver::SOLVER_PROBLEM_NOTHING_PROVIDES_DEP #5
+       reason = "nothing provides rel required by source"
+      when SatSolver::SOLVER_PROBLEM_SAME_NAME #6
+       reason = "cannot install both"
+      when SatSolver::SOLVER_PROBLEM_PACKAGE_CONFLICT #7
+       reason = "source conflicts with rel provided by target"
+      when SatSolver::SOLVER_PROBLEM_PACKAGE_OBSOLETES #8
+       reason = "source obsoletes rel provided by target"
+      when SatSolver::SOLVER_PROBLEM_DEP_PROVIDERS_NOT_INSTALLABLE #9
+       reason = "source requires rel but no providers are installable"
+      else
+       reason = "**unknown**"
+    end
+    "[#{self.reason}]: #{reason}] Source #{self.source}, Rel #{self.relation}, Target #{self.target}"
+  end
+end