Class: Toys::Definition::FlagSyntax
- Inherits:
-
Object
- Object
- Toys::Definition::FlagSyntax
- Defined in:
- lib/toys/definition/flag.rb
Overview
Representation of a single flag.
Instance Attribute Summary collapse
-
#canonical_str ⇒ Object
readonly
Returns the value of attribute canonical_str.
-
#flag_style ⇒ Object
readonly
Returns the value of attribute flag_style.
-
#flag_type ⇒ Object
readonly
Returns the value of attribute flag_type.
-
#flags ⇒ Object
readonly
Returns the value of attribute flags.
-
#original_str ⇒ Object
readonly
Returns the value of attribute original_str.
-
#str_without_value ⇒ Object
readonly
Returns the value of attribute str_without_value.
-
#value_delim ⇒ Object
readonly
Returns the value of attribute value_delim.
-
#value_label ⇒ Object
readonly
Returns the value of attribute value_label.
-
#value_type ⇒ Object
readonly
Returns the value of attribute value_type.
Instance Method Summary collapse
-
#initialize(str) ⇒ FlagSyntax
constructor
Parse flag syntax.
Constructor Details
#initialize(str) ⇒ FlagSyntax
Parse flag syntax
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/toys/definition/flag.rb', line 42 def initialize(str) case str when /^(-[\?\w])$/ setup(str, [$1], $1, "-", nil, nil, nil, nil) when /^(-[\?\w])( ?)\[(\w+)\]$/ setup(str, [$1], $1, "-", :value, :optional, $2, $3) when /^(-[\?\w])\[( )(\w+)\]$/ setup(str, [$1], $1, "-", :value, :optional, $2, $3) when /^(-[\?\w])( ?)(\w+)$/ setup(str, [$1], $1, "-", :value, :required, $2, $3) when /^--\[no-\](\w[\?\w-]*)$/ setup(str, ["--#{$1}", "--no-#{$1}"], str, "--", :boolean, nil, nil, nil) when /^(--\w[\?\w-]*)$/ setup(str, [$1], $1, "--", nil, nil, nil, nil) when /^(--\w[\?\w-]*)([= ])\[(\w+)\]$/ setup(str, [$1], $1, "--", :value, :optional, $2, $3) when /^(--\w[\?\w-]*)\[([= ])(\w+)\]$/ setup(str, [$1], $1, "--", :value, :optional, $2, $3) when /^(--\w[\?\w-]*)([= ])(\w+)$/ setup(str, [$1], $1, "--", :value, :required, $2, $3) else raise ToolDefinitionError, "Illegal flag: #{str.inspect}" end end |
Instance Attribute Details
#canonical_str ⇒ Object (readonly)
Returns the value of attribute canonical_str.
75 76 77 |
# File 'lib/toys/definition/flag.rb', line 75 def canonical_str @canonical_str end |
#flag_style ⇒ Object (readonly)
Returns the value of attribute flag_style.
70 71 72 |
# File 'lib/toys/definition/flag.rb', line 70 def flag_style @flag_style end |
#flag_type ⇒ Object (readonly)
Returns the value of attribute flag_type.
71 72 73 |
# File 'lib/toys/definition/flag.rb', line 71 def flag_type @flag_type end |
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
68 69 70 |
# File 'lib/toys/definition/flag.rb', line 68 def flags @flags end |
#original_str ⇒ Object (readonly)
Returns the value of attribute original_str.
67 68 69 |
# File 'lib/toys/definition/flag.rb', line 67 def original_str @original_str end |
#str_without_value ⇒ Object (readonly)
Returns the value of attribute str_without_value.
69 70 71 |
# File 'lib/toys/definition/flag.rb', line 69 def str_without_value @str_without_value end |
#value_delim ⇒ Object (readonly)
Returns the value of attribute value_delim.
73 74 75 |
# File 'lib/toys/definition/flag.rb', line 73 def value_delim @value_delim end |
#value_label ⇒ Object (readonly)
Returns the value of attribute value_label.
74 75 76 |
# File 'lib/toys/definition/flag.rb', line 74 def value_label @value_label end |
#value_type ⇒ Object (readonly)
Returns the value of attribute value_type.
72 73 74 |
# File 'lib/toys/definition/flag.rb', line 72 def value_type @value_type end |