Class: ConvenientService::Utils::Array::Rjust
- Inherits:
-
Support::Command
- Object
- Support::Command
- ConvenientService::Utils::Array::Rjust
- Defined in:
- lib/convenient_service/utils/array/rjust.rb
Instance Attribute Summary collapse
-
#array ⇒ Object
readonly
Returns the value of attribute array.
-
#pad ⇒ Object
readonly
Returns the value of attribute pad.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
Methods inherited from Support::Command
Constructor Details
#initialize(array, size, pad = nil) ⇒ void
36 37 38 39 40 |
# File 'lib/convenient_service/utils/array/rjust.rb', line 36 def initialize(array, size, pad = nil) @array = array @size = size @pad = pad end |
Instance Attribute Details
#array ⇒ Object (readonly)
Returns the value of attribute array.
16 17 18 |
# File 'lib/convenient_service/utils/array/rjust.rb', line 16 def array @array end |
#pad ⇒ Object (readonly)
Returns the value of attribute pad.
28 29 30 |
# File 'lib/convenient_service/utils/array/rjust.rb', line 28 def pad @pad end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
22 23 24 |
# File 'lib/convenient_service/utils/array/rjust.rb', line 22 def size @size end |
Instance Method Details
#call ⇒ Array
45 46 47 48 49 50 51 |
# File 'lib/convenient_service/utils/array/rjust.rb', line 45 def call return array if size <= array.size count = size - array.size array + [pad] * count end |