Module: Lich::Util::TextStripper::Mode

Defined in:
documented/util/textstripper.rb

Overview

Enumeration of stripping modes

Provides a type-safe way to specify which type of content stripping to perform. Each mode is represented as a symbol constant.

Examples:

Using mode constants

TextStripper.strip(text, TextStripper::Mode::HTML)

Checking valid modes

TextStripper::Mode.valid?(:html)     # => true
TextStripper::Mode.valid?(:markdown) # => true
TextStripper::Mode.valid?(:pdf)      # => false

Constant Summary collapse

HTML =

Strip HTML tags

:html
XML =

Strip XML tags

:xml
MARKUP =

Strip Markdown/markup formatting

:markup
MARKDOWN =

Alias for MARKUP (both :markup and :markdown are accepted)

:markdown
ALL =

All valid modes

Returns:

  • (Array<Symbol>)

    List of all supported stripping modes

[HTML, XML, MARKUP, MARKDOWN].freeze

Class Method Summary collapse

Class Method Details

.listString

Get a human-readable list of valid modes

Examples:

Mode.list  # => "html, xml, markup, markdown"

Returns:

  • (String)

    Comma-separated list of valid modes



111
112
113
# File 'documented/util/textstripper.rb', line 111

def self.list
  ALL.join(', ')
end

.valid?(mode) ⇒ Boolean

Check if a mode is valid

Examples:

Mode.valid?(:html)     # => true
Mode.valid?('markup')  # => true
Mode.valid?(:markdown) # => true
Mode.valid?(:invalid)  # => false

Parameters:

  • mode (Symbol, String)

    The mode to validate

Returns:

  • (Boolean)

    true if the mode is valid, false otherwise



101
102
103
# File 'documented/util/textstripper.rb', line 101

def self.valid?(mode)
  ALL.include?(mode.to_sym)
end