Class: Solve::Problem

Inherits:
Struct
  • Object
show all
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

Class Method Summary collapse

Instance Attribute Details

#demandsObject

Returns the value of attribute demands

Returns:

  • (Object)

    the current value of demands



6
7
8
# File 'lib/solve/solver/serializer.rb', line 6

def demands
  @demands
end

#graphObject

Returns the value of attribute graph

Returns:

  • (Object)

    the current value of 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.

Parameters:

Returns:



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