Module: Roebe::Base::CommandlineArguments

Included in:
Roebe::Base, Shell::Commandline
Defined in:
lib/roebe/base/commandline_arguments.rb

Instance Method Summary collapse

Instance Method Details

#append_onto_the_commandline_arguments(i) ⇒ Object Also known as: append_to_the_commandline

#

append_onto_the_commandline_arguments

#


33
34
35
36
37
# File 'lib/roebe/base/commandline_arguments.rb', line 33

def append_onto_the_commandline_arguments(i)
  @commandline_arguments << i
  @commandline_arguments.flatten!
  @commandline_arguments.compact!
end

#clear_commandline_argumentsObject

#

clear_commandline_arguments

#


64
65
66
# File 'lib/roebe/base/commandline_arguments.rb', line 64

def clear_commandline_arguments
  @commandline_arguments = []
end

#commandline_arguments?Boolean Also known as: commandline?, all_arguments?, arguments?

#

commandline_arguments?

#

Returns:

  • (Boolean)


24
25
26
# File 'lib/roebe/base/commandline_arguments.rb', line 24

def commandline_arguments?
  @commandline_arguments
end

#commandline_arguments_as_string?Boolean Also known as: commandline_arguments_as_string

#

commandline_arguments_as_string?

#

Returns:

  • (Boolean)


57
58
59
# File 'lib/roebe/base/commandline_arguments.rb', line 57

def commandline_arguments_as_string?
  @commandline_arguments.join(' ').strip
end

#commandline_arguments_without_leading_hyphens?Boolean Also known as: commandline_arguments_without_leading_hyphens, non_hyphened_commandline_arguments, commandline_arguments_without_hyphens?

#

commandline_arguments_without_leading_hyphens?

#

Returns:

  • (Boolean)


101
102
103
104
105
# File 'lib/roebe/base/commandline_arguments.rb', line 101

def commandline_arguments_without_leading_hyphens?
  @commandline_arguments.select {|entry|
    !entry.start_with? '--'
  }
end

#first_argument?Boolean Also known as: first?, first_commandline_argument?

#

first_argument?

#

Returns:

  • (Boolean)


42
43
44
# File 'lib/roebe/base/commandline_arguments.rb', line 42

def first_argument?
  @commandline_arguments.first
end

#first_argument_without_leading_hyphens?Boolean Also known as: return_first_non_hyphen_commandline_argument

#

first_argument_without_leading_hyphens?

This variant will return the first argument that does NOT have any leading “–”.

#

Returns:

  • (Boolean)


81
82
83
# File 'lib/roebe/base/commandline_arguments.rb', line 81

def first_argument_without_leading_hyphens?
  commandline_arguments_without_leading_hyphens?.first
end

#has_an_argument_been_passed?Boolean

#

has_an_argument_been_passed?

#

Returns:

  • (Boolean)


71
72
73
# File 'lib/roebe/base/commandline_arguments.rb', line 71

def has_an_argument_been_passed?
  !first_argument?.nil?
end

#remove_hyphened_arguments_from_the_commandline_arguments(commandline_arguments = commandline_arguments? ) ⇒ Object

#

remove_hyphened_arguments_from_the_commandline_arguments

#


112
113
114
115
116
117
118
# File 'lib/roebe/base/commandline_arguments.rb', line 112

def remove_hyphened_arguments_from_the_commandline_arguments(
    commandline_arguments = commandline_arguments?
  )
  commandline_arguments.reject! {|entry|
    entry.start_with? '--'
  }
end

#return_commandline_arguments_with_leading_hyphensObject Also known as: return_hyphenated_commandline_arguments, return_commandline_arguments_starting_with_hyphens, hyphened_arguments?, commandline_arguments_with_leading_hyphens?, commandline_arguments_with_hyphens?

#

return_commandline_arguments_with_leading_hyphens

#


88
89
90
91
92
# File 'lib/roebe/base/commandline_arguments.rb', line 88

def return_commandline_arguments_with_leading_hyphens
  @commandline_arguments.select {|entry|
    entry.start_with? '--'
  }
end

#second_argument?Boolean

#

second_argument?

#

Returns:

  • (Boolean)


50
51
52
# File 'lib/roebe/base/commandline_arguments.rb', line 50

def second_argument?
  @commandline_arguments[1]
end

#set_commandline_arguments(i = ARGV) ⇒ Object Also known as: set_input

#

set_commandline_arguments

#


17
18
19
# File 'lib/roebe/base/commandline_arguments.rb', line 17

def set_commandline_arguments(i = ARGV)
  @commandline_arguments = [i].flatten.compact
end