class OctocatalogDiff::Cli::Options::Option

Define the Option class and newoption() method for use by cli/options/*.rb files

Public Class Methods

has_weight(w) click to toggle source
# File lib/octocatalog-diff/cli/options.rb, line 26
def self.has_weight(w) # rubocop:disable Style/PredicateName
  @weight = w
end
name() click to toggle source
# File lib/octocatalog-diff/cli/options.rb, line 46
def self.name
  self::NAME
end
newoption(name, &block) click to toggle source
# File lib/octocatalog-diff/cli/options.rb, line 50
def self.newoption(name, &block)
  klass = Class.new(OctocatalogDiff::Cli::Options::Option)
  klass.const_set('NAME', name)
  klass.class_exec(&block)
  Options.classes.push(klass)
end
order_within_weight(w) click to toggle source
# File lib/octocatalog-diff/cli/options.rb, line 30
def self.order_within_weight(w) # rubocop:disable Style/TrivialAccessors
  @order_within_weight = w
end
weight() click to toggle source
# File lib/octocatalog-diff/cli/options.rb, line 34
def self.weight
  if @weight && @order_within_weight
    @weight + (@order_within_weight / 100.0)
  elsif @weight
    @weight
  else
    # :nocov:
    raise ArgumentError, "Option #{name} does not have a weight specified. Add 'has_weight NNN' to control ordering."
    # :nocov:
  end
end