Class: OptParseValidator::OptAlias

Inherits:
OptBase
  • Object
show all
Defined in:
lib/opt_parse_validator/opts/alias.rb

Overview

Implementation of the Alias Option

Instance Attribute Summary

Attributes inherited from OptBase

#attrs, #option, #required

Instance Method Summary collapse

Methods inherited from OptBase

#advanced?, #choices, #default, #help_message_for_default, #help_messages, #normalize, #required?, #required_unless, #to_long, #to_s, #to_sym, #validate, #value_if_empty

Constructor Details

#initialize(option, attrs = {}) ⇒ OptAlias

Returns a new instance of OptAlias.

Raises:



6
7
8
9
10
# File 'lib/opt_parse_validator/opts/alias.rb', line 6

def initialize(option, attrs = {})
  raise Error, 'The :alias_for attribute is required' unless attrs.key?(:alias_for)

  super(option, attrs)
end

Instance Method Details

#alias?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/opt_parse_validator/opts/alias.rb', line 24

def alias?
  true
end

#alias_forString

Returns:

  • (String)


19
20
21
# File 'lib/opt_parse_validator/opts/alias.rb', line 19

def alias_for
  @alias_for ||= attrs[:alias_for]
end

#append_help_messagesObject



12
13
14
15
16
# File 'lib/opt_parse_validator/opts/alias.rb', line 12

def append_help_messages
  super

  option << "Alias for #{alias_for}"
end