Class: Thor::SharedOption

Inherits:
Option show all
Defined in:
lib/thor/parser/shared_option.rb

Overview

A Option that has an additional #groups attribute storing a set of group symbols that the option is a part of.

Constant Summary

Constants inherited from Option

Option::VALID_TYPES

Constants inherited from Argument

Argument::VALID_TYPES

Instance Attribute Summary collapse

Attributes inherited from Option

#aliases, #group, #hide, #lazy_default

Attributes inherited from Argument

#banner, #default, #description, #enum, #name, #required, #type

Instance Method Summary collapse

Methods inherited from Option

#dasherize, #dasherized?, #human_name, parse, #switch_name, #undasherize, #usage, #validate!, #validate_default_type!

Methods inherited from Argument

#default_banner, #required?, #show_default?, #usage, #valid_type?, #validate!

Constructor Details

#initialize(name, **options) ⇒ SharedOption

Returns a new instance of SharedOption.



17
18
19
20
21
# File 'lib/thor/parser/shared_option.rb', line 17

def initialize name, **options
  super name, options
  
  @groups = Set.new [*options[:groups]].map( &:to_sym )
end

Instance Attribute Details

#groupsSet<Symbol> (readonly)

Shared option groups this option belongs to.

Returns:

  • (Set<Symbol>)


13
14
15
# File 'lib/thor/parser/shared_option.rb', line 13

def groups
  @groups
end