Class: Axlsx::VmlDrawing
- Inherits:
-
Object
- Object
- Axlsx::VmlDrawing
- Defined in:
- lib/axlsx/drawing/vml_drawing.rb
Overview
a vml drawing used for comments in Excel.
Instance Method Summary collapse
-
#initialize(comments) ⇒ VmlDrawing
constructor
creates a new Vml Drawing object.
-
#pn ⇒ String
The part name for this vml drawing.
-
#to_xml_string(str = +'')) ⇒ String
serialize the vml_drawing to xml.
Constructor Details
#initialize(comments) ⇒ VmlDrawing
creates a new Vml Drawing object.
8 9 10 11 12 |
# File 'lib/axlsx/drawing/vml_drawing.rb', line 8 def initialize(comments) raise ArgumentError, "you must provide a comments object" unless comments.is_a?(Comments) @comments = comments end |
Instance Method Details
#pn ⇒ String
The part name for this vml drawing
16 17 18 |
# File 'lib/axlsx/drawing/vml_drawing.rb', line 16 def pn format(VML_DRAWING_PN, @comments.worksheet.index + 1) end |
#to_xml_string(str = +'')) ⇒ String
serialize the vml_drawing to xml.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/axlsx/drawing/vml_drawing.rb', line 23 def to_xml_string(str = +'') str << " <xml xmlns:v=\"urn:schemas-microsoft-com:vml\"\n xmlns:o=\"urn:schemas-microsoft-com:office:office\"\n xmlns:x=\"urn:schemas-microsoft-com:office:excel\">\n <o:shapelayout v:ext=\"edit\">\n <o:idmap v:ext=\"edit\" data=\"\#{@comments.worksheet.index + 1}\"/>\n </o:shapelayout>\n <v:shapetype id=\"_x0000_t202\" coordsize=\"21600,21600\" o:spt=\"202\"\n path=\"m0,0l0,21600,21600,21600,21600,0xe\">\n <v:stroke joinstyle=\"miter\"/>\n <v:path gradientshapeok=\"t\" o:connecttype=\"rect\"/>\n </v:shapetype>\n XML\n @comments.each { |comment| comment.vml_shape.to_xml_string str }\n str << \"</xml>\"\nend\n" |