class EasyOptions::Option

Attributes

boolean[RW]
long[RW]
short[RW]

Public Class Methods

new(long_version, short_version, boolean = true) click to toggle source
# File easyoptions.rb, line 81
def initialize(long_version, short_version, boolean = true)
    fail ArgumentError.new('Long version is mandatory') if !long_version || long_version.length < 2
    @short = short_version.to_sym if short_version
    @long = long_version.to_s.gsub('-', '_').to_sym
    @boolean = boolean
end

Public Instance Methods

in?(string) click to toggle source
# File easyoptions.rb, line 92
def in?(string)
    string =~ /^--#{long_dashed}$/ || (@short && string =~ /^-#{@short}$/)
end
in_with_value?(string) click to toggle source
# File easyoptions.rb, line 96
def in_with_value?(string)
    string =~ /^--#{long_dashed}=.*$/
end
long_dashed() click to toggle source
# File easyoptions.rb, line 100
def long_dashed
    @long.to_s.gsub('_', '-')
end
to_s() click to toggle source
# File easyoptions.rb, line 88
def to_s
    "--#{long_dashed}"
end