Class: TabTab::Definition::Default
- Defined in:
- lib/tabtab/definitions/default.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
Attributes inherited from Base
#contents, #definition_block, #parent
Instance Method Summary collapse
- #definition_type ⇒ Object
-
#initialize(parent, description = nil, &definition_block) ⇒ Default
constructor
A new instance of Default.
-
#matches_token?(cmd_line_token) ⇒ Boolean
Determines if current token matches this command’s name.
- #own_completions ⇒ Object
- #yield_result_block ⇒ Object
Methods inherited from Base
#[], #autocompletable?, #command, #completions_of_contents, #current_token, #definition_type?, #filtered_completions, #find_active_definition_for_last_token, #flags, #tokens_consumed, #yield_definition_block
Constructor Details
#initialize(parent, description = nil, &definition_block) ⇒ Default
Returns a new instance of Default.
4 5 6 7 |
# File 'lib/tabtab/definitions/default.rb', line 4 def initialize(parent, description=nil, &definition_block) @description = description super parent, &definition_block end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
3 4 5 |
# File 'lib/tabtab/definitions/default.rb', line 3 def description @description end |
Instance Method Details
#definition_type ⇒ Object
9 10 11 |
# File 'lib/tabtab/definitions/default.rb', line 9 def definition_type :default end |
#matches_token?(cmd_line_token) ⇒ Boolean
Determines if current token matches this command’s name
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/tabtab/definitions/default.rb', line 28 def matches_token?(cmd_line_token) results = yield_result_block case results when String results == cmd_line_token.to_s when Array results.include?(cmd_line_token.to_s) else false end end |
#own_completions ⇒ Object
13 14 15 |
# File 'lib/tabtab/definitions/default.rb', line 13 def own_completions yield_result_block end |
#yield_result_block ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/tabtab/definitions/default.rb', line 17 def yield_result_block if definition_block.arity == -1 || definition_block.arity == 0 definition_block.call elsif definition_block.arity == 1 definition_block.call(self) else raise TabTab::Definition::InvalidDefinitionBlockArguments end end |