Class: Genit::Fragment
- Inherits:
-
Object
- Object
- Genit::Fragment
- Defined in:
- lib/genit/documents/fragment.rb
Overview
Replace each fragment in a page.
Instance Method Summary collapse
-
#initialize(file, working_dir) ⇒ Fragment
constructor
Public: Constructor.
-
#to_html ⇒ Object
Public: Get the page in html format.
Constructor Details
#initialize(file, working_dir) ⇒ Fragment
Public: Constructor.
file - Full String filename of the page. working_dir - The String working directory, where live the project.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/genit/documents/fragment.rb', line 12 def initialize file, working_dir @page = HtmlDocument.open_fragment file @working_dir = working_dir HtmlDocument.(@page).each do |tag| case tag['class'] when 'fragment' @file = tag['file'] error "Incomplete #{tag}" unless tag.key?('file') unless File.exists?(File.join(@working_dir, FRAGMENTS_DIR, @file)) error "No such file #{tag}" end replace_fragment end end end |
Instance Method Details
#to_html ⇒ Object
Public: Get the page in html format.
Returns the html code of the page as a String.
31 32 33 |
# File 'lib/genit/documents/fragment.rb', line 31 def to_html @page.to_html end |