Class: DataBase

Inherits:
Object
  • Object
show all
Defined in:
lib/cobreak/function_db.rb

Instance Method Summary collapse

Constructor Details

#initialize(alg = nil) ⇒ DataBase

Returns a new instance of DataBase.



7
8
9
# File 'lib/cobreak/function_db.rb', line 7

def initialize(alg = nil)
@alg = alg
end

Instance Method Details

#database(alg, var1) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/cobreak/function_db.rb', line 10

def database(alg, var1)
  if File.exists?(var1) == false
    FileUtils.touch(var1)
  end
    IO.foreach(var1) {|line|
      line.chomp!
      $db[:database] << {text_db:line}
    }
    if ($db[:database].filter(text_db:alg).map(:text_db)).include?(alg) == true
      exit
    end
    File.open(var1, mode: 'a'){|lin|
      lin.puts alg
    }
end