Class: Command::CompletionsLister
- Inherits:
-
SetVisitor
- Object
- SetVisitor
- Command::CompletionsLister
- Defined in:
- lib/command-set/structural.rb
Instance Attribute Summary collapse
-
#completion_list ⇒ Object
readonly
Returns the value of attribute completion_list.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
Attributes inherited from SetVisitor
#command_path, #subject_context
Instance Method Summary collapse
- #arrive_at(terms, node) ⇒ Object
- #command_out_of_terms(node) ⇒ Object
-
#initialize(prefix, subject, terms) ⇒ CompletionsLister
constructor
A new instance of CompletionsLister.
- #set_out_of_terms(node) ⇒ Object
- #term_without_hop(terms, node) ⇒ Object
Methods inherited from SetVisitor
Constructor Details
#initialize(prefix, subject, terms) ⇒ CompletionsLister
Returns a new instance of CompletionsLister.
127 128 129 130 131 132 133 134 |
# File 'lib/command-set/structural.rb', line 127 def initialize(prefix, subject, terms) super() @prefix = prefix @subject = subject @completion_list = [] @arguments = [] @original_terms = terms.dup end |
Instance Attribute Details
#completion_list ⇒ Object (readonly)
Returns the value of attribute completion_list.
136 137 138 |
# File 'lib/command-set/structural.rb', line 136 def completion_list @completion_list end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
136 137 138 |
# File 'lib/command-set/structural.rb', line 136 def prefix @prefix end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
136 137 138 |
# File 'lib/command-set/structural.rb', line 136 def subject @subject end |
Instance Method Details
#arrive_at(terms, node) ⇒ Object
138 139 140 141 142 143 144 |
# File 'lib/command-set/structural.rb', line 138 def arrive_at(terms, node) @arguments = node.argument_list.dup image = subject.get_image(node.subject_requirements) until terms.empty? or @arguments.empty? do @arguments.first.match_terms(image, terms, @arguments) end end |
#command_out_of_terms(node) ⇒ Object
152 153 154 155 156 157 158 |
# File 'lib/command-set/structural.rb', line 152 def command_out_of_terms(node) image = @subject.get_image(node.subject_requirements) @arguments.each do |handler| @completion_list += handler.complete(@original_terms, @prefix, image) break unless handler.omittable? end end |
#set_out_of_terms(node) ⇒ Object
146 147 148 149 150 |
# File 'lib/command-set/structural.rb', line 146 def set_out_of_terms(node) if @arguments.empty? or not @arguments.first.required? @completion_list = node.command_names.grep(%r{^#{prefix}.*}) end end |
#term_without_hop(terms, node) ⇒ Object
160 161 162 |
# File 'lib/command-set/structural.rb', line 160 def term_without_hop(terms, node) return [] end |