class Rototiller::Task::ParamCollection

The base ParamCollection class to collect more than one parameter for a task, or other parameters

delegates to Array for most of Array's methods

@since v0.1.0

Public Class Methods

new() click to toggle source

setup the collection as a composed Array @return the collection

# File lib/rototiller/task/collections/param_collection.rb, line 17
def initialize
  @collection = []
end

Public Instance Methods

messages() click to toggle source

format the messages inside this ParamCollection @return [String] messages from the contents of this ParamCollection

# File lib/rototiller/task/collections/param_collection.rb, line 31
def messages
  @collection.map { |param| param.message }.join('')
end
push(*args) click to toggle source

push to the collection @param [Param] args instances of the child classes allowed_class @return the new collection

# File lib/rototiller/task/collections/param_collection.rb, line 24
def push(*args)
  check_classes(allowed_class, *args)
  @collection.push(*args)
end
stop?() click to toggle source

Do any of the contents of this ParamCollection require the task to stop @return [true, nil] should the values of this ParamCollection stop the task

# File lib/rototiller/task/collections/param_collection.rb, line 37
def stop?
  @collection.any?{ |param| param.stop }
end
to_s()
Alias for: to_str
to_str() click to toggle source

convert a ParamCollection to a string

the value sent by author, or overridden by any EnvVar

@return [String] the Param's value

# File lib/rototiller/task/collections/param_collection.rb, line 44
def to_str
  @collection.join(' ') unless @collection.empty?
end
Also aliased as: to_s

Private Instance Methods

check_classes(allowed_klass, *args) click to toggle source

@private

# File lib/rototiller/task/collections/param_collection.rb, line 52
def check_classes(allowed_klass, *args)

  args.each do |arg|

    unless arg.is_a?(allowed_klass)
      argument_error = "Argument was of class #{arg.class}, Can only be of class #{allowed_klass}"
      raise(ArgumentError, argument_error)
    end
  end
end