Class: Samovar::Flags
- Inherits:
-
Object
- Object
- Samovar::Flags
- Defined in:
- lib/samovar/flags.rb
Instance Method Summary collapse
-
#boolean? ⇒ Boolean
Whether or not this flag should have a true/false value if not specified otherwise.
- #count ⇒ Object
- #each(&block) ⇒ Object
- #first ⇒ Object
-
#initialize(text) ⇒ Flags
constructor
A new instance of Flags.
- #parse(input) ⇒ Object
- #to_s ⇒ Object
Constructor Details
Instance Method Details
#boolean? ⇒ Boolean
Whether or not this flag should have a true/false value if not specified otherwise.
38 39 40 |
# File 'lib/samovar/flags.rb', line 38 def boolean? @ordered.count == 1 and @ordered.first.value.nil? end |
#count ⇒ Object
42 43 44 |
# File 'lib/samovar/flags.rb', line 42 def count return @ordered.count end |
#each(&block) ⇒ Object
29 30 31 |
# File 'lib/samovar/flags.rb', line 29 def each(&block) @ordered.each(&block) end |
#first ⇒ Object
33 34 35 |
# File 'lib/samovar/flags.rb', line 33 def first @ordered.first end |
#parse(input) ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/samovar/flags.rb', line 50 def parse(input) @ordered.each do |flag| if result = flag.parse(input) return result end end return nil end |
#to_s ⇒ Object
46 47 48 |
# File 'lib/samovar/flags.rb', line 46 def to_s '[' + @ordered.join(' | ') + ']' end |