Module: Bioroebe::CommandlineArguments
Overview
Bioroebe::CommandlineApplication
Constant Summary
Bioroebe::ColoursForBase::ARRAY_HTML_COLOURS_IN_USE
Instance Method Summary
collapse
-
#commandline_arguments? ⇒ Boolean
# === commandline_arguments?.
-
#commandline_arguments_that_are_files? ⇒ Boolean
# === commandline_arguments_that_are_files?.
-
#e(i = '') ⇒ Object
# === e ========================================================================= #.
-
#first? ⇒ Boolean
(also: #first_argument?, #first_argument, #input_file?, #first_commandline_argument?)
# === first? ========================================================================= #.
-
#first_non_hyphen_argument? ⇒ Boolean
(also: #first_non_hyphened_argument?)
# === first_non_hyphen_argument? ========================================================================= #.
-
#remove_hyphens_from_the_commandline_arguments(i = @commandline_arguments) ⇒ Object
(also: #remove_hyphens_from)
# === remove_hyphens_from_the_commandline_arguments ========================================================================= #.
-
#reset ⇒ Object
# === reset.
-
#return_commandline_arguments_as_string ⇒ Object
# === return_commandline_arguments_as_string.
-
#return_commandline_arguments_that_are_not_files ⇒ Object
# === return_commandline_arguments_that_are_not_files.
-
#return_entries_without_two_leading_hyphens(i = @commandline_arguments) ⇒ Object
(also: #return_commandline_arguments_without_hyphen)
# === return_entries_without_two_leading_hyphens.
-
#select_commandline_arguments(i = @commandline_arguments) ⇒ Object
# === select_commandline_arguments.
-
#select_entries_starting_with_two_hyphens(i = commandline_arguments? ) ⇒ Object
(also: #return_commandline_arguments_starting_with_hyphens, #return_entries_with_two_leading_hyphens_from, #return_arguments_with_leading_hyphens, #return_commandline_arguments_starting_with_two_hyphens, #commandline_arguments_containing_hyphens?, #commandline_arguments_containing_leading_hyphens?, #commandline_arguments_with_two_leading_hyphens, #commandline_arguments_starting_with_leading_hyphens?, #select_two_hyphens_from)
# === select_entries_starting_with_two_hyphens.
-
#set_commandline_arguments(i = ARGV) ⇒ Object
# === set_commandline_arguments.
#colourize_this_aminoacid_sequence_for_the_commandline, #colourize_this_nucleotide_sequence, #disable_colours, #ecomment, #efancy, #egold, #enable_colours, #eorange, #eparse, #erev, #red, #remove_trailing_escape_part, #return_colour_for_nucleotides, #rev, #sdir, #set_use_colours, #sfancy, #sfile, #simp, #swarn, #use_colours?, #use_colours_within_the_bioroebe_namespace?
Instance Method Details
#commandline_arguments? ⇒ Boolean
#
commandline_arguments?
Query method to obtain all commandline arguments given to this class.
#
38
39
40
|
# File 'lib/bioroebe/base/commandline_application/commandline_arguments.rb', line 38
def commandline_arguments?
@commandline_arguments
end
|
#commandline_arguments_that_are_files? ⇒ Boolean
#
commandline_arguments_that_are_files?
This method will select the entries that are a file (which must exist locally).
#
58
59
60
|
# File 'lib/bioroebe/base/commandline_application/commandline_arguments.rb', line 58
def commandline_arguments_that_are_files?
@commandline_arguments.select {|entry| File.file?(entry.to_s) }
end
|
#e(i = '') ⇒ Object
18
19
20
|
# File 'lib/bioroebe/base/commandline_application/commandline_arguments.rb', line 18
def e(i = '')
puts i
end
|
#first? ⇒ Boolean
Also known as:
first_argument?, first_argument, input_file?, first_commandline_argument?
45
46
47
|
# File 'lib/bioroebe/base/commandline_application/commandline_arguments.rb', line 45
def first?
@commandline_arguments.first
end
|
#first_non_hyphen_argument? ⇒ Boolean
Also known as:
first_non_hyphened_argument?
#
first_non_hyphen_argument?
#
117
118
119
|
# File 'lib/bioroebe/base/commandline_application/commandline_arguments.rb', line 117
def first_non_hyphen_argument?
return_entries_without_two_leading_hyphens.first
end
|
#remove_hyphens_from_the_commandline_arguments(i = @commandline_arguments) ⇒ Object
Also known as:
remove_hyphens_from
#
remove_hyphens_from_the_commandline_arguments
#
99
100
101
102
103
|
# File 'lib/bioroebe/base/commandline_application/commandline_arguments.rb', line 99
def remove_hyphens_from_the_commandline_arguments(
i = @commandline_arguments
)
i.reject! {|entry| entry.start_with? '--' }
end
|
#reset ⇒ Object
#
reset
We only define two instance variables here.
#
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/bioroebe/base/commandline_application/reset.rb', line 18
def reset
super()
infer_the_namespace
@commandline_arguments = []
set_be_verbose
@use_colours = true
end
|
#return_commandline_arguments_as_string ⇒ Object
#
return_commandline_arguments_as_string
This method will return the commandline arguments as a String.
#
110
111
112
|
# File 'lib/bioroebe/base/commandline_application/commandline_arguments.rb', line 110
def return_commandline_arguments_as_string
@commandline_arguments.join(' ').strip
end
|
#return_commandline_arguments_that_are_not_files ⇒ Object
#
return_commandline_arguments_that_are_not_files
This method will grab all entries that are NOT files.
#
67
68
69
|
# File 'lib/bioroebe/base/commandline_application/commandline_arguments.rb', line 67
def return_commandline_arguments_that_are_not_files
@commandline_arguments.reject {|entry| File.file?(entry.to_s) }
end
|
#return_entries_without_two_leading_hyphens(i = @commandline_arguments) ⇒ Object
Also known as:
return_commandline_arguments_without_hyphen
#
return_entries_without_two_leading_hyphens
This variant will return all entries WITHOUT leading hyphens.
#
76
77
78
79
80
|
# File 'lib/bioroebe/base/commandline_application/commandline_arguments.rb', line 76
def return_entries_without_two_leading_hyphens(
i = @commandline_arguments
)
i.reject {|entry| entry.start_with? '--' }
end
|
#select_commandline_arguments(i = @commandline_arguments) ⇒ Object
#
select_commandline_arguments
This method can be used to select commandline arguments that begin with – hyphens.
#
88
89
90
91
92
93
94
|
# File 'lib/bioroebe/base/commandline_application/commandline_arguments.rb', line 88
def select_commandline_arguments(
i = @commandline_arguments
)
i.select {|entry|
entry.start_with? '--'
}
end
|
#select_entries_starting_with_two_hyphens(i = commandline_arguments?
) ⇒ Object
Also known as:
return_commandline_arguments_starting_with_hyphens, return_entries_with_two_leading_hyphens_from, return_arguments_with_leading_hyphens, return_commandline_arguments_starting_with_two_hyphens, commandline_arguments_containing_hyphens?, commandline_arguments_containing_leading_hyphens?, commandline_arguments_with_two_leading_hyphens, commandline_arguments_starting_with_leading_hyphens?, select_two_hyphens_from
#
select_entries_starting_with_two_hyphens
This entry can, specifically, be used to filter out proper commandline arguments from an Array (such as ARGV).
#
128
129
130
131
132
133
134
135
136
|
# File 'lib/bioroebe/base/commandline_application/commandline_arguments.rb', line 128
def select_entries_starting_with_two_hyphens(
i = commandline_arguments?
)
if i.respond_to? :select
i.select {|entry| entry.to_s.start_with? '--' } else
[]
end
end
|
#set_commandline_arguments(i = ARGV) ⇒ Object
#
set_commandline_arguments
This method can be used to set the commandline arguments, which usually refers to ARGV.
#
28
29
30
31
|
# File 'lib/bioroebe/base/commandline_application/commandline_arguments.rb', line 28
def set_commandline_arguments(i = ARGV)
i = [i].flatten.compact
@commandline_arguments = i
end
|