class Somemoji::CommandLineArguments

Public Class Methods

new(argv) click to toggle source

@param argv [Array<String>]

# File lib/somemoji/command_line_arguments.rb, line 4
def initialize(argv)
  @argv = argv
end

Public Instance Methods

destination() click to toggle source

@return [String]

# File lib/somemoji/command_line_arguments.rb, line 9
def destination
  slop_parse_result[:destination]
end
error_message() click to toggle source

@return [String]

# File lib/somemoji/command_line_arguments.rb, line 14
def error_message
  slop_options.to_s
end
format() click to toggle source

@return [String, nil]

# File lib/somemoji/command_line_arguments.rb, line 19
def format
  slop_parse_result[:format]
end
provider_name() click to toggle source

@return [String]

# File lib/somemoji/command_line_arguments.rb, line 24
def provider_name
  slop_parse_result[:provider]
end
size() click to toggle source

@return [Integer, nil]

# File lib/somemoji/command_line_arguments.rb, line 29
def size
  slop_parse_result[:size]
end
valid?() click to toggle source

@return [Boolean]

# File lib/somemoji/command_line_arguments.rb, line 34
def valid?
   command_name == "extract" && !slop_parse_result.nil?
end

Private Instance Methods

command_name() click to toggle source

@return [String]

# File lib/somemoji/command_line_arguments.rb, line 41
def command_name
  @argv[0]
end
slop_options() click to toggle source

@return [Slop::Options]

# File lib/somemoji/command_line_arguments.rb, line 46
def slop_options
  @slop_options ||= begin
    if using_slop_version_4?
      slop_options = ::Slop::Options.new
      slop_options.banner = "Usage: somemoji extract [options]"
      slop_options.string "-p", "--provider", "(required) apple, emoji_one, noto, or twemoji"
      slop_options.string "-d", "--destination", "(required) directory path to locate extracted image files"
      slop_options.string "-f", "--format", "png or svg (default: png)"
      slop_options.integer "-s", "--size", "Some providers have different size image files"
      slop_options.bool "-h", "--help", "Display this help message"
      slop_options
    else
      ::Slop.new do
        banner "Usage: somemoji extract [options]"
        on "p", "provider=", "(required) apple, emoji_one, noto, or twemoji"
        on "d", "destination=", "(required) directory path to locate extracted image files"
        on "f", "format=", "png or svg (default: png)"
        on "s", "size=", "Some providers have different size image files"
        on "h", "help", "Display this help message"
      end
    end
  end
end
slop_parse_result() click to toggle source

@return [Slop::Result]

# File lib/somemoji/command_line_arguments.rb, line 71
def slop_parse_result
  @slop_parse_result ||= begin
    if using_slop_version_4?
      ::Slop::Parser.new(slop_options).parse(@argv)
    else
      slop_options.parse!(@argv)
      slop_options
    end
  end
rescue ::Slop::Error
end
using_slop_version_4?() click to toggle source

@return [Boolean]

# File lib/somemoji/command_line_arguments.rb, line 84
def using_slop_version_4?
  ::Slop::VERSION >= "4.0.0"
end