class Samovar::Flag

Attributes

alternatives[R]
prefix[R]
text[R]

Public Class Methods

new(text, prefix, alternatives = nil) click to toggle source
# File lib/samovar/flags.rb, line 58
def initialize(text, prefix, alternatives = nil)
        @text = text
        @prefix = prefix
        @alternatives = alternatives
end
parse(text) click to toggle source
# File lib/samovar/flags.rb, line 48
def self.parse(text)
        if text =~ /(.*?)\s(\<.*?\>)/
                ValueFlag.new(text, $1, $2)
        elsif text =~ /--\[no\]-(.*?)$/
                BooleanFlag.new(text, "--#{$1}")
        else
                ValueFlag.new(text, text, nil)
        end
end

Public Instance Methods

boolean?() click to toggle source
# File lib/samovar/flags.rb, line 76
def boolean?
        false
end
key() click to toggle source
# File lib/samovar/flags.rb, line 72
def key
        @key ||= @prefix.sub(/^-*/, '').gsub('-', '_').to_sym
end
to_s() click to toggle source
# File lib/samovar/flags.rb, line 68
def to_s
        @text
end