Class: Axlsx::Scaling

Inherits:
Object
  • Object
show all
Includes:
OptionsParser
Defined in:
lib/axlsx/drawing/scaling.rb

Overview

The Scaling class defines axis scaling

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from OptionsParser

#parse_options

Constructor Details

#initialize(options = {}) ⇒ Scaling

creates a new Scaling object

Parameters:

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

    a customizable set of options

Options Hash (options):

  • logBase (Integer)
  • orientation (Symbol)
  • max (Float)
  • min (Float)


11
12
13
14
15
# File 'lib/axlsx/drawing/scaling.rb', line 11

def initialize(options = {})
  @orientation = :minMax
  @logBase, @min, @max = nil, nil, nil
  parse_options options
end

Instance Attribute Details

#logBaseInteger

logarithmic base for a logarithmic axis. must be between 2 and 1000

Returns:

  • (Integer)


20
21
22
# File 'lib/axlsx/drawing/scaling.rb', line 20

def logBase
  @logBase
end

#maxFloat

the maximum scaling

Returns:

  • (Float)


29
30
31
# File 'lib/axlsx/drawing/scaling.rb', line 29

def max
  @max
end

#minFloat

the minimu scaling

Returns:

  • (Float)


33
34
35
# File 'lib/axlsx/drawing/scaling.rb', line 33

def min
  @min
end

#orientationSymbol

the orientation of the axis must be one of [:minMax, :maxMin]

Returns:

  • (Symbol)


25
26
27
# File 'lib/axlsx/drawing/scaling.rb', line 25

def orientation
  @orientation
end

Instance Method Details

#to_xml_string(str = '') ⇒ String

Serializes the object

Parameters:

  • str (String) (defaults to: '')

Returns:

  • (String)


48
49
50
51
52
53
54
55
# File 'lib/axlsx/drawing/scaling.rb', line 48

def to_xml_string(str = '')
  str << '<c:scaling>'
  str << ('<c:logBase val="' << @logBase.to_s << '"/>') unless @logBase.nil?
  str << ('<c:orientation val="' << @orientation.to_s << '"/>') unless @orientation.nil?
  str << ('<c:min val="' << @min.to_s << '"/>') unless @min.nil?
  str << ('<c:max val="' << @max.to_s << '"/>') unless @max.nil?
  str << '</c:scaling>'
end