Class: Samovar::Flag
- Inherits:
-
Object
- Object
- Samovar::Flag
- Defined in:
- lib/samovar/flags.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#alternatives ⇒ Object
readonly
Returns the value of attribute alternatives.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Class Method Summary collapse
Instance Method Summary collapse
- #boolean? ⇒ Boolean
-
#initialize(text, prefix, alternatives = nil) ⇒ Flag
constructor
A new instance of Flag.
- #key ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(text, prefix, alternatives = nil) ⇒ Flag
Returns a new instance of Flag.
58 59 60 61 62 |
# File 'lib/samovar/flags.rb', line 58 def initialize(text, prefix, alternatives = nil) @text = text @prefix = prefix @alternatives = alternatives end |
Instance Attribute Details
#alternatives ⇒ Object (readonly)
Returns the value of attribute alternatives.
66 67 68 |
# File 'lib/samovar/flags.rb', line 66 def alternatives @alternatives end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
65 66 67 |
# File 'lib/samovar/flags.rb', line 65 def prefix @prefix end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
64 65 66 |
# File 'lib/samovar/flags.rb', line 64 def text @text end |
Class Method Details
Instance Method Details
#boolean? ⇒ Boolean
76 77 78 |
# File 'lib/samovar/flags.rb', line 76 def boolean? false end |
#key ⇒ Object
72 73 74 |
# File 'lib/samovar/flags.rb', line 72 def key @key ||= @prefix.sub(/^-*/, '').gsub('-', '_').to_sym end |
#to_s ⇒ Object
68 69 70 |
# File 'lib/samovar/flags.rb', line 68 def to_s @text end |