class Samovar::ValueFlag
Attributes
alternatives[R]
value[R]
Public Class Methods
new(text, prefix, value)
click to toggle source
Calls superclass method
Samovar::Flag::new
# File lib/samovar/flags.rb, line 82 def initialize(text, prefix, value) super(text, prefix) @value = value *@alternatives, @prefix = @prefix.split('/') end
Public Instance Methods
boolean?()
click to toggle source
# File lib/samovar/flags.rb, line 93 def boolean? @value.nil? end
parse(input)
click to toggle source
# File lib/samovar/flags.rb, line 101 def parse(input) if prefix?(input.first) if @value return input.shift(2).last else input.shift return key end end end
prefix?(token)
click to toggle source
# File lib/samovar/flags.rb, line 97 def prefix?(token) @prefix == token or @alternatives.include?(token) end