class Noir::Command::New::Note
Constants
- FileNameGlob
- SerialDigitRange
- TimeFormat
Public Class Methods
create_new_note()
click to toggle source
# File lib/noir/command/new/note.rb, line 23 def create_new_note note_num = Dir.glob(FileNameGlob).size + 1 note_name = serial_format(note_num) + '_' + Time.now.strftime(TimeFormat) + '.txt' Noir::Command::New.createFile note_name return note_name end
execute(*args)
click to toggle source
# File lib/noir/command/new/note.rb, line 30 def execute *args puts create_new_note end
serial_format(number)
click to toggle source
# File lib/noir/command/new/note.rb, line 10 def serial_format number digit_from_env = ENV['NOIR_NOTE_SERIAL_DIGIT'] # default digit is 2 digit = digit_from_env.nil? ? 2 : digit_from_env.to_i if SerialDigitRange.cover?(digit) return format("%0#{digit}d", number) else raise ["Invalid NOIR_NOTE_SERIAL_DIGIT=#{digit_from_env}.", "supported digits are [#{SerialDigitRange.to_a.join(', ')}]."].join("\n") end end