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