class RBT::Cookbooks::AllUrls

Public Class Methods

new( i = nil, run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/cookbooks/all_urls/all_urls.rb, line 36
def initialize(
    i           = nil,
    run_already = true
  )
  reset
  set_commandline_arguments(i)
  run if run_already
end

Public Instance Methods

check_for_commandline_arguments() click to toggle source
#

check_for_commandline_arguments

We will work on a String - no need to care for Symbols here.

#
# File lib/rbt/cookbooks/all_urls/all_urls.rb, line 87
def check_for_commandline_arguments
  case commandline_arguments?.join(' ').strip.to_s # case tag
  # ======================================================================= #
  # === all_urls --no-opn
  # ======================================================================= #
  when /-?-?no(_|-)?opn/,'disable_opn'
    no_opn
  # ======================================================================= #
  # === all_urls --help
  # ======================================================================= #
  when /^-?-?help/i
    show_help
  # when 'MISSING','--missing','missing'
  #   @show_only_missing_programs = true
  end
end
data?() click to toggle source
#

data?

#
# File lib/rbt/cookbooks/all_urls/all_urls.rb, line 117
def data?
  @array
end
Also aliased as: result?
display_start_message_to_the_user() click to toggle source
#

display_start_message_to_the_user

#
# File lib/rbt/cookbooks/all_urls/all_urls.rb, line 77
def display_start_message_to_the_user
  opne 'We will gather all URLs next - this may take a '\
       'short while. Please remain patient.'
end
report_result( i = data? ) click to toggle source
#

report_result

Here we can report the result, which is usually what we stored in our main array called @array.

#
# File lib/rbt/cookbooks/all_urls/all_urls.rb, line 149
def report_result(
    i = data?
  )
  index_counter = 0
  buffer_string = ''.dup # This will become the Xorg buffer-string.
  pad_right = ' ' * 33
  # ======================================================================= #
  # Next we iterate over our result.
  # ======================================================================= #
  i.each {|name_of_the_program, remote_url1, remote_url2|
    string_to_display = ''.dup
    name_of_the_program = name_of_the_program.strip
    increase_index_counter = true
    remote_url1 = remote_url1.to_s.strip
    index_counter += 1 if increase_index_counter
    colourized_counter = index_counter.to_s.rjust(7)
    colourized_counter = slateblue(index_counter)
    string_to_display << ('('+colourized_counter+') ').rjust(15)
    # ===================================================================== #
    # Build the return String next.
    # ===================================================================== #
    remote_url1 = colourize_this_link(remote_url1)
    string_to_display = ''.dup
    string_to_display << name_of_the_program.ljust(30)+
                         steelblue(' → ')
    string_to_display << remote_url1.strip.ljust(40)+N
    buffer_string << string_to_display
    if show_url2?
      remote_url2 = pad_right+remote_url2.strip
      buffer_string << string_to_display
      string_to_display << colourize_this_link(
        remote_url2
      )+N
      buffer_string << N
    end
    buffer_string << string_to_display
    e string_to_display
  }
  # ======================================================================= #
  # Also assign this to the xorg buffer.
  # ======================================================================= #
  set_the_xorg_buffer_next(buffer_string)
end
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::LeanPrototype#reset
# File lib/rbt/cookbooks/all_urls/all_urls.rb, line 48
def reset
  super()
  infer_the_namespace
  try_to_require_the_xorg_buffer
  # === @xorg_buffer
  @xorg_buffer = nil
  @array = []
  @use_opn = true # Whether to call opnn() or whether we don't.
  # === @also_show_url2
  @also_show_url2 = true # <- Whether to try to show url2, too.
end
result?()
Alias for: data?
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/cookbooks/all_urls/all_urls.rb, line 210
def run
  check_for_commandline_arguments
  display_start_message_to_the_user
  all_programs = available_programs?
  all_programs.each {|program|
    result = RBT.find_url_for(program) # bl $COOKBOOKS/module_methods/module_methods.rb
    url1 = result.first.to_s.strip
    url2 = result.last.to_s.strip
    @array << [program, url1, url2]
  }
  report_result
  save_result
end
save_result( into = " click to toggle source
#

save_result

#
# File lib/rbt/cookbooks/all_urls/all_urls.rb, line 131
def save_result(
    into        = "#{log_dir?}all_remote_webpages_of_the_programs.md",
    xorg_buffer = @xorg_buffer
  )
  if xorg_buffer
    what = xorg_buffer
    opne "#{rev}We will store this result in the "\
         "file `#{sfile(into)}#{rev}`."
    write_what_into(what, into)
  end
end
set_the_xorg_buffer_next(i = '') click to toggle source
#

set_the_xorg_buffer_next

#
# File lib/rbt/cookbooks/all_urls/all_urls.rb, line 196
def set_the_xorg_buffer_next(i = '')
  if i.empty?
    opne 'We can not set the xorg buffer as the input is empty.'
  else
    e; opne 'We will set the xorgbuffer next with the above '\
            'programs as our result.'
    @xorg_buffer = i
    set_xorg_buffer(@xorg_buffer)
  end
end
show_help() click to toggle source
#

show_help (help tag)

#
# File lib/rbt/cookbooks/all_urls/all_urls.rb, line 107
def show_help
  e
  e 'Use '+simp('--missing')+' if you wish to display only the programs'
  e 'without an URL entry.'
  e
end
show_url2?() click to toggle source
#

show_url2?

#
# File lib/rbt/cookbooks/all_urls/all_urls.rb, line 63
def show_url2?
  @also_show_url2
end
use_opn?() click to toggle source
#

use_opn?

#
# File lib/rbt/cookbooks/all_urls/all_urls.rb, line 70
def use_opn?
  @use_opn
end