class Methan::Console
Public Instance Methods
new(filename)
click to toggle source
# File lib/methan/console.rb, line 20 def new(filename) now = Time.now.strftime("%Y%m%d%H%M%S") pwd = Dir::pwd filename = "#{filename}.md" unless filename.split(".").last == "md" filename = "#{now}_#{filename}" filepath = File.join(pwd, filename) src = "# #{options[:title] || ''}\n" File.open(filepath, "w") do |io| io.write(src) end show "Create memo `#{filename} at #{pwd}`", :green end
server()
click to toggle source
# File lib/methan/console.rb, line 38 def server ::Methan::Server.rackup(options.dup) end
version()
click to toggle source
# File lib/methan/console.rb, line 14 def version show Methan::VERSION end
Private Instance Methods
show(message, color=nil)
click to toggle source
# File lib/methan/console.rb, line 45 def show(message, color=nil) prefix = case color when :red then "\033[31m" when :green then "\033[32m" when :yellow then "\033[33m" when :blue then "\033[34m" else "" end suffix = prefix == "" ? "" : "\033[0m" puts "#{prefix}#{message}#{suffix}" end