summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/drawing/str_val.rb
blob: 5f453d97864ad325f2a9316a2d352c2576c061d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# -*- coding: utf-8 -*-
module Axlsx

  #This class specifies data for a particular data point.
  class StrVal

    # a string value.
    # @return [String]
    attr_reader :v

    # creates a new StrVal object
    # @option options [String] v
    def initialize(options={})
      @v = ""
      @idx = 0
      options.each do |o|
        self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
      end
    end
    # @see v
    def v=(v)
      @v = v.to_s
    end

    # serialize the object
    def to_xml_string(idx, str = "")
      Axlsx::validate_unsigned_int(idx)
      str << '<c:pt idx="' << idx.to_s << '"><c:v>' << v.to_s << '</c:v></c:pt>'
    end

  end

end