Class: HtmlFormat::Generator
- Inherits:
-
Object
- Object
- HtmlFormat::Generator
- Includes:
- ActionView::Helpers::TagHelper
- Defined in:
- lib/html_format/generator.rb
Instance Attribute Summary collapse
-
#output_buffer ⇒ Object
Returns the value of attribute output_buffer.
Class Method Summary collapse
Instance Method Summary collapse
- #generate(obj) ⇒ Object
-
#initialize(options) ⇒ Generator
constructor
A new instance of Generator.
Constructor Details
#initialize(options) ⇒ Generator
Returns a new instance of Generator.
48 49 50 |
# File 'lib/html_format/generator.rb', line 48 def initialize() = HtmlFormat..merge(depth: 0).merge() end |
Instance Attribute Details
#output_buffer ⇒ Object
Returns the value of attribute output_buffer.
23 24 25 |
# File 'lib/html_format/generator.rb', line 23 def output_buffer @output_buffer end |
Class Method Details
.generate(*args, &block) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/html_format/generator.rb', line 25 def self.generate(*args, &block) if block_given? object = yield = args. else if args.size == 0 return elsif args.size == 1 object = args.first = {} else = args. if args.size > 1 object = args else object = args.first end end end new().generate(object) end |
Instance Method Details
#generate(obj) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/html_format/generator.rb', line 52 def generate(obj) return if obj.blank? info = function_table.find { |e| e[:_case].call(obj) } body = ''.html_safe if v = [:caption].presence body << v end if [:header_patch] if info[:header_process] if v = info[:header_process].call(obj) body << v end end end body << info[:process].call(obj) body = tag.table(body, :class => table_class(info)) if [:depth].zero? if [:responsive] body = tag.div(body, :class => 'table-responsive') end if [:title].present? body = tag.send([:title_tag], [:title], :class => 'title') + body end end tag.div(body, :class => ['html_format', "html_format_depth_#{@options[:depth]}"]) end |