Class: LogBench::App::Filter

Inherits:
Object
  • Object
show all
Defined in:
lib/log_bench/app/filter.rb

Instance Method Summary collapse

Constructor Details

#initializeFilter

Returns a new instance of Filter.



4
5
6
7
# File 'lib/log_bench/app/filter.rb', line 4

def initialize
  self.text = ""
  self.mode = false
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/log_bench/app/filter.rb', line 17

def active?
  mode
end

#add_character(char) ⇒ Object



25
26
27
# File 'lib/log_bench/app/filter.rb', line 25

def add_character(char)
  self.text += char
end

#clearObject



33
34
35
# File 'lib/log_bench/app/filter.rb', line 33

def clear
  self.text = ""
end

#clear_and_exitObject



37
38
39
40
# File 'lib/log_bench/app/filter.rb', line 37

def clear_and_exit
  clear
  exit_mode
end

#cursor_displayObject



51
52
53
# File 'lib/log_bench/app/filter.rb', line 51

def cursor_display
  active? ? "#{text}█" : text
end

#display_textObject



47
48
49
# File 'lib/log_bench/app/filter.rb', line 47

def display_text
  text
end

#enter_modeObject



9
10
11
# File 'lib/log_bench/app/filter.rb', line 9

def enter_mode
  self.mode = true
end

#exit_modeObject



13
14
15
# File 'lib/log_bench/app/filter.rb', line 13

def exit_mode
  self.mode = false
end

#matches?(content) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
45
# File 'lib/log_bench/app/filter.rb', line 42

def matches?(content)
  return true if text.empty?
  content.to_s.downcase.include?(text.downcase)
end

#present?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/log_bench/app/filter.rb', line 21

def present?
  !text.empty?
end

#remove_characterObject



29
30
31
# File 'lib/log_bench/app/filter.rb', line 29

def remove_character
  self.text = text[0...-1] if text.length > 0
end