Module: Burly

Defined in:
lib/burly.rb,
lib/burly/parser.rb,
lib/burly/exceptions.rb,
lib/burly/parsers/html_parser.rb,
lib/burly/parsers/json_parser.rb,
lib/burly/parsers/plaintext_parser.rb

Defined Under Namespace

Modules: Parsers Classes: Parser, UnsupportedMimeType

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.registered_parsersObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



16
17
18
# File 'lib/burly.rb', line 16

def registered_parsers
  @registered_parsers
end

Class Method Details

.parse(document, mime_type: "text/plain") ⇒ Array<String>

Parameters:

  • document (String)

Returns:

  • (Array<String>)

Raises:



22
23
24
25
26
27
28
# File 'lib/burly.rb', line 22

def self.parse(document, mime_type: "text/plain")
  parser = registered_parsers[mime_type]

  raise UnsupportedMimeType unless parser

  parser.new(document).parse
end

.register_parser(klass) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



31
32
33
# File 'lib/burly.rb', line 31

def self.register_parser(klass)
  klass.mime_types.each { |mime_type| @registered_parsers[mime_type] = klass }
end