Class: BaseDato

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

Instance Method Summary collapse

Constructor Details

#initialize(alg = nil) ⇒ BaseDato

Returns a new instance of BaseDato.



8
9
10
# File 'lib/cobreak/function_hash.rb', line 8

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

Instance Method Details

#database(alg) ⇒ Object



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

def database(alg)
  	var1 = File.join(Gem.path[1], "gems", "cobreak-#{CoBreak.version}", 'lib', 'cobreak', 'hash', 'hash.db')
  	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