class Samovar::Flags

Public Class Methods

new(text) click to toggle source
# File lib/samovar/flags.rb, line 8
def initialize(text)
        @text = text
        
        @ordered = text.split(/\s+\|\s+/).map{|part| Flag.parse(part)}
end

Public Instance Methods

boolean?() click to toggle source

Whether or not this flag should have a true/false value if not specified otherwise.

# File lib/samovar/flags.rb, line 23
def boolean?
        @ordered.count == 1 and @ordered.first.boolean?
end
count() click to toggle source
# File lib/samovar/flags.rb, line 27
def count
        return @ordered.count
end
each(&block) click to toggle source
# File lib/samovar/flags.rb, line 14
def each(&block)
        @ordered.each(&block)
end
first() click to toggle source
# File lib/samovar/flags.rb, line 18
def first
        @ordered.first
end
parse(input) click to toggle source
# File lib/samovar/flags.rb, line 35
def parse(input)
        @ordered.each do |flag|
                result = flag.parse(input)
                if result != nil
                        return result
                end
        end
        
        return nil
end
to_s() click to toggle source
# File lib/samovar/flags.rb, line 31
def to_s
        "[#{@ordered.join(' | ')}]"
end