Class: ConvenientService::Utils::Array::DropWhile

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Support::Command

[], call

Constructor Details

#initialize(array, inclusively: false, &condition_block) ⇒ void

Parameters:

  • array (Array)
  • inclusively (Boolean) (defaults to: false)
  • condition_block (Proc)


31
32
33
34
35
# File 'lib/convenient_service/utils/array/drop_while.rb', line 31

def initialize(array, inclusively: false, &condition_block)
  @array = array
  @inclusively = inclusively
  @condition_block = condition_block
end

Instance Attribute Details

#arrayObject (readonly)

Returns the value of attribute array.



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

def array
  @array
end

#condition_blockObject (readonly)

Returns the value of attribute condition_block.



23
24
25
# File 'lib/convenient_service/utils/array/drop_while.rb', line 23

def condition_block
  @condition_block
end

#inclusivelyObject (readonly)

Returns the value of attribute inclusively.



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

def inclusively
  @inclusively
end

Instance Method Details

#callArray

Returns:



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

def call
  remained_items = array.drop_while(&condition_block)

  remained_items = remained_items.drop(1) if inclusively

  remained_items
end