module Dopi::CommandParser::Arguments

Public Instance Methods

arguments() click to toggle source
# File lib/dopi/command_parser/arguments.rb, line 12
def arguments
  arguments_valid? ? parse_arguments : ""
end
validate_arguments() click to toggle source
# File lib/dopi/command_parser/arguments.rb, line 8
def validate_arguments
  log_validation_method('arguments_valid?', CommandParsingError)
end

Private Instance Methods

arguments_valid?() click to toggle source
# File lib/dopi/command_parser/arguments.rb, line 18
def arguments_valid?
  return false unless hash.kind_of?(Hash) # plugin may not have parameters
  return false if hash[:arguments].nil? # arguments are optional
  hash[:arguments].kind_of?(Hash) or
    hash[:arguments].kind_of?(Array) or
    hash[:arguments].kind_of?(String) or
    raise CommandParsingError, "The value for 'arguments' hast to be an Array, Hash or String"
end
parse_arguments() click to toggle source
# File lib/dopi/command_parser/arguments.rb, line 27
def parse_arguments
  case hash[:arguments]
  when Hash   then hash[:arguments].to_a.flatten.join(' ')
  when Array  then hash[:arguments].flatten.join(' ')
  when String then hash[:arguments]
  else ""
  end
end