Class: Leftovers::Collection
- Inherits:
-
Object
- Object
- Leftovers::Collection
- Defined in:
- lib/leftovers/collection.rb
Instance Attribute Summary collapse
-
#calls ⇒ Object
readonly
Returns the value of attribute calls.
-
#definitions ⇒ Object
readonly
Returns the value of attribute definitions.
-
#test_calls ⇒ Object
readonly
Returns the value of attribute test_calls.
Instance Method Summary collapse
- #concat(calls:, definitions:, test:) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize ⇒ Collection
constructor
A new instance of Collection.
- #leftovers ⇒ Object
- #with_tests ⇒ Object
- #without_tests ⇒ Object
Constructor Details
#initialize ⇒ Collection
Returns a new instance of Collection.
9 10 11 12 13 |
# File 'lib/leftovers/collection.rb', line 9 def initialize @calls = [] @test_calls = [] @definitions = [] end |
Instance Attribute Details
#calls ⇒ Object (readonly)
Returns the value of attribute calls.
7 8 9 |
# File 'lib/leftovers/collection.rb', line 7 def calls @calls end |
#definitions ⇒ Object (readonly)
Returns the value of attribute definitions.
7 8 9 |
# File 'lib/leftovers/collection.rb', line 7 def definitions @definitions end |
#test_calls ⇒ Object (readonly)
Returns the value of attribute test_calls.
7 8 9 |
# File 'lib/leftovers/collection.rb', line 7 def test_calls @test_calls end |
Instance Method Details
#concat(calls:, definitions:, test:) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/leftovers/collection.rb', line 37 def concat(calls:, definitions:, test:) if test @test_calls.concat(calls) else @calls.concat(calls) end @definitions.concat(definitions) end |
#empty? ⇒ Boolean
33 34 35 |
# File 'lib/leftovers/collection.rb', line 33 def empty? leftovers.empty? end |
#leftovers ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/leftovers/collection.rb', line 15 def leftovers @leftovers ||= begin freeze_calls @definitions .reject { |definition| definition.in_collection?(self) } .sort_by(&:location_s).freeze end end |
#with_tests ⇒ Object
25 26 27 |
# File 'lib/leftovers/collection.rb', line 25 def with_tests split_leftovers.first end |
#without_tests ⇒ Object
29 30 31 |
# File 'lib/leftovers/collection.rb', line 29 def without_tests split_leftovers[1] end |