Class: Jklpost
- Inherits:
-
Object
- Object
- Jklpost
- Defined in:
- lib/jklpost.rb
Instance Method Summary collapse
-
#initialize ⇒ Jklpost
constructor
A new instance of Jklpost.
- #run ⇒ Object
- #showDoneMsg ⇒ Object
Constructor Details
#initialize ⇒ Jklpost
Returns a new instance of Jklpost.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/jklpost.rb', line 5 def initialize abort("Error! Too much arguments! Usage: jklpost <filename> [options].") if ARGV.length > 2 @title = "post" @layout = "default" @date = Date.today.to_s @timeStamp = Time.now.strftime "%H%M%S" @title = ARGV[0] if ARGV.length == 1 @layout = ARGV[1] if ARGV.length == 2 @filename = @date.to_s + "-" + @title.to_s + "-" + @timeStamp.to_s + ".md" end |
Instance Method Details
#run ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/jklpost.rb', line 17 def run File.open(@filename.to_s,"w"){|file| file.puts("---") file.puts("layout: #{@layout}") file.puts("title: \"#{@title}\"") file.puts("date: #{Time.now.strftime "%Y-%m-%d %H:%M:%S"}") file.puts("---") } end |
#showDoneMsg ⇒ Object
27 28 29 |
# File 'lib/jklpost.rb', line 27 def showDoneMsg puts "Successful! #{@filename.to_s} is created." end |