Class: Miniparse::FlagOption
- Defined in:
- lib/miniparse/command.rb
Instance Attribute Summary
Attributes inherited from Option
Attributes inherited from Command
Class Method Summary collapse
Instance Method Summary collapse
- #arg_to_value(arg) ⇒ Object
-
#check(arg) ⇒ Object
True if arg specifies this option.
- #help_usage ⇒ Object
Methods inherited from Option
Methods inherited from Command
#help_desc, #initialize, #run, valid_spec
Constructor Details
This class inherits a constructor from Miniparse::Command
Class Method Details
.spec_to_name(spec) ⇒ Object
175 176 177 |
# File 'lib/miniparse/command.rb', line 175 def self.spec_to_name(spec) spec_pattern_to_name(spec, /\A--(\w[\w-]+)[=| ]\S+\z/) end |
Instance Method Details
#arg_to_value(arg) ⇒ Object
186 187 188 189 190 191 192 193 194 |
# File 'lib/miniparse/command.rb', line 186 def arg_to_value(arg) if arg =~ /\A--#{name}[=| ](.+)\z/ $1 elsif shortable && (arg =~ /\A-#{name.to_s[0]}[=| ](.+)\z/) $1 else nil end end |
#check(arg) ⇒ Object
Returns true if arg specifies this option.
181 182 183 184 |
# File 'lib/miniparse/command.rb', line 181 def check(arg) super(arg) || (arg =~ /\A--#{name}\z/) || (shortable && (arg =~ /\A-#{name.to_s[0]}\z/)) end |
#help_usage ⇒ Object
196 197 198 |
# File 'lib/miniparse/command.rb', line 196 def help_usage "[#{spec}]" end |