Sha256: 195c8056a1e10c598946b45460501f0116a8d9219caa1b60e2bba9ec815d3614
Contents?: true
Size: 1.26 KB
Versions: 5
Compression:
Stored size: 1.26 KB
Contents
class EcoRake class Option module Mirror # It allows to redirect options # @param value [String, Symbol] the value to use. # @return [String] command option with value def mirror(value = :not_used, raise: false) opt = name_hyphened return boolean_mirror(value) unless argument? missing = (value == :not_used) && !default? msg = "required argument value #{argument} for option #{name} (#{short})" raise ArgumentError, msg if missing && argument_required? && raise return nil if missing && argument_required? value = default if value == :not_used "#{opt} \"#{value}\"" end private # Implements the mirror of Boolean options/switches. def boolean_mirror(value = :not_used) opt = name_hyphened # puts "boolean_mirror (#{value}): #{opt}" if name == :no_get return nil unless [TrueClass, NilClass, FalseClass].any? {|klass| type_coercion == klass} enabled_value = !boolean_name? || [TrueClass, NilClass].any? {|klass| type_coercion == klass} return opt if value == enabled_value name_false_hypen if boolean_name? && value == !enabled_value end end end end
Version data entries
5 entries across 5 versions & 1 rubygems