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.
14 15 16 |
# File 'lib/mdoc.rb', line 14 def initialize(opts) @opts = opts.merge(block_name_hidden_match: nil) end |
Instance Method Details
#fcb_in_menu?(fcb) ⇒ Boolean
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/mdoc.rb', line 18 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
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/mdoc.rb', line 36 def (block) if block.fetch(:chrome, false) false else @opts[:hide_blocks_by_name] && ((@opts[:block_name_hidden_match]&.present? && block.s2title&.match(Regexp.new(@opts[:block_name_hidden_match]))) || (@opts[:block_name_include_match]&.present? && block.s2title&.match(Regexp.new(@opts[:block_name_include_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 |