class Fir::Suggestion
Attributes
history[R]
line[R]
Public Class Methods
new(line, history)
click to toggle source
# File lib/fir/suggestion.rb, line 8 def initialize(line, history) @line = line @history = history end
Public Instance Methods
filtered_history(str)
click to toggle source
# File lib/fir/suggestion.rb, line 27 def filtered_history(str) history.grep(/^#{Regexp.escape(str)}/).reverse end
generate(i)
click to toggle source
# File lib/fir/suggestion.rb, line 13 def generate(i) word = suggestion(line, i) return unless word word[(line.length)..(word.length)] end
suggestion(str, i)
click to toggle source
# File lib/fir/suggestion.rb, line 19 def suggestion(str, i) if str == '' && i.positive? history[-i] elsif str != '' filtered_history(str)[-i] end end