Class: ConvenientService::Utils::Array::FindLast Private

Inherits:
Support::Command show all
Defined in:
lib/convenient_service/utils/array/find_last.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Support::Command

[], call

Constructor Details

#initialize(array, &block) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • array (Array, Enumerable)
  • block (Proc, nil)

Since:

  • 1.0.0



29
30
31
32
# File 'lib/convenient_service/utils/array/find_last.rb', line 29

def initialize(array, &block)
  @array = array
  @block = block
end

Instance Attribute Details

#arrayObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0



16
17
18
# File 'lib/convenient_service/utils/array/find_last.rb', line 16

def array
  @array
end

#blockObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0



22
23
24
# File 'lib/convenient_service/utils/array/find_last.rb', line 22

def block
  @block
end

Instance Method Details

#callObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

Works with custom Enumerable objects.

Returns Can be any type.

Returns:

  • (Object)

    Can be any type.

See Also:

Since:

  • 1.0.0



40
41
42
43
44
# File 'lib/convenient_service/utils/array/find_last.rb', line 40

def call
  array.reverse_each { |item| return item if block.call(item) }

  nil
end