Class: Thinreports::BasicReport::Report::Page

Inherits:
BlankPage
  • Object
show all
Includes:
Core::Shape::Manager::Target
Defined in:
lib/thinreports/basic_report/report/page.rb

Instance Attribute Summary collapse

Attributes included from Core::Shape::Manager::Target

#manager

Attributes inherited from BlankPage

#no

Instance Method Summary collapse

Methods included from Core::Shape::Manager::Target

#[], #[]=, #item, #item_exists?, #list, #values

Methods included from Utils

#blank_value?, #call_block_in, #deep_copy, included

Methods inherited from BlankPage

#count?

Constructor Details

#initialize(report, layout, options = {}) ⇒ Page

Returns a new instance of Page.

Parameters:

Options Hash (options):

  • :count (Boolean) — default: true


51
52
53
54
55
56
57
58
59
60
61
# File 'lib/thinreports/basic_report/report/page.rb', line 51

def initialize(report, layout, options = {})
  super(options.key?(:count) ? options[:count] : true)

  @report = report
  @layout = layout
  @finalized = false

  initialize_manager(layout.format) do |f|
    Core::Shape::Interface(self, f)
  end
end

Instance Attribute Details

#layoutThinreports::BasicReport::Layout::Base (readonly)



45
46
47
# File 'lib/thinreports/basic_report/report/page.rb', line 45

def layout
  @layout
end

#reportThinreports::BasicReport::Report::Base (readonly)



42
43
44
# File 'lib/thinreports/basic_report/report/page.rb', line 42

def report
  @report
end

Instance Method Details

#blank?Boolean

Returns (false).

Returns:

  • (Boolean)

    (false)



64
65
66
# File 'lib/thinreports/basic_report/report/page.rb', line 64

def blank?
  false
end

#copyObject



68
69
70
71
72
73
74
75
76
77
78
# File 'lib/thinreports/basic_report/report/page.rb', line 68

def copy
  new_page = self.class.new(report, layout, count: count?)

  manager.shapes.each do |id, shape|
    new_shape = shape.copy(new_page)
    new_page.manager.shapes[id] = new_shape

    new_page.manager.lists[id] = new_shape if new_shape.internal.type_of?(Core::Shape::List::TYPE_NAME)
  end
  new_page
end

#finalize(options = {}) ⇒ Object

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :at (:create, :copy) — default: :create


82
83
84
85
86
87
88
89
# File 'lib/thinreports/basic_report/report/page.rb', line 82

def finalize(options = {})
  at = options[:at] || :create

  # For list shapes.
  manager.lists.each_value { |list| list.manager.finalize } if at == :create

  @finalized = true
end

#finalized?Boolean

Returns:

  • (Boolean)


91
92
93
# File 'lib/thinreports/basic_report/report/page.rb', line 91

def finalized?
  @finalized
end