ru_excel 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +21 -0
- data/Rakefile +30 -0
- data/VERSION +1 -0
- data/examples/big-16Mb_test.rb +35 -0
- data/examples/test_multiline.rb +13 -0
- data/examples/test_utf8.rb +12 -0
- data/lib/ru_excel/biff_records.rb +1930 -0
- data/lib/ru_excel/bitmap.rb +222 -0
- data/lib/ru_excel/cell.rb +57 -0
- data/lib/ru_excel/column.rb +31 -0
- data/lib/ru_excel/compound_doc.rb +268 -0
- data/lib/ru_excel/deco.rb +156 -0
- data/lib/ru_excel/excel_magic.rb +1019 -0
- data/lib/ru_excel/formatting.rb +231 -0
- data/lib/ru_excel/row.rb +170 -0
- data/lib/ru_excel/style.rb +135 -0
- data/lib/ru_excel/unicode_utils.rb +73 -0
- data/lib/ru_excel/workbook.rb +365 -0
- data/lib/ru_excel/worksheet.rb +466 -0
- data/lib/ru_excel.rb +16 -0
- metadata +73 -0
@@ -0,0 +1,156 @@
|
|
1
|
+
class TrueClass
|
2
|
+
def to_i; 1; end
|
3
|
+
end
|
4
|
+
class FalseClass
|
5
|
+
def to_i; 0; end
|
6
|
+
end
|
7
|
+
|
8
|
+
module Excel
|
9
|
+
module Deco
|
10
|
+
def accepts(method, *types)
|
11
|
+
class_eval do
|
12
|
+
method_accepts = "#{method}_accepts".to_sym
|
13
|
+
alias_method method_accepts, method.to_sym
|
14
|
+
define_method(method.to_sym) do |*args|
|
15
|
+
for t,a in types.zip(args)
|
16
|
+
raise "Type mismatch" unless t === a
|
17
|
+
end
|
18
|
+
self.send(method_accepts, *args)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def accepts_bool(*methods)
|
24
|
+
methods.each{|method|
|
25
|
+
class_eval do
|
26
|
+
method_accepts = "#{method}_accepts_bool".to_sym
|
27
|
+
alias_method method_accepts, method.to_sym
|
28
|
+
define_method(method.to_sym) do |bool|
|
29
|
+
raise "Type mismatch" if bool!=true and bool != false
|
30
|
+
self.send(method_accepts, bool)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
def returns(method, *types)
|
37
|
+
class_eval do
|
38
|
+
method_returns = "#{method}_returns".to_sym
|
39
|
+
alias_method method_returns, method.to_sym
|
40
|
+
define_method(method.to_sym) do |*args|
|
41
|
+
ret = self.send(method_returns, *args)
|
42
|
+
for t,r in types.zip(ret)
|
43
|
+
raise "Type ret mismatch" unless t===a
|
44
|
+
end
|
45
|
+
ret
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def short_accessor(*attrs)
|
51
|
+
attrs.each do |attr|
|
52
|
+
module_eval <<-"EOF;"
|
53
|
+
def #{attr}=(value)
|
54
|
+
#raise "Type Mismatch" if not Integer === value
|
55
|
+
@#{attr} = value.to_i & 0xFFFF
|
56
|
+
end
|
57
|
+
attr_reader :#{attr}
|
58
|
+
EOF;
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def int_accessor(*attrs)
|
63
|
+
attrs.each do |attr|
|
64
|
+
module_eval <<-"EOF;"
|
65
|
+
def #{attr}=(value)
|
66
|
+
#raise "Type Mismatch" if not Integer === value
|
67
|
+
@#{attr} = value.to_i
|
68
|
+
end
|
69
|
+
attr_reader :#{attr}
|
70
|
+
EOF;
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def absint_accessor(*attrs)
|
75
|
+
attrs.each do |attr|
|
76
|
+
module_eval <<-"EOF;"
|
77
|
+
def #{attr}=(value)
|
78
|
+
#raise "Type Mismatch" if not Integer === value
|
79
|
+
@#{attr} = value.to_i.abs
|
80
|
+
end
|
81
|
+
attr_reader :#{attr}
|
82
|
+
EOF;
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def bool_int_accessor(*attrs)
|
87
|
+
attrs.each do |attr|
|
88
|
+
module_eval <<-"EOF;"
|
89
|
+
def #{attr}=(value)
|
90
|
+
#raise "Type Mismatch" if value != true and value != false
|
91
|
+
@#{attr} = value.to_i
|
92
|
+
end
|
93
|
+
def #{attr}
|
94
|
+
[false, true][@#{attr}]
|
95
|
+
end
|
96
|
+
EOF;
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def bool_accessor(*attrs)
|
101
|
+
attrs.each do |attr|
|
102
|
+
module_eval <<-"EOF;"
|
103
|
+
def #{attr}=(value)
|
104
|
+
@#{attr} = value ? true : false
|
105
|
+
end
|
106
|
+
attr_reader :#{attr}
|
107
|
+
EOF;
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def float_accessor(*attrs)
|
112
|
+
attrs.each do |attr|
|
113
|
+
module_eval <<-"EOF;"
|
114
|
+
def #{attr}=(value)
|
115
|
+
@#{attr} = value.to_f
|
116
|
+
end
|
117
|
+
attr_reader :#{attr}
|
118
|
+
EOF;
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def string_accessor(*attrs)
|
123
|
+
attrs.each do |attr|
|
124
|
+
module_eval <<-"EOF;"
|
125
|
+
def #{attr}=(value)
|
126
|
+
@#{attr} = value.to_s
|
127
|
+
end
|
128
|
+
attr_reader :#{attr}
|
129
|
+
EOF;
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def array_accessor(*attrs)
|
134
|
+
attrs.each do |attr|
|
135
|
+
module_eval <<-"EOF;"
|
136
|
+
def #{attr}=(value)
|
137
|
+
@#{attr} = value.to_a
|
138
|
+
end
|
139
|
+
attr_reader :#{attr}
|
140
|
+
EOF;
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def type_accessor(type, *attrs)
|
145
|
+
attrs.each do |attr|
|
146
|
+
module_eval <<-"EOF;"
|
147
|
+
def #{attr}=(value)
|
148
|
+
raise "Type Mismatch" if not #{type.name} === value
|
149
|
+
@#{attr} = value
|
150
|
+
end
|
151
|
+
attr_reader :#{attr}
|
152
|
+
EOF;
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|