Class: MarkdownExec::MenuFilter
Instance Method Summary collapse
- #fcb_in_menu?(fcb) ⇒ Boolean
-
#hide_menu_block_on_name(block) ⇒ Boolean
Checks if a code block should be hidden based on the given options.
-
#initialize(opts) ⇒ MenuFilter
constructor
A new instance of MenuFilter.
Constructor Details
#initialize(opts) ⇒ MenuFilter
Returns a new instance of MenuFilter.
15 16 17 |
# File 'lib/mdoc.rb', line 15 def initialize(opts) @opts = opts.merge(block_name_hide_custom_match: nil) end |
Instance Method Details
#fcb_in_menu?(fcb) ⇒ Boolean
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/mdoc.rb', line 19 def (fcb) = Filter.fcb_select?(@opts, fcb) unless @opts[:menu_include_imported_blocks] = fcb.fetch(:depth, 0).zero? end if && @opts[:hide_blocks_by_name] = !(fcb) end end |
#hide_menu_block_on_name(block) ⇒ Boolean
Checks if a code block should be hidden based on the given options.
:reek:UtilityFunction
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/mdoc.rb', line 37 def (block) if block.fetch(:chrome, false) false else @opts[:hide_blocks_by_name] && ((@opts[:block_name_hide_custom_match]&.present? && block.s2title&.match(Regexp.new(@opts[:block_name_hide_custom_match]))) || (@opts[:block_name_hidden_match]&.present? && block.s2title&.match(Regexp.new(@opts[:block_name_hidden_match]))) || (@opts[:block_name_wrapper_match]&.present? && block.s2title&.match(Regexp.new(@opts[:block_name_wrapper_match])))) && (block.s2title&.present? || block[:label]&.present?) end end |