class RBT::Action::Headers
Public Class Methods
[](i = ARGV)
click to toggle source
new( i = ARGV, run_already = true, &block )
click to toggle source
#¶ ↑
initialize¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/headers/headers.rb, line 31 def initialize( i = ARGV, run_already = true, &block ) reset set_commandline_arguments(i) case run_already # ======================================================================= # # === :do_not_run_yet # ======================================================================= # when :do_not_run_yet run_already = false end run if run_already end
Public Instance Methods
check_whether_the_input_is_a_header_file()
click to toggle source
#¶ ↑
check_whether_the_input_is_a_header_file
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/headers/headers.rb, line 122 def check_whether_the_input_is_a_header_file first_argument = first_argument? unless first_argument.end_with? '.h' e "#{steelblue(first_argument)} #{rev}does not seem to be a .h file." end end
load_up_the_registered_headers( i = RBT.file_registered_headers )
click to toggle source
#¶ ↑
load_up_the_registered_headers
¶ ↑
This method will simply load the registered .h (header) files, from the yaml file.
#¶ ↑
# File lib/rbt/actions/individual_actions/headers/headers.rb, line 72 def load_up_the_registered_headers( i = RBT.file_registered_headers ) @registered_headers = YAML.load_file(i) end
match?()
click to toggle source
report()
click to toggle source
#¶ ↑
report (report tag)¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/headers/headers.rb, line 110 def report if @match _ = first_argument? e "#{rev}The given input #{steelblue(_)} "\ "#{rev}matches to the program #{lightblue(@match)}#{rev}. "\ "(#{olivedrab(_)} #{tomato('→')} #{mediumpurple(@match)})" end end
reset()
click to toggle source
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
Calls superclass method
RBT::Action#reset
# File lib/rbt/actions/individual_actions/headers/headers.rb, line 51 def reset super() infer_the_namespace # ======================================================================= # # === @match # ======================================================================= # @match = nil # ======================================================================= # # === @do_report # # By default this class will not report. # ======================================================================= # @do_report = false end
run()
click to toggle source
try_to_find_a_match_for_the_given_input()
click to toggle source
#¶ ↑
try_to_find_a_match_for_the_given_input
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/headers/headers.rb, line 81 def try_to_find_a_match_for_the_given_input first_argument = first_argument? if first_argument.nil? e "#{rev}Please provide some input, such as #{steelblue('ao.h')}#{rev}." else # ===================================================================== # # First check whether such a file exists in the registered headers. # ===================================================================== # if @registered_headers.has_key? first_argument @match = @registered_headers[first_argument] else # else we need to find any .header file. if @registered_headers.keys.any? {|entry| entry.end_with?("/#{first_argument}") } selection = @registered_headers.select {|header_file, name_of_the_program_at_hand| header_file.end_with?("/#{first_argument}") } if selection.empty? e "#{rev}No match has been found for the given "\ "input #{steelblue(first_argument)}#{rev}." else @match = selection[selection.keys.first] end end end end end