Sha256: 57102a8b6866ade74f34b39550ae4b4e3443cf69e10af84c09dc1212f0d8c746

Contents?: true

Size: 1.84 KB

Versions: 5

Compression:

Stored size: 1.84 KB

Contents

module Axlsx
  # The Scaling class defines axis scaling
  class Scaling

    # logarithmic base for a logarithmic axis.
    # must be between 2 and 1000
    # @return [Integer]
    attr_reader :logBase

    # the orientation of the axis
    # must be one of [:minMax, :maxMin]
    # @return [Symbol]
    attr_reader :orientation

    # the maximum scaling
    # @return [Float]
    attr_reader :max

    # the minimu scaling
    # @return [Float]
    attr_reader :min

    # creates a new Scaling object
    # @option options [Integer, Fixnum] logBase
    # @option options [Symbol] orientation
    # @option options [Float] max
    # @option options [Float] min
    def initialize(options={})
      @orientation = :minMax
      @logBase, @min, @max = nil, nil, nil
      options.each do |o|
        self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
      end
    end
    
    # @see logBase
    def logBase=(v) DataTypeValidator.validate "Scaling.logBase", [Integer, Fixnum], v, lambda { |arg| arg >= 2 && arg <= 1000}; @logBase = v; end
    # @see orientation
    def orientation=(v) RestrictionValidator.validate "Scaling.orientation", [:minMax, :maxMin], v; @orientation = v; end
    # @see max
    def max=(v) DataTypeValidator.validate "Scaling.max", Float, v; @max = v; end

    # @see min
    def min=(v) DataTypeValidator.validate "Scaling.min", Float, v; @min = v; end

    # Serializes the axId
    # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
    # @return [String]
    def to_xml(xml)
      xml.send('c:scaling') {
        xml.send('c:logBase', :val=> @logBase) unless @logBase.nil?
        xml.send('c:orientation', :val=> @orientation) unless @orientation.nil?
        xml.send('c:min', :val => @min) unless @min.nil?
        xml.send('c:max', :val => @max) unless @max.nil?
      }
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
axlsx-1.0.13 lib/axlsx/drawing/scaling.rb
axlsx-1.0.11 lib/axlsx/drawing/scaling.rb
axlsx-1.0.10 lib/axlsx/drawing/scaling.rb
axlsx-1.0.10a lib/axlsx/drawing/scaling.rb
axlsx-1.0.9 lib/axlsx/drawing/scaling.rb