module Spreadsheet::Excel::Offset

This module is used to keep track of offsets in modified Excel documents. Considered internal and subject to change without notice.

Attributes

changes[R]
offsets[R]

Public Class Methods

append_features(mod) click to toggle source
Calls superclass method
# File lib/spreadsheet/excel/offset.rb, line 16
def Offset.append_features mod
  super
  mod.module_eval do
    class << self
      include Compatibility
      def offset *keys
        keys.each do |key|
          attr_reader key unless instance_methods.include? method_name(key)
          define_method "#{key}=" do |value|
            @changes.store key, true
            instance_variable_set ivar_name(key), value
          end
          define_method "set_#{key}" do |value, pos, len|
            instance_variable_set ivar_name(key), value
            @offsets.store key, [pos, len]
            havename = "have_set_#{key}"
            send(havename, value, pos, len) if respond_to? havename
          end
        end
      end
    end
  end
end
new(*args) click to toggle source
Calls superclass method
# File lib/spreadsheet/excel/offset.rb, line 11
def initialize *args
  super
  @changes = {}
  @offsets = {}
end
offset(*keys) click to toggle source
# File lib/spreadsheet/excel/offset.rb, line 21
def offset *keys
  keys.each do |key|
    attr_reader key unless instance_methods.include? method_name(key)
    define_method "#{key}=" do |value|
      @changes.store key, true
      instance_variable_set ivar_name(key), value
    end
    define_method "set_#{key}" do |value, pos, len|
      instance_variable_set ivar_name(key), value
      @offsets.store key, [pos, len]
      havename = "have_set_#{key}"
      send(havename, value, pos, len) if respond_to? havename
    end
  end
end