Class: Govspeak::PostProcessor

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(html, govspeak_document) ⇒ PostProcessor

Returns a new instance of PostProcessor.



90
91
92
93
# File 'lib/govspeak/post_processor.rb', line 90

def initialize(html, govspeak_document)
  @input = html
  @govspeak_document = govspeak_document
end

Instance Attribute Details

#govspeak_documentObject (readonly)

Returns the value of attribute govspeak_document.



88
89
90
# File 'lib/govspeak/post_processor.rb', line 88

def govspeak_document
  @govspeak_document
end

#inputObject (readonly)

Returns the value of attribute input.



88
89
90
# File 'lib/govspeak/post_processor.rb', line 88

def input
  @input
end

Class Method Details

.extension(title, &block) ⇒ Object



15
16
17
# File 'lib/govspeak/post_processor.rb', line 15

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

.extensionsObject



7
8
9
# File 'lib/govspeak/post_processor.rb', line 7

def self.extensions
  @extensions
end

.process(html, govspeak_document) ⇒ Object



11
12
13
# File 'lib/govspeak/post_processor.rb', line 11

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

Instance Method Details

#outputObject



95
96
97
98
99
100
101
# File 'lib/govspeak/post_processor.rb', line 95

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