Class: Kayessess::SectionExample
- Inherits:
-
Object
- Object
- Kayessess::SectionExample
- Defined in:
- lib/kayessess/section_example.rb
Overview
SectionExample is a untility class for helping to render Section Examples. It is passed into the section_example partial and then used as a view object.
Instance Attribute Summary collapse
-
#html ⇒ Object
Returns the value of attribute html.
-
#section ⇒ Object
Returns the value of attribute section.
Instance Method Summary collapse
- #extra_classes ⇒ Object
- #html_for_modifier(modifier) ⇒ Object
- #html_unescaped ⇒ Object
-
#initialize(section, html, options = {}) ⇒ SectionExample
constructor
A new instance of SectionExample.
- #modifiers ⇒ Object
Constructor Details
#initialize(section, html, options = {}) ⇒ SectionExample
Returns a new instance of SectionExample.
8 9 10 11 12 |
# File 'lib/kayessess/section_example.rb', line 8 def initialize(section, html, = {}) @section = section @html = html @options = end |
Instance Attribute Details
#html ⇒ Object
Returns the value of attribute html.
6 7 8 |
# File 'lib/kayessess/section_example.rb', line 6 def html @html end |
#section ⇒ Object
Returns the value of attribute section.
6 7 8 |
# File 'lib/kayessess/section_example.rb', line 6 def section @section end |
Instance Method Details
#extra_classes ⇒ Object
14 15 16 |
# File 'lib/kayessess/section_example.rb', line 14 def extra_classes @options.class || '' end |
#html_for_modifier(modifier) ⇒ Object
32 33 34 |
# File 'lib/kayessess/section_example.rb', line 32 def html_for_modifier(modifier) html.gsub('$modifier_class', "#{modifier.class_name}").html_safe end |
#html_unescaped ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/kayessess/section_example.rb', line 18 def html_unescaped cleaned_html = @html .gsub('$modifier_class', '') .gsub(/class="([\w\s-]+)"/) {|matches| "class=\"#{$1.strip}\"" } .gsub(' class=""', '') .gsub(' style=".+"', '') .gsub(/^$\n/, '') Kayessess.markdownerize("```html\n#{cleaned_html}\n```") end |
#modifiers ⇒ Object
28 29 30 |
# File 'lib/kayessess/section_example.rb', line 28 def modifiers @section.modifiers end |