Class: TextUtils::FormatQualifier

Inherits:
Processor
  • Object
show all
Defined in:
lib/text_utils/format_qualifier.rb

Instance Method Summary collapse

Methods inherited from Processor

#initialize

Constructor Details

This class inherits a constructor from TextUtils::Processor

Instance Method Details

#call(data, env) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
# File 'lib/text_utils/format_qualifier.rb', line 2

def call data, env
  env[:format] = (
    (data =~ /\A\s*<[a-z_\-0-9]+>.*<\/[a-z_\-0-9]+>\s*\z/im) or
    (data =~ /\A\s*<[a-z_\-0-9]+\/>\s*\z/i)
  ) ? :html : :markdown

  data = call_next data, env

  raise "some processor in pipe clear the data format!" unless env[:format]
  data
end