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
7 8 9 10 11 12 13 14 15 |
# 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'] @template = template end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
16 17 18 |
# File 'lib/review/htmllayout.rb', line 16 def body @body end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
16 17 18 |
# File 'lib/review/htmllayout.rb', line 16 def title @title end |
#toc ⇒ Object (readonly)
Returns the value of attribute toc.
16 17 18 |
# File 'lib/review/htmllayout.rb', line 16 def toc @toc end |
Instance Method Details
#next_chapter ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/review/htmllayout.rb', line 18 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
26 27 28 29 30 31 32 |
# File 'lib/review/htmllayout.rb', line 26 def prev_chapter if @prev.present? "<a href='#{h @prev.id}.html'>#{h @builder.compile_inline @prev.title}</a>" else "" end end |
#result ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/review/htmllayout.rb', line 34 def result if File.exist?(@template) return ERB.new(IO.read(@template)).result(binding) else return @src end end |