Class: ConvenientService::Utils::Array::LimitedPush Private

Inherits:
Support::Command show all
Defined in:
lib/convenient_service/utils/array/limited_push.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

Defined Under Namespace

Modules: Constants

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Support::Command

[], call

Constructor Details

#initialize(array, object, limit: Constants::DEFAULT_LIMIT) ⇒ 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:

Since:

  • 1.0.0



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

def initialize(array, object, limit: Constants::DEFAULT_LIMIT)
  @array = array
  @object = object
  @limit = limit
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



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

def array
  @array
end

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



35
36
37
# File 'lib/convenient_service/utils/array/limited_push.rb', line 35

def limit
  @limit
end

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



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

def object
  @object
end

Instance Method Details

#callArray<Object>

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.

Returns:

Since:

  • 1.0.0



51
52
53
54
55
# File 'lib/convenient_service/utils/array/limited_push.rb', line 51

def call
  return array if array.size >= limit

  array.push(object)
end