Class: Crystalball::RSpec::PredictionPruning::ExamplesPruner

Inherits:
Object
  • Object
show all
Defined in:
lib/crystalball/rspec/prediction_pruning/examples_pruner.rb

Overview

A class to prune given world example groups to fit the limit.

Defined Under Namespace

Classes: ContextIdsSet

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rspec_world, to:) ⇒ ExamplesPruner

Returns a new instance of ExamplesPruner.

Parameters:

  • rspec_world (RSpec::Core::World)

    RSpec world instance

  • to (Integer)

    upper bound limit for prediction.



28
29
30
31
# File 'lib/crystalball/rspec/prediction_pruning/examples_pruner.rb', line 28

def initialize(rspec_world, to:)
  @world = rspec_world
  @limit = to
end

Instance Attribute Details

#limitObject (readonly)

Returns the value of attribute limit.



24
25
26
# File 'lib/crystalball/rspec/prediction_pruning/examples_pruner.rb', line 24

def limit
  @limit
end

#worldObject (readonly)

Returns the value of attribute world.



24
25
26
# File 'lib/crystalball/rspec/prediction_pruning/examples_pruner.rb', line 24

def world
  @world
end

Instance Method Details

#pruned_setArray<String>

Returns set of example and context ids to run.

Returns:

  • (Array<String>)

    set of example and context ids to run



34
35
36
37
38
# File 'lib/crystalball/rspec/prediction_pruning/examples_pruner.rb', line 34

def pruned_set
  resulting_set = ContextIdsSet.new
  world.ordered_example_groups.each { |g| prune_to_limit(g, resulting_set) }
  resulting_set.to_a
end