class ImageParadise::MagicCardBorder

Public Class Methods

new( i = ARGV, run_already = true ) { || ... } click to toggle source
#

initialize

#
# File lib/image_paradise/utility_scripts/magic_card_border.rb, line 29
def initialize(
    i           = ARGV,
    run_already = true,
    &block
  )
  reset
  set_commandline_arguments(i)
  # ======================================================================= #
  # === Handle blocks next
  # ======================================================================= #
  if block_given?
    yielded = yield
    if yielded.is_a? Hash
      # =================================================================== #
      # === :output_file
      # =================================================================== #
      if yielded.has_key? :output_file
        set_output_file(yielded[:output_file])
      end
    end
  end
  run if run_already
end

Public Instance Methods

menu( i = commandline_arguments_via_leading_hyphens ) click to toggle source
#

menu (menu tag)

#
n_pixels?() click to toggle source
#

n_pixels?

#
# File lib/image_paradise/utility_scripts/magic_card_border.rb, line 77
def n_pixels?
  @n_pixels
end
output_file?() click to toggle source
#

output_file?

#
# File lib/image_paradise/utility_scripts/magic_card_border.rb, line 84
def output_file?
  @output_file
end
reset() click to toggle source
#

reset (reset tag)

#
# File lib/image_paradise/utility_scripts/magic_card_border.rb, line 56
def reset
  # ======================================================================= #
  # === @n_pixels
  # ======================================================================= #
  @n_pixels = 10
  # ======================================================================= #
  # This specifies the default output file.
  # ======================================================================= #
  @output_file = :default
end
run() click to toggle source
#

run (run tag)

#
# File lib/image_paradise/utility_scripts/magic_card_border.rb, line 175
def run
  menu
  i = commandline_arguments_as_stripped_string
  sanitize_the_name_of_the_output_file_based_on_this_input(i)
  if File.exist? i
    _ = ::ImageParadise.add_border_to_this_image(i, @n_pixels, 'black', @output_file)
    result = ::ImageParadise.rounded_corner(_, @output_file)
    return result
  else
    print ::Colours.rev
    opnn; e 'No file exists at `'+sfile(i)+'`.'
    return nil
  end
end
sanitize_the_name_of_the_output_file_based_on_this_input( i = :default ) click to toggle source
#

sanitize_the_name_of_the_output_file

Note that this method will always apply File.absolute_path().

#
# File lib/image_paradise/utility_scripts/magic_card_border.rb, line 93
def sanitize_the_name_of_the_output_file_based_on_this_input(
    i = :default
  )
  case i
  when nil
    i = 'foobar.png'
  else
    # This also covers :default
    if i == :default
      i = 'foobar.png'
    end
    # ===================================================================== #
    # In this case we need to use the default.
    # ===================================================================== #
    i = File.basename("output_#{i}")
  end
  i = File.absolute_path(i)
  set_output_file(i)
end
set_n_pixels(i) click to toggle source
#

set_n_pixels

#
# File lib/image_paradise/utility_scripts/magic_card_border.rb, line 70
def set_n_pixels(i)
  @n_pixels = i.to_i
end
Also aliased as: set_size
set_output_file(i) click to toggle source
#

set_output_file

This is simply a setter - it may not modify anything when invoked.

#
# File lib/image_paradise/utility_scripts/magic_card_border.rb, line 118
def set_output_file(i)
  @output_file = i
end
set_size(i)
Alias for: set_n_pixels
show_help() click to toggle source
#

show_help

Invoke this method via:

magic-rounded --help
#
# File lib/image_paradise/utility_scripts/magic_card_border.rb, line 130
def show_help
  e 'This class presently supports the following commandline options:'
  e
  e '  ----size=(n) # where n should be a number. This '\
    'specifies the size of the rounded border.'
  e
  e 'Example for this commandline flag:'
  e
  e ::Colours.tomato('  magic-rounded --size=5')
  e
end