Class: HTML::Pipeline::BodyContent

Inherits:
Object
  • Object
show all
Defined in:
lib/html/pipeline_plus/body_content.rb

Overview

Public: Runs a String of content through an HTML processing pipeline, providing easy access to a generated DocumentFragment.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body, context, pipeline) ⇒ BodyContent

Public: Initialize a BodyContent.

body - A String body. context - A Hash of context options for the filters. pipeline - A HTML::Pipeline object with one or more Filters.



13
14
15
16
17
# File 'lib/html/pipeline_plus/body_content.rb', line 13

def initialize(body, context, pipeline)
  @body = body
  @context = context
  @pipeline = pipeline
end

Instance Attribute Details

#resultObject (readonly)

Public: Gets the memoized result of the body content as it passed through the Pipeline.

Returns a Hash, or something similar as defined by @pipeline.result_class.



23
24
25
# File 'lib/html/pipeline_plus/body_content.rb', line 23

def result
  @result
end

Instance Method Details

#documentObject

Public: Parses the output into a DocumentFragment.

Returns a DocumentFragment.



37
38
39
# File 'lib/html/pipeline_plus/body_content.rb', line 37

def document
  @document ||= HTML::Pipeline.parse output
end

#outputObject

Public: Gets the updated body from the Pipeline result.

Returns a String or DocumentFragment.



30
31
32
# File 'lib/html/pipeline_plus/body_content.rb', line 30

def output
  @output ||= result[:output]
end