class Pepin::Query
Public Class Methods
new(list, filter: GrepFilter)
click to toggle source
# File lib/pepin/query.rb, line 11 def initialize(list, filter: GrepFilter) @list = list @string = '' @filter = filter.new end
Public Instance Methods
add_char(ch)
click to toggle source
# File lib/pepin/query.rb, line 31 def add_char(ch) @string << ch notify_change end
clear()
click to toggle source
# File lib/pepin/query.rb, line 25 def clear @string.clear notify_change end
delete_ahead_from(pos)
click to toggle source
# File lib/pepin/query.rb, line 63 def delete_ahead_from(pos) string_was = @string @string = @string.to_s[0...pos] notify_change string_was.length - @string.length end
delete_behind_char_from(pos)
click to toggle source
# File lib/pepin/query.rb, line 55 def delete_behind_char_from(pos) @string = @string[0...pos.pred] + @string[pos..-1] notify_change 1 end
delete_behind_from(pos)
click to toggle source
# File lib/pepin/query.rb, line 37 def delete_behind_from(pos) string_was = @string @string = @string.to_s[pos..-1] notify_change string_was.length - @string.length end
delete_behind_word_from(pos)
click to toggle source
# File lib/pepin/query.rb, line 46 def delete_behind_word_from(pos) string_was = @string @string = @string[0..pos.pred].split(/\b/)[0...-1].join + @string[pos..-1] notify_change string_was.length - @string.length end
pattern()
click to toggle source
# File lib/pepin/query.rb, line 17 def pattern @filter.pattern(@string.strip) end
search()
click to toggle source
# File lib/pepin/query.rb, line 21 def search @filter.select(@list, @string.strip) end
Private Instance Methods
notify_change()
click to toggle source
# File lib/pepin/query.rb, line 74 def notify_change changed notify_observers end