Sha256: 00bc3bbde68b0e8808d38f55f6e53a4150185c1b09a4b0d2e8f794376a31076f
Contents?: true
Size: 1.41 KB
Versions: 16
Compression:
Stored size: 1.41 KB
Contents
# encoding: utf-8 module LocalPac module ProxyPac class HTMLDivStyle private attr_reader :data, :main_container_css_class, :element_container_css_class public def initialize(options = {}) @main_container_css_class = options.fetch(:main_container_css_class) @element_container_css_class = options.fetch(:element_container_css_class) @data = [] rescue KeyError => e raise ArgumentError, e.message end def add_data(data) @data << data end def to_s data_row = data.reduce([]) do |memo, element| memo << " <div class=\"#{element_container_css_class}\">" if element.header memo << " <div class=\"#{element.header_css_class}\">" if element.header_css_class memo << " #{element.header}" memo << ' </div>' if element.header_css_class end memo << " <div class=\"#{element.element_css_class}\">" if element.element_css_class memo << " #{element.element}" memo << ' </div>' if element.element_css_class memo << ' </div>' end content = ["<div class=\"#{main_container_css_class}\">"] content.concat data_row content << '</div>' content.join("\n") end end end end
Version data entries
16 entries across 16 versions & 1 rubygems