Sha256: c5812ea78d7e33f925782c7d03ed6c0dbce680c1f4dfd3c4cd1230e787762168
Contents?: true
Size: 1.19 KB
Versions: 37
Compression:
Stored size: 1.19 KB
Contents
require 'caracal/core/models/table_model' require 'caracal/errors' module Caracal module Core # This module encapsulates all the functionality related to adding tables # to the document. # module Tables def self.included(base) base.class_eval do #------------------------------------------------------------- # Public Methods #------------------------------------------------------------- def table(*args, &block) options = Caracal::Utilities.extract_options!(args) options.merge!({ data: args.first }) if args.first model = Caracal::Core::Models::TableModel.new(options, &block) if respond_to?(:page_width) container_width = page_width - page_margin_left - page_margin_right model.calculate_width(container_width) end if model.valid? contents << model else raise Caracal::Errors::InvalidModelError, 'Table must be provided data for at least one cell.' end model end end end end end end
Version data entries
37 entries across 37 versions & 2 rubygems