Class: MarkdownExec::FileInMenu
Class Method Summary collapse
-
.for_menu(filename, colorize: true, histogram: true) ⇒ String
Prepends the age of the file in days to the file name for display in a menu.
-
.from_menu(dname) ⇒ String
Removes the age from the string to retrieve the original file name.
Class Method Details
.for_menu(filename, colorize: true, histogram: true) ⇒ String
Prepends the age of the file in days to the file name for display in a menu.
114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/markdown_exec.rb', line 114 def self.(filename, colorize: true, histogram: true) file_age = (Time.now - File.mtime(filename)) / (60 * 60 * 24 * 30) filename = ColorScheme.colorize_path(filename) if colorize if histogram " #{Histogram.display(file_age, 0, 11, 12, inverse: false)}: #{filename}" else filename end end |
.from_menu(dname) ⇒ String
Removes the age from the string to retrieve the original file name.
129 130 131 132 |
# File 'lib/markdown_exec.rb', line 129 def self.(dname) filename_with_age = dname.gsub(/\033\[[\d;]+m|\033\[0m/, '') filename_with_age.split(': ', 2).last end |