Class: Pacer::Neo4j::Algo::BlockCostEvaluator
- Inherits:
-
Object
- Object
- Pacer::Neo4j::Algo::BlockCostEvaluator
- Includes:
- CostEvaluator
- Defined in:
- lib/pacer-neo4j/algo/block_cost_evaluator.rb
Constant Summary collapse
- DIRS =
{ Direction::INCOMING => :in, Direction::OUTGOING => :out, Direction::BOTH => :both }
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#graph ⇒ Object
readonly
Returns the value of attribute graph.
Instance Method Summary collapse
- #getCost(rel, dir) ⇒ Object
-
#initialize(block, graph, default) ⇒ BlockCostEvaluator
constructor
A new instance of BlockCostEvaluator.
Constructor Details
#initialize(block, graph, default) ⇒ BlockCostEvaluator
Returns a new instance of BlockCostEvaluator.
18 19 20 21 22 |
# File 'lib/pacer-neo4j/algo/block_cost_evaluator.rb', line 18 def initialize(block, graph, default) @block = block @graph = graph @default = default.to_f end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
16 17 18 |
# File 'lib/pacer-neo4j/algo/block_cost_evaluator.rb', line 16 def block @block end |
#default ⇒ Object (readonly)
Returns the value of attribute default.
16 17 18 |
# File 'lib/pacer-neo4j/algo/block_cost_evaluator.rb', line 16 def default @default end |
#graph ⇒ Object (readonly)
Returns the value of attribute graph.
16 17 18 |
# File 'lib/pacer-neo4j/algo/block_cost_evaluator.rb', line 16 def graph @graph end |
Instance Method Details
#getCost(rel, dir) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/pacer-neo4j/algo/block_cost_evaluator.rb', line 24 def getCost(rel, dir) e = Pacer::Wrappers::EdgeWrapper.new graph, Neo4jEdge.new(rel, graph.blueprints_graph) result = block.call e, DIRS[dir] if result.is_a? Numeric result.to_f elsif default default else fail Pacer::ClientError, "No cost returned and no default specified: #{ result.inspect }" end end |