Top Level Namespace
Defined Under Namespace
Modules: Zolaposta
Instance Method Summary collapse
- #cancel_operation ⇒ Object
- #generate_frontmatter(title, description, tags) ⇒ Object
- #get_tags_from_user ⇒ Object
- #get_user_input(prompt) ⇒ Object
Instance Method Details
#cancel_operation ⇒ Object
37 38 39 40 |
# File 'lib/zolaposta.rb', line 37 def cancel_operation() puts 'Operation cancelled. Exiting...'.colorize(:red) exit end |
#generate_frontmatter(title, description, tags) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/zolaposta.rb', line 5 def generate_frontmatter(title, description, ) frontmatter = { 'date' => Date.today.strftime('%Y-%m-%d') } frontmatter['title'] = title unless title.empty? frontmatter['description'] = description unless description.empty? frontmatter['taxonomies'] = { 'tags' => } unless .empty? TomlRB.dump(frontmatter) end |
#get_tags_from_user ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/zolaposta.rb', line 24 def () = [] loop do tag = get_user_input('Enter a tag (press enter to add another tag, or leave blank if done): ') break if tag.empty? << tag end end |
#get_user_input(prompt) ⇒ Object
19 20 21 22 |
# File 'lib/zolaposta.rb', line 19 def get_user_input(prompt) print prompt.colorize(color: :blue, mode: :bold) gets.chomp end |