Class: HTML::Pipeline::BodyContent

Inherits:
Object
  • Object
show all
Defined in:
lib/html/pipeline/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.



15
16
17
18
19
# File 'lib/html/pipeline/body_content.rb', line 15

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.



25
26
27
# File 'lib/html/pipeline/body_content.rb', line 25

def result
  @result
end

Instance Method Details

#documentObject

Public: Parses the output into a DocumentFragment.

Returns a DocumentFragment.



39
40
41
# File 'lib/html/pipeline/body_content.rb', line 39

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

#outputObject

Public: Gets the updated body from the Pipeline result.

Returns a String or DocumentFragment.



32
33
34
# File 'lib/html/pipeline/body_content.rb', line 32

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