Class: Samovar::Completion::Result
- Inherits:
-
Object
- Object
- Samovar::Completion::Result
- Includes:
- Enumerable
- Defined in:
- lib/samovar/completion/result.rb
Overview
A collection of completion suggestions.
Instance Attribute Summary collapse
-
#suggestions ⇒ Object
readonly
Returns the value of attribute suggestions.
- #The suggestions in this result.(suggestions) ⇒ Object readonly
Instance Method Summary collapse
-
#+(other) ⇒ Object
Combine this result with another result.
-
#each(&block) ⇒ Object
Iterate over each suggestion.
-
#empty? ⇒ Boolean
Whether this result contains no suggestions.
-
#initialize(suggestions = []) ⇒ Result
constructor
Initialize a new completion result.
-
#print(output = $stdout) ⇒ Object
Print suggestions as tab-separated completion records.
Constructor Details
#initialize(suggestions = []) ⇒ Result
Initialize a new completion result.
15 16 17 |
# File 'lib/samovar/completion/result.rb', line 15 def initialize(suggestions = []) @suggestions = suggestions end |
Instance Attribute Details
#suggestions ⇒ Object (readonly)
Returns the value of attribute suggestions.
20 21 22 |
# File 'lib/samovar/completion/result.rb', line 20 def suggestions @suggestions end |
#The suggestions in this result.(suggestions) ⇒ Object (readonly)
20 |
# File 'lib/samovar/completion/result.rb', line 20 attr :suggestions |
Instance Method Details
#+(other) ⇒ Object
Combine this result with another result.
40 41 42 |
# File 'lib/samovar/completion/result.rb', line 40 def +(other) self.class.new(@suggestions + other.suggestions) end |
#each(&block) ⇒ Object
Iterate over each suggestion.
25 26 27 |
# File 'lib/samovar/completion/result.rb', line 25 def each(&block) @suggestions.each(&block) end |
#empty? ⇒ Boolean
Whether this result contains no suggestions.
32 33 34 |
# File 'lib/samovar/completion/result.rb', line 32 def empty? @suggestions.empty? end |
#print(output = $stdout) ⇒ Object
Print suggestions as tab-separated completion records.
47 48 49 50 51 |
# File 'lib/samovar/completion/result.rb', line 47 def print(output = $stdout) each do |suggestion| output.puts suggestion.to_record end end |