textwrap 0.1.1 → 0.1.2
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/lib/textwrap.rb +18 -13
- metadata +1 -1
data/lib/textwrap.rb
CHANGED
@@ -120,20 +120,23 @@ module Textwrap
|
|
120
120
|
end
|
121
121
|
|
122
122
|
class TextWrapper
|
123
|
-
@@kwargs =
|
124
|
-
:width
|
125
|
-
:expand_tabs
|
126
|
-
:replace_whitespace
|
127
|
-
:initial_indent
|
128
|
-
:subsequent_indent
|
129
|
-
:break_long_words
|
130
|
-
|
131
|
-
|
132
|
-
|
123
|
+
@@kwargs = [
|
124
|
+
:width,
|
125
|
+
:expand_tabs,
|
126
|
+
:replace_whitespace,
|
127
|
+
:initial_indent,
|
128
|
+
:subsequent_indent,
|
129
|
+
:break_long_words,
|
130
|
+
:consider_linebreak_whitespace,
|
131
|
+
:code
|
132
|
+
]
|
133
|
+
|
134
|
+
attr_accessor *@@kwargs
|
133
135
|
|
134
136
|
def initialize(options = {})
|
135
|
-
@@kwargs.each do |kw
|
136
|
-
|
137
|
+
@@kwargs.each do |kw|
|
138
|
+
next unless options.has_key?(kw)
|
139
|
+
self.instance_variable_set("@#{kw}", options[kw])
|
137
140
|
end
|
138
141
|
end
|
139
142
|
|
@@ -157,7 +160,9 @@ class TextWrapper
|
|
157
160
|
|
158
161
|
instance_options = {}
|
159
162
|
|
160
|
-
@@kwargs.each do |kw
|
163
|
+
@@kwargs.each do |kw|
|
164
|
+
val = self.instance_variable_get("@#{kw}")
|
165
|
+
next if val.nil?
|
161
166
|
instance_options[kw] = self.instance_variable_get("@#{kw}")
|
162
167
|
end
|
163
168
|
|
metadata
CHANGED