class Mbrao::ParsingEngines::Base
A base class for all parsers.
Public Instance Methods
Filters content of a post by locale.
@param _content [Content] The content to filter. @param _locales [String|Array] The desired locales. Can include `*` to match all. @param _options [Hash] Options to customize parsing. @return [String|HashWithIndifferentAccess] Return the filtered content in the desired locales. If only one locale is required, then a `String` is
returned, else a `HashWithIndifferentAccess` with locales as keys.
# File lib/mbrao/parsing_engines/base.rb, line 37 def filter_content(_content, _locales = [], _options = {}) raise Mbrao::Exceptions::Unimplemented end
Parses a content and return a {Content Content} object.
@param content [Object] The content to parse. @param options [Hash] Options to customize parsing.
# File lib/mbrao/parsing_engines/base.rb, line 45 def parse(content, options = {}) metadata, body = separate_components(content, options) metadata = parse_metadata(metadata, options) Mbrao::Content.create(metadata, body) end
Parses metadata part and returns all valid metadata.
@param _content [Object] The content to parse. @param _options [Hash] Options to customize parsing. @return [Hash] All valid metadata for the content.
# File lib/mbrao/parsing_engines/base.rb, line 26 def parse_metadata(_content, _options = {}) raise Mbrao::Exceptions::Unimplemented end
Parses a whole post content and return its metadata and content parts.
@param _content [Object] The content to parse. @param _options [Hash] Options to customize parsing. @return [Array] An array of metadata and contents parts.
# File lib/mbrao/parsing_engines/base.rb, line 17 def separate_components(_content, _options = {}) raise Mbrao::Exceptions::Unimplemented end