Class: DrHenryPost

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

Instance Method Summary collapse

Instance Method Details

#createObject

Método que crea el archivo concatenando la fecha y el nombre generados por date y name



26
27
28
29
30
31
32
33
34
35
# File 'lib/drhenrypost.rb', line 26

def create
  filename = date + "-" + name

  output = File.new("#{filename}", "w")
  output.puts("---")
  output.puts("layout: post # Sustituye el layout si lo usas uno diferente")
  output.puts("title: " + "#{$title}" + " # Nombre generado automáticamente")
  output.puts("---")
  output.close
end

#dateObject

Método que setea la fecha del post



7
8
9
10
11
# File 'lib/drhenrypost.rb', line 7

def date
  time = Time.new
  date = time.strftime("%Y-%m-%d")
  return date.to_s
end

#nameObject

Método que setea el nombre del archivo



14
15
16
17
18
19
20
21
22
23
# File 'lib/drhenrypost.rb', line 14

def name
  string = []

  ARGV.each do |a|
    string.push(a)
  end

  joinName = string.join('-')
  return joinName + ".md"
end