Module: Diary::Item::Creator
- Included in:
- Base
- Defined in:
- lib/diary/item/creator.rb
Defined Under Namespace
Modules: Peristance
Constant Summary collapse
- ACCENTS =
{ ['á','à','â','ä','ã'] => 'a', ['Ã','Ä','Â','À','�?'] => 'A', ['é','è','ê','ë'] => 'e', ['Ë','É','È','Ê'] => 'E', ['í','ì','î','ï'] => 'i', ['�?','Î','Ì','�?'] => 'I', ['ó','ò','ô','ö','õ'] => 'o', ['Õ','Ö','Ô','Ò','Ó'] => 'O', ['ú','ù','û','ü'] => 'u', ['Ú','Û','Ù','Ü'] => 'U', ['ç'] => 'c', ['Ç'] => 'C', ['ñ'] => 'n', ['Ñ'] => 'N' }
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.extended(base) ⇒ Object
5 6 7 |
# File 'lib/diary/item/creator.rb', line 5 def self.extended(base) base.send :include, Peristance end |
Instance Method Details
#create(title) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/diary/item/creator.rb', line 38 def create(title) slug = slugify(title) path = resolve_path(slug) ensure_directories_exists!(path) unless File.exists?(path) File.open(path, "w+") do |f| f.puts "---\n" f.puts "title: #{title}" f.puts "\n---\n" end Diary. :create, path, :green else Diary. :exist, path, :yellow end self.new(path) end |