Class: ConvenientService::Utils::Array::KeepAfter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Support::Command

[], call

Constructor Details

#initialize(array, object) ⇒ void

Parameters:



24
25
26
27
# File 'lib/convenient_service/utils/array/keep_after.rb', line 24

def initialize(array, object)
  @array = array
  @object = object
end

Instance Attribute Details

#arrayObject (readonly)

Returns the value of attribute array.



11
12
13
# File 'lib/convenient_service/utils/array/keep_after.rb', line 11

def array
  @array
end

#objectObject (readonly)

Returns the value of attribute object.



17
18
19
# File 'lib/convenient_service/utils/array/keep_after.rb', line 17

def object
  @object
end

Instance Method Details

#callObject?

Returns Can be any type.



33
34
35
36
37
# File 'lib/convenient_service/utils/array/keep_after.rb', line 33

def call
  return [] unless array.include?(object)

  Utils::Array.drop_while(array, inclusively: true) { |item| item != object }
end