Class: DrHenryPost
- Inherits:
-
Object
- Object
- DrHenryPost
- Defined in:
- lib/drhenrypost.rb
Instance Method Summary collapse
-
#create ⇒ Object
Método que crea el archivo concatenando la fecha y el nombre generados por date y name.
-
#date ⇒ Object
Método que setea la fecha del post.
-
#name ⇒ Object
Método que setea el nombre del archivo.
Instance Method Details
#create ⇒ Object
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 |
#date ⇒ Object
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 |
#name ⇒ Object
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 |