Class: Thinreports::BasicReport::Core::Shape::PageNumber::Internal

Inherits:
Basic::Internal show all
Defined in:
lib/thinreports/basic_report/core/shape/page_number/internal.rb

Instance Attribute Summary

Attributes inherited from Base::Internal

#format, #parent, #states

Instance Method Summary collapse

Methods inherited from Basic::Internal

#identifier

Methods inherited from Base::Internal

#copy, #initialize

Methods included from Utils

#blank_value?, #call_block_in, #deep_copy, included

Constructor Details

This class inherits a constructor from Thinreports::BasicReport::Core::Shape::Base::Internal

Instance Method Details

#build_format(page_no, page_count) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/thinreports/basic_report/core/shape/page_number/internal.rb', line 23

def build_format(page_no, page_count)
  return '' if blank_value?(read_format)

  if start_page_number > 1
    page_no += start_page_number - 1
    page_count += start_page_number - 1
  end

  read_format.dup.tap do |f|
    f.gsub! '{page}', page_no.to_s
    f.gsub! '{total}', page_count.to_s
  end
end

#read_formatObject



11
12
13
# File 'lib/thinreports/basic_report/core/shape/page_number/internal.rb', line 11

def read_format
  states.key?(:format) ? states[:format] : format.default_format.dup
end

#reset_formatObject



15
16
17
# File 'lib/thinreports/basic_report/core/shape/page_number/internal.rb', line 15

def reset_format
  states.delete(:format)
end

#start_page_numberObject



45
46
47
# File 'lib/thinreports/basic_report/core/shape/page_number/internal.rb', line 45

def start_page_number
  for_report? ? parent.report.start_page_number : 1
end

#styleObject



37
38
39
# File 'lib/thinreports/basic_report/core/shape/page_number/internal.rb', line 37

def style
  @style ||= PageNumber::Style.new(format)
end

#type_of?(type_name) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/thinreports/basic_report/core/shape/page_number/internal.rb', line 41

def type_of?(type_name)
  type_name == PageNumber::TYPE_NAME
end

#write_format(format) ⇒ Object



19
20
21
# File 'lib/thinreports/basic_report/core/shape/page_number/internal.rb', line 19

def write_format(format)
  states[:format] = format.to_s
end