Class: Nexty::Sites

Inherits:
Object
  • Object
show all
Defined in:
lib/nexty/site.rb

Class Method Summary collapse

Class Method Details

.load_from_file(file) ⇒ Object

Public: load site names from a text file returning it in an array

file - the filename

Example

Nexty::Sites.load_from_file('./important_sites.txt')
# => ['www', 'mail', 'dns']

Nexty::Sites.load_from_file('./doesnt_exists_file.foo')
# => []

Returns an Array containing the site names or an empty Array if the file doesn’t exist.



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/nexty/site.rb', line 16

def self.load_from_file(file)
  if !File.exists?(file)
    return []
  end

  ret = [] 
  File.open(file).each_line{ |s|
    ret << s.chomp
  }
  
  ret 

end