Class: Axlsx::NumVal

Inherits:
StrVal show all
Defined in:
lib/axlsx/drawing/num_val.rb

Overview

This class specifies data for a particular data point.

Instance Attribute Summary collapse

Attributes inherited from StrVal

#v

Instance Method Summary collapse

Methods included from OptionsParser

#parse_options

Constructor Details

#initialize(options = {}) ⇒ NumVal

creates a new NumVal object

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • formatCode (String)
  • v (Integer)


14
15
16
17
# File 'lib/axlsx/drawing/num_val.rb', line 14

def initialize(options = {})
  @format_code = "General"
  super(options)
end

Instance Attribute Details

#format_codeString

A string representing the format code to apply. For more information see see the SpreadsheetML numFmt element's (ยง18.8.30) formatCode attribute.

Returns:

  • (String)


9
10
11
# File 'lib/axlsx/drawing/num_val.rb', line 9

def format_code
  @format_code
end

Instance Method Details

#to_xml_string(idx, str = +'')) ⇒ Object

serialize the object



26
27
28
29
30
31
# File 'lib/axlsx/drawing/num_val.rb', line 26

def to_xml_string(idx, str = +'')
  Axlsx.validate_unsigned_int(idx)
  unless v.to_s.empty?
    str << '<c:pt idx="' << idx.to_s << '" formatCode="' << format_code << '"><c:v>' << v.to_s << '</c:v></c:pt>'
  end
end