Class: Leftovers::Collection

Inherits:
Object
  • Object
show all
Defined in:
lib/leftovers/collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCollection

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

#callsObject (readonly)

Returns the value of attribute calls.



7
8
9
# File 'lib/leftovers/collection.rb', line 7

def calls
  @calls
end

#definitionsObject (readonly)

Returns the value of attribute definitions.



7
8
9
# File 'lib/leftovers/collection.rb', line 7

def definitions
  @definitions
end

#test_callsObject (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

Returns:

  • (Boolean)


33
34
35
# File 'lib/leftovers/collection.rb', line 33

def empty?
  leftovers.empty?
end

#leftoversObject



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_testsObject



25
26
27
# File 'lib/leftovers/collection.rb', line 25

def with_tests
  split_leftovers.first
end

#without_testsObject



29
30
31
# File 'lib/leftovers/collection.rb', line 29

def without_tests
  split_leftovers[1]
end