Class: TheoryCollection
Instance Attribute Summary collapse
-
#theories ⇒ Object
readonly
Returns the value of attribute theories.
Instance Method Summary collapse
- #actions ⇒ Object
- #components ⇒ Object
-
#dependents ⇒ Object
Returns all the dependents within the theories.
- #each_with_dependent_structure(structure) ⇒ Object
- #each_with_result_structure(structure) ⇒ Object
-
#initialize(theories) ⇒ TheoryCollection
constructor
A new instance of TheoryCollection.
- #results ⇒ Object
-
#same_structure_count(structure, approach) ⇒ Object
Returns the number of theories that have dependents or results that match the structure supplied.
-
#theory_variables ⇒ Object
Returns an array of all the uniq theory variables used.
Constructor Details
#initialize(theories) ⇒ TheoryCollection
Returns a new instance of TheoryCollection.
5 6 7 |
# File 'lib/theory/theory_collection.rb', line 5 def initialize(theories) @theories = theories end |
Instance Attribute Details
#theories ⇒ Object (readonly)
Returns the value of attribute theories.
3 4 5 |
# File 'lib/theory/theory_collection.rb', line 3 def theories @theories end |
Instance Method Details
#actions ⇒ Object
50 51 52 |
# File 'lib/theory/theory_collection.rb', line 50 def actions @theories.select {|x| x.action != nil}.inject([]) {|total,theory| total << theory.action } end |
#components ⇒ Object
54 55 56 |
# File 'lib/theory/theory_collection.rb', line 54 def components return dependents+results end |
#dependents ⇒ Object
Returns all the dependents within the theories
42 43 44 |
# File 'lib/theory/theory_collection.rb', line 42 def dependents @theories.inject([]) {|total,theory| total += theory.dependents } end |
#each_with_dependent_structure(structure) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/theory/theory_collection.rb', line 19 def each_with_dependent_structure(structure) @theories.each do |t| t.dependents.each do |d| if d.same_structure?(structure) yield t, d end end end end |
#each_with_result_structure(structure) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/theory/theory_collection.rb', line 9 def each_with_result_structure(structure) @theories.each do |t| t.results.each do |r| if r.same_structure?(structure) yield t, r end end end end |
#results ⇒ Object
46 47 48 |
# File 'lib/theory/theory_collection.rb', line 46 def results @theories.inject([]) {|total,theory| total += theory.results } end |
#same_structure_count(structure, approach) ⇒ Object
Returns the number of theories that have dependents or results that match the structure supplied.
34 35 36 37 38 |
# File 'lib/theory/theory_collection.rb', line 34 def same_structure_count(structure,approach) @theories.inject(0) do |total,theory| total += theory.send(approach).count {|x| x.same_structure?(structure)} end end |
#theory_variables ⇒ Object
Returns an array of all the uniq theory variables used.
59 60 61 |
# File 'lib/theory/theory_collection.rb', line 59 def theory_variables return @theories.inject([]) {|total,x| total += x.all_theory_variables}.uniq end |