Module: Kernel
- Defined in:
- lib/lessons_indexer/addons/utils.rb
Instance Method Summary collapse
- #exit_msg(*msg) ⇒ Object
- #warning(*msg) ⇒ Object
- #with_messages(prior = '', after = '', delimiter = true, output = $stdout) ⇒ Object
- #within(path, ret = false) ⇒ Object
Instance Method Details
#exit_msg(*msg) ⇒ Object
17 18 19 |
# File 'lib/lessons_indexer/addons/utils.rb', line 17 def exit_msg(*msg) abort "[ERROR] #{msg.join(' ')}".red end |
#warning(*msg) ⇒ Object
13 14 15 |
# File 'lib/lessons_indexer/addons/utils.rb', line 13 def warning(*msg) warn "[WARNING] #{msg.join(' ')}".cyan end |
#with_messages(prior = '', after = '', delimiter = true, output = $stdout) ⇒ Object
2 3 4 5 6 7 8 9 10 11 |
# File 'lib/lessons_indexer/addons/utils.rb', line 2 def (prior = '', after = '', delimiter = true, output = $stdout) return unless block_given? prior = String(prior) after = String(after) output.puts prior.magenta unless prior == '' yield output.puts after.green unless after == '' output.puts "=".yellow * 50 if delimiter end |
#within(path, ret = false) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/lessons_indexer/addons/utils.rb', line 21 def within(path, ret = false) return unless block_given? initial = Dir.getwd Dir.chdir(path) val = yield Dir.chdir(initial) if ret return val rescue Errno::ENOENT exit_msg "The provided directory #{path} was not found! Aborting..." end |