Module: Amnesie::Persist

Defined in:
lib/amnesie/persist.rb,
lib/amnesie/persist/iwd.rb,
lib/amnesie/persist/systemd.rb,
lib/amnesie/persist/wpa_supplicant.rb

Defined Under Namespace

Classes: Iwd, Systemd, WpaSupplicant

Class Method Summary collapse

Class Method Details

.grep?(file, regex) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
6
7
8
9
10
11
12
# File 'lib/amnesie/persist.rb', line 3

def self.grep?(file, regex)
  is_found = false
  return is_found if ! File.exist? file
  File.open(file) do |f|
    f.each do |line|
      is_found = true if line.match(regex)
    end
  end
  is_found
end