Class: XlsxWriter::HeaderFooter::HF::LCR
- Inherits:
-
Object
- Object
- XlsxWriter::HeaderFooter::HF::LCR
- Defined in:
- lib/xlsx_writer/header_footer.rb
Constant Summary collapse
- FONT =
%{"Arial,Regular"}
- SIZE =
10
Instance Attribute Summary collapse
-
#contents ⇒ Object
Returns the value of attribute contents.
-
#hf ⇒ Object
readonly
Returns the value of attribute hf.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #code ⇒ Object
- #has_image? ⇒ Boolean
- #image_id ⇒ Object
-
#initialize(hf, id) ⇒ LCR
constructor
A new instance of LCR.
- #present? ⇒ Boolean
- #render ⇒ Object
Constructor Details
#initialize(hf, id) ⇒ LCR
Returns a new instance of LCR.
58 59 60 61 |
# File 'lib/xlsx_writer/header_footer.rb', line 58 def initialize(hf, id) @hf = hf @id = id end |
Instance Attribute Details
#contents ⇒ Object
Returns the value of attribute contents.
54 55 56 |
# File 'lib/xlsx_writer/header_footer.rb', line 54 def contents @contents end |
#hf ⇒ Object (readonly)
Returns the value of attribute hf.
55 56 57 |
# File 'lib/xlsx_writer/header_footer.rb', line 55 def hf @hf end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
56 57 58 |
# File 'lib/xlsx_writer/header_footer.rb', line 56 def id @id end |
Instance Method Details
#code ⇒ Object
98 99 100 |
# File 'lib/xlsx_writer/header_footer.rb', line 98 def code [ '', id, FONT, SIZE, render ].join('&') end |
#has_image? ⇒ Boolean
67 68 69 |
# File 'lib/xlsx_writer/header_footer.rb', line 67 def has_image? ::Array.wrap(contents).any? { |v| v.is_a?(XlsxWriter::Image) } end |
#image_id ⇒ Object
71 72 73 |
# File 'lib/xlsx_writer/header_footer.rb', line 71 def image_id [ id, hf.id ].join end |
#present? ⇒ Boolean
63 64 65 |
# File 'lib/xlsx_writer/header_footer.rb', line 63 def present? contents.present? end |
#render ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/xlsx_writer/header_footer.rb', line 75 def render out = case contents when :page_x_of_y 'Page &P of &N' when ::Array contents.map do |v| case v when XlsxWriter::Image v.lcr = self '&G' else v end end.join when XlsxWriter::Image contents.lcr = self '&G' else contents end "K000000#{out}" end |