Class: ConvenientService::Utils::Array::FindLast
- Inherits:
-
Support::Command
- Object
- Support::Command
- ConvenientService::Utils::Array::FindLast
- Defined in:
- lib/convenient_service/utils/array/find_last.rb
Instance Attribute Summary collapse
-
#array ⇒ Object
readonly
Returns the value of attribute array.
-
#block ⇒ Object
readonly
Returns the value of attribute block.
Instance Method Summary collapse
-
#call ⇒ Object
Can be any type.
- #initialize(array, &block) ⇒ void constructor
Methods inherited from Support::Command
Constructor Details
#initialize(array, &block) ⇒ void
24 25 26 27 |
# File 'lib/convenient_service/utils/array/find_last.rb', line 24 def initialize(array, &block) @array = array @block = block end |
Instance Attribute Details
#array ⇒ Object (readonly)
Returns the value of attribute array.
11 12 13 |
# File 'lib/convenient_service/utils/array/find_last.rb', line 11 def array @array end |
#block ⇒ Object (readonly)
Returns the value of attribute block.
17 18 19 |
# File 'lib/convenient_service/utils/array/find_last.rb', line 17 def block @block end |
Instance Method Details
#call ⇒ Object
Note:
Works with custom Enumerable
objects.
Returns Can be any type.
35 36 37 38 39 |
# File 'lib/convenient_service/utils/array/find_last.rb', line 35 def call array.reverse_each { |item| return item if block.call(item) } nil end |