Class: Solve::Problem
- Inherits:
-
Struct
- Object
- Struct
- Solve::Problem
- Defined in:
- lib/solve/solver/serializer.rb,
lib/solve/solver/serializer.rb
Overview
Simple struct class that contains a #graph and #demands (in Array form)
Can be serialized via Solver::Serializer to create a json representation of a dependency solving problem.
Instance Attribute Summary collapse
-
#demands ⇒ Object
Returns the value of attribute demands.
-
#graph ⇒ Object
Returns the value of attribute graph.
Class Method Summary collapse
-
.from_solver(solver) ⇒ Problem
Create a Problem from a given Solver.
Instance Attribute Details
#demands ⇒ Object
Returns the value of attribute demands
6 7 8 |
# File 'lib/solve/solver/serializer.rb', line 6 def demands @demands end |
#graph ⇒ Object
Returns the value of attribute graph
6 7 8 |
# File 'lib/solve/solver/serializer.rb', line 6 def graph @graph end |
Class Method Details
.from_solver(solver) ⇒ Problem
Create a Problem from a given Solver.
18 19 20 21 22 23 |
# File 'lib/solve/solver/serializer.rb', line 18 def self.from_solver(solver) demands_data = solver.demands.map do |demand| [ demand.name, demand.constraint.to_s ] end new(solver.graph, demands_data) end |