Module: Spreadsheet::Excel::Offset

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

Overview

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.



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

def changes
  @changes
end

#offsetsObject (readonly)

Returns the value of attribute offsets.



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

def offsets
  @offsets
end

Class Method Details

.append_features(mod) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# 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

Instance Method Details

#initialize(*args) ⇒ Object



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

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