Class: TermUtils::AP::Flag
- Inherits:
-
Object
- Object
- TermUtils::AP::Flag
- Defined in:
- lib/term_utils/ap/flag.rb
Overview
Represents a Flag.
Instance Attribute Summary collapse
-
#flavor ⇒ Symbol
`:anchor`, `:long`, `:short`.
- #label ⇒ String
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Flag
constructor
Constructs a new Flag.
-
#to_s ⇒ String
Returns the string representation of this one.
Constructor Details
#initialize(opts = {}) ⇒ Flag
Constructs a new Flag.
30 31 32 33 |
# File 'lib/term_utils/ap/flag.rb', line 30 def initialize(opts = {}) @label = opts.fetch(:label, nil) @flavor = opts.fetch(:flavor, nil) end |
Instance Attribute Details
#flavor ⇒ Symbol
Returns `:anchor`, `:long`, `:short`.
25 26 27 |
# File 'lib/term_utils/ap/flag.rb', line 25 def flavor @flavor end |
#label ⇒ String
23 24 25 |
# File 'lib/term_utils/ap/flag.rb', line 23 def label @label end |
Instance Method Details
#to_s ⇒ String
Returns the string representation of this one.
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/term_utils/ap/flag.rb', line 36 def to_s case @flavor when :anchor @label when :long "--%s" % @label when :short "-%s" % @label end end |