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
31 32 33 34 35 |
# File 'lib/convenient_service/utils/array/rjust.rb', line 31 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.
11 12 13 |
# File 'lib/convenient_service/utils/array/rjust.rb', line 11 def array @array end |
#pad ⇒ Object (readonly)
Returns the value of attribute pad.
23 24 25 |
# File 'lib/convenient_service/utils/array/rjust.rb', line 23 def pad @pad end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
17 18 19 |
# File 'lib/convenient_service/utils/array/rjust.rb', line 17 def size @size end |
Instance Method Details
#call ⇒ Array
40 41 42 43 44 45 46 |
# File 'lib/convenient_service/utils/array/rjust.rb', line 40 def call return array if size <= array.size count = size - array.size array + [pad] * count end |