class SolrMakr::OptionDefinition
@api private
Public Instance Methods
add_to_command!(command)
click to toggle source
@param [Commander::Command] command @return [void]
# File lib/solr_makr/meta/option_definition.rb, line 18 def add_to_command!(command) command.option *commander_tuple end
commander_tuple()
click to toggle source
@return [Array]
# File lib/solr_makr/meta/option_definition.rb, line 60 def commander_tuple [].tap do |ary| ary << "-#{short_name}" if short_name.present? ary << long_name_with_value ary << type if type.present? ary << full_description if full_description.present? end end
default_long_name()
click to toggle source
@api private @return [String]
# File lib/solr_makr/meta/option_definition.rb, line 55 def default_long_name name.dasherize end
has_default?()
click to toggle source
# File lib/solr_makr/meta/option_definition.rb, line 22 def has_default? !default_value.nil? end
long_name_with_value()
click to toggle source
# File lib/solr_makr/meta/option_definition.rb, line 69 def long_name_with_value [].tap do |ary| ary << "--#{long_name}" unless type.blank? ary << ( value_name.presence || name.upcase ) end end.join(' ') end
set_default!(args, options)
click to toggle source
@param [<String>] args @param [Commander::Command::Options] options @return [void]
# File lib/solr_makr/meta/option_definition.rb, line 29 def set_default!(args, options) return unless has_default? case default_value when Proc options.default name => default_value.call when Symbol options.default name => options[default_value] else options.default name => default_value end return end
valid_in?(options)
click to toggle source
@param [Commander::Command::Options] options
# File lib/solr_makr/meta/option_definition.rb, line 45 def valid_in?(options) if required? return options[name].present? end return true end