Module: Studium::CommandlineArgumentsModule
- Included in:
- Base
- Defined in:
- lib/studium/base/commandline_arguments_module/commandline_arguments_module.rb
Overview
Studium::CommandlineArgumentsModule
Instance Method Summary
collapse
Instance Method Details
#commandline_arguments? ⇒ Boolean
Also known as:
commandline?
#
commandline_arguments?
#
37
38
39
|
# File 'lib/studium/base/commandline_arguments_module/commandline_arguments_module.rb', line 37
def commandline_arguments?
@internal_hash[:commandline_arguments]
end
|
#commandline_arguments_joined ⇒ Object
Also known as:
return_commandline_arguments_as_string, commandline_arguments_as_string, commandline_arguments_as_string?, commandline_string?, commandline_as_string, return_original_input_as_string
#
commandline_arguments_joined
This method will, essentially, return all commandline-arguments as a String.
#
61
62
63
|
# File 'lib/studium/base/commandline_arguments_module/commandline_arguments_module.rb', line 61
def commandline_arguments_joined
commandline_arguments?.join(' ').strip
end
|
#commandline_arguments_with_hyphens? ⇒ Boolean
Also known as:
return_commandline_arguments_with_leading_hyphens, commandline_arguments_with_leading_hyphens?, return_hyphened_commandline_arguments, hyphened_commandline_arguments?
#
commandline_arguments_with_hyphens?
This method will select all the commandline arguments that begin with ‘–’ hyphens.
#
76
77
78
79
80
|
# File 'lib/studium/base/commandline_arguments_module/commandline_arguments_module.rb', line 76
def commandline_arguments_with_hyphens?
commandline_arguments?.select {|entry|
entry.start_with?('--')
}
end
|
#commandline_arguments_without_leading_hyphens? ⇒ Boolean
#
commandline_arguments_without_leading_hyphens?
#
88
89
90
91
92
|
# File 'lib/studium/base/commandline_arguments_module/commandline_arguments_module.rb', line 88
def commandline_arguments_without_leading_hyphens?
return commandline_arguments?.select {|entry|
!entry.start_with?('--')
}
end
|
#first_argument? ⇒ Boolean
Also known as:
first?
#
first_argument?
This method will attempt to return the first commandline argument given.
#
47
48
49
50
51
52
53
|
# File 'lib/studium/base/commandline_arguments_module/commandline_arguments_module.rb', line 47
def first_argument?
if @internal_hash[:commandline_arguments]
return @internal_hash[:commandline_arguments].first
else
return nil
end
end
|
#first_non_hyphen_argument? ⇒ Boolean
#
first_non_hyphen_argument?
#
97
98
99
100
101
|
# File 'lib/studium/base/commandline_arguments_module/commandline_arguments_module.rb', line 97
def first_non_hyphen_argument?
return commandline_arguments?.select {|entry|
!entry.start_with?('--')
}.first
end
|
#reset_the_commandline_arguments ⇒ Object
#
reset_the_commandline_arguments
This method will reset @internal_hash.
#
18
19
20
21
22
23
24
25
|
# File 'lib/studium/base/commandline_arguments_module/commandline_arguments_module.rb', line 18
def reset_the_commandline_arguments
_ = @internal_hash[:commandline_arguments]
if _ and _.is_a?(Array)
_.clear
else
_ = []
end
end
|
#set_commandline_arguments(i = ARGV) ⇒ Object
#
set_commandline_arguments
The commandline arguments are always an Array.
#
108
109
110
111
112
113
|
# File 'lib/studium/base/commandline_arguments_module/commandline_arguments_module.rb', line 108
def set_commandline_arguments(
i = ARGV
)
i = [i].flatten.compact
@internal_hash[:commandline_arguments] = i
end
|
#set_first_argument(i) ⇒ Object
30
31
32
|
# File 'lib/studium/base/commandline_arguments_module/commandline_arguments_module.rb', line 30
def set_first_argument(i)
@internal_hash[:commandline_arguments][0] = i
end
|