Class: Axlsx::WorksheetDrawing
- Inherits:
-
Object
- Object
- Axlsx::WorksheetDrawing
- Defined in:
- lib/axlsx/workbook/worksheet/worksheet_drawing.rb
Overview
This is a utility class for serialing the drawing node in a worksheet. Drawing objects have their own serialization that exports a drawing document. This is only for the single node in the worksheet
Instance Attribute Summary collapse
-
#drawing ⇒ Object
readonly
Returns the value of attribute drawing.
-
#worksheet ⇒ Object
readonly
Returns the value of attribute worksheet.
Instance Method Summary collapse
-
#add_chart(chart_type, options) ⇒ Object
adds a chart to the drawing object.
-
#add_image(options) ⇒ Object
adds an image to the drawing object.
-
#has_drawing? ⇒ Boolean
helper method to tell us if the drawing has something in it or not.
-
#initialize(worksheet) ⇒ WorksheetDrawing
constructor
Creates a new WorksheetDrawing.
-
#relationship ⇒ Relationship
The relationship instance for this drawing.
-
#to_xml_string(str = '') ⇒ Object
Serialize the drawing for the worksheet.
Constructor Details
#initialize(worksheet) ⇒ WorksheetDrawing
Creates a new WorksheetDrawing
11 12 13 14 15 |
# File 'lib/axlsx/workbook/worksheet/worksheet_drawing.rb', line 11 def initialize(worksheet) raise ArgumentError, 'you must provide a worksheet' unless worksheet.is_a?(Worksheet) @worksheet = worksheet @drawing = nil end |
Instance Attribute Details
#drawing ⇒ Object (readonly)
Returns the value of attribute drawing.
19 20 21 |
# File 'lib/axlsx/workbook/worksheet/worksheet_drawing.rb', line 19 def drawing @drawing end |
#worksheet ⇒ Object (readonly)
Returns the value of attribute worksheet.
17 18 19 |
# File 'lib/axlsx/workbook/worksheet/worksheet_drawing.rb', line 17 def worksheet @worksheet end |
Instance Method Details
#add_chart(chart_type, options) ⇒ Object
adds a chart to the drawing object
25 26 27 28 |
# File 'lib/axlsx/workbook/worksheet/worksheet_drawing.rb', line 25 def add_chart(chart_type, ) @drawing ||= Drawing.new worksheet drawing.add_chart(chart_type, ) end |
#add_image(options) ⇒ Object
adds an image to the drawing object
33 34 35 36 |
# File 'lib/axlsx/workbook/worksheet/worksheet_drawing.rb', line 33 def add_image() @drawing ||= Drawing.new worksheet drawing.add_image() end |
#has_drawing? ⇒ Boolean
helper method to tell us if the drawing has something in it or not
40 41 42 |
# File 'lib/axlsx/workbook/worksheet/worksheet_drawing.rb', line 40 def has_drawing? @drawing.is_a? Drawing end |
#relationship ⇒ Relationship
The relationship instance for this drawing.
46 47 48 49 |
# File 'lib/axlsx/workbook/worksheet/worksheet_drawing.rb', line 46 def relationship return unless has_drawing? Relationship.new(self, DRAWING_R, "../#{drawing.pn}") end |
#to_xml_string(str = '') ⇒ Object
Serialize the drawing for the worksheet
53 54 55 56 |
# File 'lib/axlsx/workbook/worksheet/worksheet_drawing.rb', line 53 def to_xml_string(str = '') return unless has_drawing? str << "<drawing r:id='#{relationship.Id}'/>" end |