Class: MarkdownExec::MenuBuilder
Instance Method Summary collapse
- #build_menu(file_names, directory_names, found_in_block_names, file_name_choices, choices_from_block_names, colorize: true) ⇒ Object
-
#initialize ⇒ MenuBuilder
constructor
A new instance of MenuBuilder.
Constructor Details
#initialize ⇒ MenuBuilder
Returns a new instance of MenuBuilder.
168 169 170 171 |
# File 'lib/markdown_exec.rb', line 168 def initialize @chrome_color = :cyan @o_color = :red end |
Instance Method Details
#build_menu(file_names, directory_names, found_in_block_names, file_name_choices, choices_from_block_names, colorize: true) ⇒ Object
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/markdown_exec.rb', line 173 def (file_names, directory_names, found_in_block_names, file_name_choices, choices_from_block_names, colorize: true) choices = [] # Adding section title and data for file names text = "in #{file_names[:section_title]}" text = AnsiString.new(text).send(@chrome_color) if colorize choices << { disabled: '', name: text } choices += file_names[:data].map do |str| FileInMenu.(str, colorize: colorize) end # Conditionally add directory names if data is present if directory_names[:data].any? text = "in #{directory_names[:section_title]}" text = AnsiString.new(text).send(@chrome_color) if colorize choices << { disabled: '', name: text } choices += file_name_choices end # Adding found in block names text = "in #{found_in_block_names[:section_title]}" text = AnsiString.new(text).send(@chrome_color) if colorize choices << { disabled: '', name: text } choices += choices_from_block_names choices end |