Class: Govspeak::PostProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/govspeak/post_processor.rb

Constant Summary collapse

@@extensions =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(html) ⇒ PostProcessor

Returns a new instance of PostProcessor.



9
10
11
# File 'lib/govspeak/post_processor.rb', line 9

def initialize(html)
  @input = html
end

Instance Attribute Details

#inputObject (readonly)

Returns the value of attribute input.



5
6
7
# File 'lib/govspeak/post_processor.rb', line 5

def input
  @input
end

Class Method Details

.extension(title, &block) ⇒ Object



24
25
26
# File 'lib/govspeak/post_processor.rb', line 24

def self.extension(title, &block)
  @@extensions << [title, block]
end

.process(html) ⇒ Object



20
21
22
# File 'lib/govspeak/post_processor.rb', line 20

def self.process(html)
  new(html).output
end

Instance Method Details

#outputObject



28
29
30
31
32
33
34
# File 'lib/govspeak/post_processor.rb', line 28

def output
  document = nokogiri_document
  @@extensions.each do |_, block|
    instance_exec(document, &block)
  end
  document.to_html
end