lib/thinreports/layout/base.rb in thinreports-0.7.7 vs lib/thinreports/layout/base.rb in thinreports-0.8.0
- old
+ new
@@ -1,80 +1,66 @@
# coding: utf-8
-module ThinReports
+module Thinreports
module Layout
-
+
class Base
EXT_NAME = 'tlf'
-
+ include Utils
+
class << self
# @param [String] filename
- # @return [ThinReports::Layout::Format]
- # @raise [ThinReports::Errors::InvalidLayoutFormat]
- # @raise [ThinReports::Errors::IncompatibleLayoutFormat]
- # @private
+ # @return [Thinreports::Layout::Format]
+ # @raise [Thinreports::Errors::InvalidLayoutFormat]
+ # @raise [Thinreports::Errors::IncompatibleLayoutFormat]
def load_format(filename)
filename += ".#{EXT_NAME}" unless filename =~/\.#{EXT_NAME}$/
-
+
unless File.exists?(filename)
- raise ThinReports::Errors::LayoutFileNotFound
+ raise Thinreports::Errors::LayoutFileNotFound
end
# Build format.
- ThinReports::Layout::Format.build(filename)
+ Thinreports::Layout::Format.build(filename)
end
-
- # @private
- def Page
- const_defined?(:Page) ? Page : Core::Page
- end
-
- private
-
- # @private
- def PageHelpers(&block)
- const_set(:Page, ::Class.new(Core::Page, &block))
- end
end
-
- # @private
+
attr_reader :format
-
+
# @return [String]
attr_reader :filename
-
+
# @return [Symbol]
attr_reader :id
-
+
# @param [String] filename
# @param [Hash] options
# @option options [Symbol] :id (nil)
def initialize(filename, options = {})
@filename = filename
@format = self.class.load_format(filename)
@id = options[:id]
end
-
+
# @return [Boolean] Return the true if is default layout.
def default?
@id.nil?
end
-
+
# @yield [config]
# @yieldparam [List::Configuration] config
# @return [List::Configuration]
def config(&block)
@config ||= Layout::Configuration.new(self)
- block_exec_on(@config, &block)
+ call_block_in(@config, &block)
end
-
- # @param [ThinReports::Report::Base] parent
+
+ # @param [Thinreports::Report::Base] parent
# @param [Hash] options ({})
# @option option [Boolean] :count (true)
# @return [Page]
- # @private
- def init_new_page(parent, options = {})
- self.class.Page.new(parent, self, options)
+ def new_page(parent, options = {})
+ Report::Page.new(parent, self, options)
end
end
-
+
end
end