Module: Tins::GO::ArrayExtension

Defined in:
lib/tins/go.rb

Overview

A module that provides extension methods for Strings let them double as arrays.

Instance Method Summary collapse

Instance Method Details

#push(argument) ⇒ self

Adds an element to the collection.

This method allows for chaining operations and collects multiple values for the same command-line option.

Parameters:

  • argument (Object)

    The element to add to the collection

Returns:

  • (self)

    Returns self to enable method chaining



28
29
30
31
32
# File 'lib/tins/go.rb', line 28

def push(argument)
  @arguments ||= []
  @arguments.push argument
  self
end

#to_aArray

The to_a method converts the object to an array.

Returns:

  • (Array)

    a new array containing the object’s elements



36
37
38
# File 'lib/tins/go.rb', line 36

def to_a
  @arguments
end