lib/axlsx/drawing/series.rb in axlsx-1.0.18 vs lib/axlsx/drawing/series.rb in axlsx-1.1.0

- old
+ new

@@ -23,11 +23,11 @@ self.chart = chart @chart.series << self options.each do |o| self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}=" end - end + end # The index of this series in the chart's series. # @return [Integer] def index @chart.series.index(self) @@ -42,30 +42,30 @@ # @see order def order=(v) Axlsx::validate_unsigned_int(v); @order = v; end # @see title - def title=(v) + def title=(v) v = SeriesTitle.new(v) if v.is_a?(String) || v.is_a?(Cell) DataTypeValidator.validate "#{self.class}.title", SeriesTitle, v @title = v end - - private - + + private + # assigns the chart for this series - def chart=(v) DataTypeValidator.validate "Series.chart", Chart, v; @chart = v; end + def chart=(v) DataTypeValidator.validate "Series.chart", Chart, v; @chart = v; end - # Serializes the series - # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to. + # Serializes the object + # @param [String] str # @return [String] - def to_xml(xml) - xml.ser { - xml.idx :val=>index - xml.order :val=>order || index - title.to_xml(xml) unless title.nil? - yield xml if block_given? - } + def to_xml_string(str = '') + str << '<c:ser>' + str << '<c:idx val="' << index.to_s << '"/>' + str << '<c:order val="' << (order || index).to_s << '"/>' + title.to_xml_string(str) unless title.nil? + yield str if block_given? + str << '</c:ser>' end end end