Module: Spreadsheet::Excel::Offset

Includes:
Compatibility
Included in:
Workbook, Worksheet
Defined in:
lib/spreadsheet/excel/offset.rb

Overview

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Compatibility

#ivar_name, #method_name

Instance Attribute Details

#changesObject (readonly)

Returns the value of attribute changes.



11
12
13
# File 'lib/spreadsheet/excel/offset.rb', line 11

def changes
  @changes
end

#offsetsObject (readonly)

Returns the value of attribute offsets.



11
12
13
# File 'lib/spreadsheet/excel/offset.rb', line 11

def offsets
  @offsets
end

Class Method Details

.append_features(mod) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/spreadsheet/excel/offset.rb', line 18

def self.append_features mod
  super
  mod.module_eval do
    class << self
      include Compatibility

      def offset *keys
        keys.each do |key|
          attr_reader key unless method_defined?(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

Instance Method Details

#initialize(*args) ⇒ Object



12
13
14
15
16
# File 'lib/spreadsheet/excel/offset.rb', line 12

def initialize *args
  super
  @changes = {}
  @offsets = {}
end