class Gongora
Public Class Methods
hi()
click to toggle source
# File lib/gongora.rb, line 3 def self.hi puts "Hi, I\'m Góngora and I\'ll help you to write easily beatiful words" end
write_words(words, file, dir="")
click to toggle source
# File lib/gongora.rb, line 7 def self.write_words(words, file, dir="") if dir.empty? puts "I\'ll write in this directory... " elsif self.exists_dir? dir puts "Directory already existed..." else puts "Creating new directory #{dir}... " Dir.mkdir(dir, 0755) end self.write_file words, file, dir end
Protected Class Methods
exists_dir?(dir)
click to toggle source
# File lib/gongora.rb, line 20 def self.exists_dir?(dir) File.directory? dir end
write_file(words, file, dir)
click to toggle source
# File lib/gongora.rb, line 24 def self.write_file(words, file, dir) dir.empty? ? path = "#{file}" : path = "#{dir}/#{file}" puts "Creating #{file} and writting some beautiful words..." File.open(path, "a") { |f| f.write(words) } end