Class: Genit::TagProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/genit/tags/tag_processor.rb

Overview

Replace a tag in a template.

Instance Method Summary collapse

Constructor Details

#initialize(working_dir, template, filename, tag) ⇒ TagProcessor

Public: Constructor.

working_dir - The String working directory, where live the project. template - The Nokogiri::XML::Document into which we process the tag. filename - The String name of the page tag - The tag to process as a Nokogiri::XML::Element



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/genit/tags/tag_processor.rb', line 14

def initialize working_dir, template, filename, tag
  @working_dir = working_dir
  @filename = filename
  @template = template
  if tag.genit_class?
    @tag = ClassTag.new(@working_dir, @template, @filename, tag)
  elsif tag.genit_here?
    @tag = HereTag.new(@working_dir, @template, @filename, tag)
  else
    puts "Genit aborted! Unknown tag: #{tag}"
    exit 1
  end
end

Instance Method Details

#processObject

Returns the modified template as a Nokogiri::XML::Document



29
30
31
# File 'lib/genit/tags/tag_processor.rb', line 29

def process
  @tag.process
end