Class: OptimistXL::StringFlagOption
- Inherits:
-
StringOption
- Object
- Option
- StringOption
- OptimistXL::StringFlagOption
- Defined in:
- lib/optimist_xl.rb
Instance Attribute Summary
Attributes inherited from Option
#default, #long, #max_args, #min_args, #multi_given, #name, #permitted, #permitted_response, #short
Instance Method Summary collapse
- #compatible_with?(other_option) ⇒ Boolean
-
#initialize ⇒ StringFlagOption
constructor
A new instance of StringFlagOption.
- #parse(paramlist, neg_given) ⇒ Object
- #type_format ⇒ Object
Methods inherited from Option
#array_default?, #callback, create, #desc, #description_with_default, #description_with_permitted, #doesnt_need_autogen_short, #educate, #format_stdio, #full_description, handle_long_opt, handle_short_opt, #multi, #opts, #opts=, #permitted_type_valid?, #permitted_valid_string, #permitted_value?, register_alias, #required?, #validate_permitted
Constructor Details
#initialize ⇒ StringFlagOption
Returns a new instance of StringFlagOption.
1224 1225 1226 1227 1228 1229 |
# File 'lib/optimist_xl.rb', line 1224 def initialize super @default = false @min_args = 0 @max_args = 1 end |
Instance Method Details
#compatible_with?(other_option) ⇒ Boolean
1231 1232 1233 1234 1235 |
# File 'lib/optimist_xl.rb', line 1231 def compatible_with?(other_option) self.is_a?(other_option.class) || other_option.is_a?(BooleanOption) || other_option.is_a?(StringArrayOption) end |
#parse(paramlist, neg_given) ⇒ Object
1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 |
# File 'lib/optimist_xl.rb', line 1211 def parse(paramlist, neg_given) paramlist.map do |plist| plist.map do |pg| neg_given ? false : pg #case pg #when FalseClass then () ? neg_given : !neg_given #when TrueClass then (self.name.to_s =~ /^no_/) ? neg_given : !neg_given #else pg #end end end end |
#type_format ⇒ Object
1210 |
# File 'lib/optimist_xl.rb', line 1210 def type_format ; "=<s?>" ; end |