Class: HTMLLayout
- Includes:
- ERB::Util
- Defined in:
- lib/review/htmllayout.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#toc ⇒ Object
readonly
Returns the value of attribute toc.
Instance Method Summary collapse
-
#initialize(params, template) ⇒ HTMLLayout
constructor
A new instance of HTMLLayout.
- #next_chapter ⇒ Object
- #prev_chapter ⇒ Object
- #result ⇒ Object
Constructor Details
#initialize(params, template) ⇒ HTMLLayout
Returns a new instance of HTMLLayout.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/review/htmllayout.rb', line 7 def initialize(params, template) @body = params['body'] @title = params['title'] @toc = params['toc'] @next = params['next'] @prev = params['prev'] @builder = params['builder'] @language = params['language'] @stylesheets = params['stylesheets'] @template = template end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
18 19 20 |
# File 'lib/review/htmllayout.rb', line 18 def body @body end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
18 19 20 |
# File 'lib/review/htmllayout.rb', line 18 def title @title end |
#toc ⇒ Object (readonly)
Returns the value of attribute toc.
18 19 20 |
# File 'lib/review/htmllayout.rb', line 18 def toc @toc end |
Instance Method Details
#next_chapter ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/review/htmllayout.rb', line 20 def next_chapter if @next.present? "<a href='#{h @next.id}.html'>#{h @builder.compile_inline @next.title}</a>" else "" end end |
#prev_chapter ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/review/htmllayout.rb', line 28 def prev_chapter if @prev.present? "<a href='#{h @prev.id}.html'>#{h @builder.compile_inline @prev.title}</a>" else "" end end |
#result ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/review/htmllayout.rb', line 36 def result if File.exist?(@template) return ERB.new(IO.read(@template)).result(binding) else return @src end end |