Class: XlsxWriter::HeaderFooter::HF::LCR

Inherits:
Object
  • Object
show all
Defined in:
lib/xlsx_writer/header_footer.rb

Constant Summary collapse

FONT =
%{"Arial,Regular"}
SIZE =
10

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#contentsObject

Returns the value of attribute contents.



54
55
56
# File 'lib/xlsx_writer/header_footer.rb', line 54

def contents
  @contents
end

#hfObject (readonly)

Returns the value of attribute hf.



55
56
57
# File 'lib/xlsx_writer/header_footer.rb', line 55

def hf
  @hf
end

#idObject (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

#codeObject



98
99
100
# File 'lib/xlsx_writer/header_footer.rb', line 98

def code
  [ '', id, FONT, SIZE, render ].join('&')
end

#has_image?Boolean

Returns:

  • (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_idObject



71
72
73
# File 'lib/xlsx_writer/header_footer.rb', line 71

def image_id
  [ id, hf.id ].join
end

#present?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/xlsx_writer/header_footer.rb', line 63

def present?
  contents.present?
end

#renderObject



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