meteor 0.9.30 → 0.9.32

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.
@@ -10,50 +10,50 @@ module Meteor
10
10
  class ParserImpl < Meteor::Core::Kernel
11
11
  # KAIGYO_CODE = "\r?\n|\r"
12
12
  # KAIGYO_CODE = "\r\n|\n|\r"
13
- KAIGYO_CODE = ["\r\n", "\n", "\r"]
14
- BR = "<br>"
13
+ KAIGYO_CODE = ["\r\n", "\n", "\r"].freeze
14
+ BR = '<br>'
15
15
  BR_RE = BR
16
16
 
17
17
  # @@match_tag = "br|hr|img|input|meta|base"
18
- #[Array] void elemets (空要素)
19
- @@match_tag = ["br", "hr", "img", "input", "meta", "base"]
18
+ # [Array] void elemets (空要素)
19
+ @@match_tag = %w[br hr img input meta base]
20
20
  # @@match_tag_2 = "textarea|option|pre"
21
- #[Array] elements where line breaks do not need to be converted to <br> (改行を<br>に変換する必要のない要素)
22
- @@match_tag_2 = ["textarea", "option", "pre"]
21
+ # [Array] elements where line breaks do not need to be converted to <br> (改行を<br>に変換する必要のない要素)
22
+ @@match_tag_2 = %w[textarea option pre]
23
23
 
24
- #[Array] non-nestable elements (入れ子にできない要素)
25
- @@match_tag_nne = ["texarea", "select", "option", "form", "fieldset"]
24
+ # [Array] non-nestable elements (入れ子にできない要素)
25
+ @@match_tag_nne = %w[texarea select option form fieldset]
26
26
 
27
- #[Array] boolean attributes (論理値で指定する属性)
28
- @@attr_bool = ["disabled", "readonly", "checked", "selected", "multiple"]
27
+ # [Array] boolean attributes (論理値で指定する属性)
28
+ @@attr_bool = %w[disabled readonly checked selected multiple]
29
29
 
30
30
  # DISABLE_ELEMENT = "input|textarea|select|optgroup"
31
- #[Array] elements with the disabled attribute (disabled属性のある要素)
32
- DISABLE_ELEMENT = ["input", "textarea", "select", "optgroup"]
31
+ # [Array] elements with the disabled attribute (disabled属性のある要素)
32
+ DISABLE_ELEMENT = %w[input textarea select optgroup].freeze
33
33
  # READONLY_TYPE = "text|password"
34
- #[Array] the type of an input element with a readonly attribute (readonly属性のあるinput要素のタイプ)
35
- READONLY_TYPE = ["text", "password"]
34
+ # [Array] the type of an input element with a readonly attribute (readonly属性のあるinput要素のタイプ)
35
+ READONLY_TYPE = %w[text password].freeze
36
36
 
37
- SELECTED_M = "\\sselected\\s|\\sselected$|\\sSELECTED\\s|\\sSELECTED$"
37
+ SELECTED_M = '\\sselected\\s|\\sselected$|\\sSELECTED\\s|\\sSELECTED$'
38
38
  # SELECTED_M = [' selected ',' selected',' SELECTED ',' SELECTED']
39
- SELECTED_R = "selected\\s|selected$|SELECTED\\s|SELECTED$"
40
- CHECKED_M = "\\schecked\\s|\\schecked$|\\sCHECKED\\s|\\sCHECKED$"
39
+ SELECTED_R = 'selected\\s|selected$|SELECTED\\s|SELECTED$'
40
+ CHECKED_M = '\\schecked\\s|\\schecked$|\\sCHECKED\\s|\\sCHECKED$'
41
41
  # CHECKED_M = [' checked ',' checked',' CHECKED ',' CHECKED']
42
- CHECKED_R = "checked\\s|checked$|CHECKED\\s|CHECKED$"
43
- DISABLED_M = "\\sdisabled\\s|\\sdisabled$|\\sDISABLED\\s|\\sDISABLED$"
42
+ CHECKED_R = 'checked\\s|checked$|CHECKED\\s|CHECKED$'
43
+ DISABLED_M = '\\sdisabled\\s|\\sdisabled$|\\sDISABLED\\s|\\sDISABLED$'
44
44
  # DISABLED_M = [' disabled ',' disiabled',' DISABLED ',' DISABLED']
45
- DISABLED_R = "disabled\\s|disabled$|DISABLED\\s|DISABLED$"
46
- READONLY_M = "\\sreadonly\\s|\\sreadonly$|\\sREADONLY\\s|\\sREADONLY$"
45
+ DISABLED_R = 'disabled\\s|disabled$|DISABLED\\s|DISABLED$'
46
+ READONLY_M = '\\sreadonly\\s|\\sreadonly$|\\sREADONLY\\s|\\sREADONLY$'
47
47
  # READONLY_M = [' readonly ',' readonly',' READONLY ',' READONLY']
48
- READONLY_R = "readonly\\s|readonly$|READONLY\\s|READONLY$"
49
- MULTIPLE_M = "\\smultiple\\s|\\smultiple$|\\sMULTIPLE\\s|\\sMULTIPLE$"
48
+ READONLY_R = 'readonly\\s|readonly$|READONLY\\s|READONLY$'
49
+ MULTIPLE_M = '\\smultiple\\s|\\smultiple$|\\sMULTIPLE\\s|\\sMULTIPLE$'
50
50
  # MULTIPLE_M = [' multiple ',' multiple',' MULTIPLE ',' MULTIPLE']
51
- MULTIPLE_R = "multiple\\s|multiple$|MULTIPLE\\s|MULTIPLE$"
51
+ MULTIPLE_R = 'multiple\\s|multiple$|MULTIPLE\\s|MULTIPLE$'
52
52
 
53
53
  # @@pattern_true = Regexp.new("true")
54
54
  # @@pattern_false = Regexp.new("false")
55
55
 
56
- GET_ATTRS_MAP2 = "\\s(disabled|readonly|checked|selected|multiple)"
56
+ GET_ATTRS_MAP2 = '\\s(disabled|readonly|checked|selected|multiple)'
57
57
 
58
58
  @@pattern_selected_m = Regexp.new(SELECTED_M)
59
59
  @@pattern_selected_r = Regexp.new(SELECTED_R)
@@ -82,9 +82,9 @@ module Meteor
82
82
  @doc_type = Parser::HTML4
83
83
  case args.length
84
84
  when ZERO
85
- # initialize_0
85
+ # initialize_zero
86
86
  when ONE
87
- initialize_1(args[0])
87
+ initialize_one(args[0])
88
88
  else
89
89
  raise ArgumentError
90
90
  end
@@ -93,16 +93,16 @@ module Meteor
93
93
  #
94
94
  # initializer (イニシャライザ)
95
95
  #
96
- # def initialize_0
96
+ # def initialize_zero
97
97
  # end
98
98
  #
99
- # private :initialize_0
99
+ # private :initialize_zero
100
100
 
101
101
  #
102
102
  # initializer (イニシャライザ)
103
103
  # @param [Meteor::Parser] ps paser (パーサ)
104
104
  #
105
- def initialize_1(ps)
105
+ def initialize_one(ps)
106
106
  @root.document = String.new(ps.document)
107
107
  self.document_hook = String.new(ps.document_hook)
108
108
  @root.content_type = String.new(ps.root_element.content_type)
@@ -110,7 +110,7 @@ module Meteor
110
110
  @root.newline = ps.root_element.newline
111
111
  end
112
112
 
113
- private :initialize_1
113
+ private :initialize_one
114
114
 
115
115
  #
116
116
  # parse document (ドキュメントを解析する)
@@ -119,6 +119,8 @@ module Meteor
119
119
  analyze_ml
120
120
  end
121
121
 
122
+ protected :parse
123
+
122
124
  #
123
125
  # analyze document (ドキュメントをパースする)
124
126
  #
@@ -145,21 +147,19 @@ module Meteor
145
147
  def analyze_content_type
146
148
  @error_check = false
147
149
 
148
- element_3("meta", "http-equiv", "Content-Type")
150
+ element_three('meta', 'http-equiv', 'Content-Type')
149
151
 
150
- if !@elm_
151
- element_3("meta", "http-equiv", "Content-Type")
152
- end
152
+ element_three('meta', 'http-equiv', 'Content-Type') unless @elm_
153
153
 
154
154
  @error_check = true
155
155
 
156
156
  if @elm_
157
- content = @elm_.attr("content")
158
- content_arr = content&.split(";")
159
- @root.content_type = content_arr&.at(0) || ""
160
- @root.charset = content_arr&.at(1)&.split("=")&.at(1) || ""
157
+ content = @elm_.attr('content')
158
+ content_arr = content&.split(';')
159
+ @root.content_type = content_arr&.at(0) || ''
160
+ @root.charset = content_arr&.at(1)&.split('=')&.at(1) || ''
161
161
  else
162
- @root.content_type = ""
162
+ @root.content_type = ''
163
163
  end
164
164
  end
165
165
 
@@ -169,7 +169,7 @@ module Meteor
169
169
  # analuze document , set newline (ドキュメントをパースし、改行コードをセットする)
170
170
  #
171
171
  def analyze_newline
172
- for a in KAIGYO_CODE
172
+ KAIGYO_CODE.each do |a|
173
173
  if @root.document.include?(a)
174
174
  @root.newline = a
175
175
  # puts "kaigyo:" << @root.newline
@@ -184,22 +184,20 @@ module Meteor
184
184
  # @param [String] name tag name (タグ名)
185
185
  # @return [Meteor::Element] element (要素)
186
186
  #
187
- def element_1(name)
187
+ def element_one(name)
188
188
  quote_name(name)
189
189
 
190
190
  # case of void element (空要素の場合(<->内容あり要素の場合))
191
191
  if is_match(@@match_tag, name)
192
192
  # void element search pattern (空要素検索用パターン)
193
- @pattern_cc = String.new("") << "<" << @_name << "(|\\s[^<>]*)>"
193
+ @pattern_cc = String.new('') << '<' << @_name << '(|\\s[^<>]*)>'
194
194
  # @pattern_cc = "<#{@_name}(|\\s[^<>]*)>"
195
195
  @pattern = Meteor::Core::Util::PatternCache.get(@pattern_cc)
196
196
  @res = @pattern.match(@root.document)
197
197
  if @res
198
- element_void_1(name)
198
+ element_void_one(name)
199
199
  else
200
- if @error_check
201
- puts(Meteor::Exception::NoSuchElementException.new(name).message)
202
- end
200
+ puts(Meteor::Exception::NoSuchElementException.new(name).message) if @error_check
203
201
 
204
202
  @elm_ = nil
205
203
  end
@@ -215,11 +213,9 @@ module Meteor
215
213
  # case of normal element (内容あり要素の場合)
216
214
  if @res
217
215
  @on_search = true
218
- element_normal_1(name)
216
+ element_normal_one(name)
219
217
  else
220
- if @error_check
221
- puts(Meteor::Exception::NoSuchElementException.new(name).message)
222
- end
218
+ puts(Meteor::Exception::NoSuchElementException.new(name).message) if @error_check
223
219
 
224
220
  @elm_ = nil
225
221
  end
@@ -228,9 +224,9 @@ module Meteor
228
224
  @elm_
229
225
  end
230
226
 
231
- private :element_1
227
+ private :element_one
232
228
 
233
- def element_void_1(name)
229
+ def element_void_one(name)
234
230
  @elm_ = Meteor::Element.new(name)
235
231
  # attribute (属性)
236
232
  @elm_.attributes = @res[1]
@@ -242,7 +238,7 @@ module Meteor
242
238
  @elm_.parser = self
243
239
  end
244
240
 
245
- private :element_void_1
241
+ private :element_void_one
246
242
 
247
243
  #
248
244
  # get element using tag name and attribute(name="value") (要素のタグ名、属性(属性名="属性値")で検索し、要素を取得する)
@@ -252,9 +248,9 @@ module Meteor
252
248
  # @param [true,false] quote quote flag (クオート・フラグ)
253
249
  # @return [Meteor::Element] element (要素)
254
250
  #
255
- def element_3(name, attr_name, attr_value, quote = true)
251
+ def element_three(name, attr_name, attr_value, quote = true)
256
252
  if quote
257
- quote_element_3(name, attr_name, attr_value)
253
+ quote_element_three(name, attr_name, attr_value)
258
254
  else
259
255
  quote_name(name)
260
256
  end
@@ -270,11 +266,9 @@ module Meteor
270
266
  # void element search (空要素検索)
271
267
  @res = @pattern.match(@root.document)
272
268
  if @res
273
- element_void_3(name)
269
+ element_void_three(name)
274
270
  else
275
- if @error_check
276
- puts(Meteor::Exception::NoSuchElementException.new(name, attr_name, attr_value).message)
277
- end
271
+ puts(Meteor::Exception::NoSuchElementException.new(name, attr_name, attr_value).message) if @error_check
278
272
 
279
273
  @elm_ = nil
280
274
  end
@@ -289,16 +283,12 @@ module Meteor
289
283
  # search of normal element (内容あり要素検索)
290
284
  @res = @pattern.match(@root.document)
291
285
 
292
- if !@res && !is_match(@@match_tag_nne, name)
293
- @res = element_normal_3_2
294
- end
286
+ @res = element_normal_three_two if !@res && !is_match(@@match_tag_nne, name)
295
287
 
296
288
  if @res
297
- element_normal_3_1(name)
289
+ element_normal_three_one(name)
298
290
  else
299
- if @error_check
300
- puts(Meteor::Exception::NoSuchElementException.new(name, attr_name, attr_value).message)
301
- end
291
+ puts(Meteor::Exception::NoSuchElementException.new(name, attr_name, attr_value).message) if @error_check
302
292
 
303
293
  @elm_ = nil
304
294
  end
@@ -307,13 +297,13 @@ module Meteor
307
297
  @elm_
308
298
  end
309
299
 
310
- private :element_3
300
+ private :element_three
311
301
 
312
- def element_void_3(name)
313
- element_void_3_1(name, "\"[^<>]*)>")
302
+ def element_void_three(name)
303
+ element_void_three_one(name, '"[^<>]*)>')
314
304
  end
315
305
 
316
- private :element_void_3
306
+ private :element_void_three
317
307
 
318
308
  #
319
309
  # get element using attribute(name="value") (属性(属性名="属性値")で検索し、要素を取得する)
@@ -321,7 +311,7 @@ module Meteor
321
311
  # @param [String] attr_value attribute value (属性値)
322
312
  # @return [Meteor::Element] element (要素)
323
313
  #
324
- def element_2(attr_name, attr_value)
314
+ def element_two(attr_name, attr_value)
325
315
  quote_attribute(attr_name, attr_value)
326
316
 
327
317
  # @pattern_cc = String.new('') << '<([^<>"]*)\\s[^<>]*' << @_attr_name << '="' << @_attr_value
@@ -332,11 +322,9 @@ module Meteor
332
322
  @res = @pattern.match(@root.document)
333
323
 
334
324
  if @res
335
- element_3(@res[1], attr_name, attr_value)
325
+ element_three(@res[1], attr_name, attr_value)
336
326
  else
337
- if @error_check
338
- puts(Meteor::Exception::NoSuchElementException.new(attr_name, attr_value).message)
339
- end
327
+ puts(Meteor::Exception::NoSuchElementException.new(attr_name, attr_value).message) if @error_check
340
328
 
341
329
  @elm_ = nil
342
330
  end
@@ -344,7 +332,7 @@ module Meteor
344
332
  @elm_
345
333
  end
346
334
 
347
- private :element_2
335
+ private :element_two
348
336
 
349
337
  #
350
338
  # get element using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で検索し、要素を取得する)
@@ -355,8 +343,8 @@ module Meteor
355
343
  # @param [String] attr_value2 attribute value2 (属性値2)
356
344
  # @return [Meteor::Element] element (要素)
357
345
  #
358
- def element_5(name, attr_name1, attr_value1, attr_name2, attr_value2)
359
- quote_element_5(name, attr_name1, attr_value1, attr_name2, attr_value2)
346
+ def element_five(name, attr_name1, attr_value1, attr_name2, attr_value2)
347
+ quote_element_five(name, attr_name1, attr_value1, attr_name2, attr_value2)
360
348
 
361
349
  # case of void element (空要素の場合(<->内容あり要素の場合))
362
350
  if is_match(@@match_tag, name)
@@ -373,7 +361,7 @@ module Meteor
373
361
  @res = @pattern.match(@root.document)
374
362
 
375
363
  if @res
376
- element_void_5(name)
364
+ element_void_five(name)
377
365
  else
378
366
  if @error_check
379
367
  puts(
@@ -399,12 +387,10 @@ module Meteor
399
387
  # search of normal element (内容あり要素検索)
400
388
  @res = @pattern.match(@root.document)
401
389
 
402
- if !@res && !is_match(@@match_tag_nne, tag)
403
- @res = element_normal_5_2
404
- end
390
+ @res = element_normal_five_two if !@res && !is_match(@@match_tag_nne, tag)
405
391
 
406
392
  if @res
407
- element_normal_5_1(name)
393
+ element_normal_five_one(name)
408
394
  else
409
395
  if @error_check
410
396
  puts(
@@ -421,13 +407,13 @@ module Meteor
421
407
  @elm_
422
408
  end
423
409
 
424
- private :element_5
410
+ private :element_five
425
411
 
426
- def element_void_5(name)
427
- element_void_5_1(name, "\")[^<>]*)>")
412
+ def element_void_five(name)
413
+ element_void_five_one(name, '")[^<>]*)>')
428
414
  end
429
415
 
430
- private :element_void_5
416
+ private :element_void_five
431
417
 
432
418
  #
433
419
  # get element using attribute1,2(name="value") (属性1・属性2(属性名="属性値")で検索し、要素を取得する)
@@ -438,8 +424,8 @@ module Meteor
438
424
  # @param [String] attr_value2 attribute value2 (属性値2)
439
425
  # @return [Meteor::Element] element (要素)
440
426
  #
441
- def element_4(attr_name1, attr_value1, attr_name2, attr_value2)
442
- quote_element_4(attr_name1, attr_value1, attr_name2, attr_value2)
427
+ def element_four(attr_name1, attr_value1, attr_name2, attr_value2)
428
+ quote_element_four(attr_name1, attr_value1, attr_name2, attr_value2)
443
429
 
444
430
  # @pattern_cc = String.new('') << '<([^<>"]*)\\s([^<>]*(' << @_attr_name1 << '="' << @_attr_value1
445
431
  # @pattern_cc << '"[^<>]*' << @_attr_name2 << '="' << @_attr_value2
@@ -453,7 +439,7 @@ module Meteor
453
439
  @res = @pattern.match(@root.document)
454
440
 
455
441
  if @res
456
- element_5(@res[1], attr_name1, attr_value1, attr_name2, attr_value2)
442
+ element_five(@res[1], attr_name1, attr_value1, attr_name2, attr_value2)
457
443
  else
458
444
  if @error_check
459
445
  puts(
@@ -467,20 +453,21 @@ module Meteor
467
453
  @elm_
468
454
  end
469
455
 
470
- private :element_4
456
+ private :element_four
471
457
 
472
458
  def edit_attrs_(elm, attr_name, attr_value)
473
- if is_match("selected", attr_name) && is_match("option", elm.name)
474
- edit_attrs_5(elm, attr_name, attr_value, @@pattern_selected_m, @@pattern_selected_r)
475
- elsif is_match("multiple", attr_name) && is_match("select", elm.name)
476
- edit_attrs_5(elm, attr_name, attr_value, @@pattern_multiple_m, @@pattern_multiple_r)
477
- elsif is_match("disabled", attr_name) && is_match(DISABLE_ELEMENT, elm.name)
478
- edit_attrs_5(elm, attr_name, attr_value, @@pattern_disabled_m, @@pattern_disabled_r)
479
- elsif is_match("checked", attr_name) && is_match("input", elm.name) && is_match("radio", get_type(elm))
480
- edit_attrs_5(elm, attr_name, attr_value, @@pattern_checked_m, @@pattern_checked_r)
481
- elsif is_match("readonly", attr_name) &&
482
- (is_match("textarea", elm.name) || (is_match("input", elm.name) && is_match(READONLY_TYPE, get_type(elm))))
483
- edit_attrs_5(elm, attr_name, attr_value, @@pattern_readonly_m, @@pattern_readonly_r)
459
+ if is_match('selected', attr_name) && is_match('option', elm.name)
460
+ edit_attrs_five(elm, attr_name, attr_value, @@pattern_selected_m, @@pattern_selected_r)
461
+ elsif is_match('multiple', attr_name) && is_match('select', elm.name)
462
+ edit_attrs_five(elm, attr_name, attr_value, @@pattern_multiple_m, @@pattern_multiple_r)
463
+ elsif is_match('disabled', attr_name) && is_match(DISABLE_ELEMENT, elm.name)
464
+ edit_attrs_five(elm, attr_name, attr_value, @@pattern_disabled_m, @@pattern_disabled_r)
465
+ elsif is_match('checked', attr_name) && is_match('input', elm.name) && is_match('radio', get_type(elm))
466
+ edit_attrs_five(elm, attr_name, attr_value, @@pattern_checked_m, @@pattern_checked_r)
467
+ elsif is_match('readonly', attr_name) &&
468
+ (is_match('textarea',
469
+ elm.name) || (is_match('input', elm.name) && is_match(READONLY_TYPE, get_type(elm))))
470
+ edit_attrs_five(elm, attr_name, attr_value, @@pattern_readonly_m, @@pattern_readonly_r)
484
471
  else
485
472
  super(elm, attr_name, attr_value)
486
473
  end
@@ -488,44 +475,45 @@ module Meteor
488
475
 
489
476
  private :edit_attrs_
490
477
 
491
- def edit_attrs_5(elm, attr_name, attr_value, match_p, replace)
492
- if true.equal?(attr_value) || is_match("true", attr_value)
478
+ def edit_attrs_five(elm, attr_name, attr_value, match_p, replace)
479
+ if true.equal?(attr_value) || is_match('true', attr_value)
493
480
  @res = match_p.match(elm.attributes)
494
481
 
495
- if !@res
496
- if elm.attributes != "" && elm.attributes.strip != ""
497
- elm.attributes = String.new("") << " " << elm.attributes.strip
498
- else
499
- elm.attributes = String.new("")
500
- end
482
+ unless @res
483
+ elm.attributes = if elm.attributes != '' && elm.attributes.strip != ''
484
+ String.new('') << ' ' << elm.attributes.strip
485
+ else
486
+ String.new('')
487
+ end
501
488
 
502
- elm.attributes << " " << attr_name
489
+ elm.attributes << ' ' << attr_name
503
490
  # else
504
491
  end
505
- elsif false.equal?(attr_value) || is_match("false", attr_value)
506
- elm.attributes.sub!(replace, "")
492
+ elsif false.equal?(attr_value) || is_match('false', attr_value)
493
+ elm.attributes.sub!(replace, '')
507
494
  end
508
495
  end
509
496
 
510
- private :edit_attrs_5
497
+ private :edit_attrs_five
511
498
 
512
- def edit_document_1(elm)
513
- edit_document_2(elm, ">")
499
+ def edit_document_one(elm)
500
+ edit_document_two(elm, '>')
514
501
  end
515
502
 
516
- private :edit_document_1
503
+ private :edit_document_one
517
504
 
518
505
  def get_attr_value_(elm, attr_name)
519
- if is_match("selected", attr_name) && is_match("option", elm.name)
506
+ if is_match('selected', attr_name) && is_match('option', elm.name)
520
507
  get_attr_value_r(elm, @@pattern_selected_m)
521
- elsif is_match("multiple", attr_name) && is_match("select", elm.name)
508
+ elsif is_match('multiple', attr_name) && is_match('select', elm.name)
522
509
  get_attr_value_r(elm, @@pattern_multiple_m)
523
- elsif is_match("disabled", attr_name) && is_match(DISABLE_ELEMENT, elm.name)
510
+ elsif is_match('disabled', attr_name) && is_match(DISABLE_ELEMENT, elm.name)
524
511
  get_attr_value_r(elm, @@pattern_disabled_m)
525
- elsif is_match("checked", attr_name) && is_match("input", elm.name) && is_match("radio", get_type(elm))
512
+ elsif is_match('checked', attr_name) && is_match('input', elm.name) && is_match('radio', get_type(elm))
526
513
  get_attr_value_r(elm, @@pattern_checked_m)
527
- elsif is_match("readonly", attr_name) &&
528
- (is_match("textarea", elm.name) || (is_match("input", elm.name) && is_match(READONLY_TYPE, get_type(elm))))
514
+ elsif is_match('readonly', attr_name) &&
515
+ (is_match('textarea',
516
+ elm.name) || (is_match('input', elm.name) && is_match(READONLY_TYPE, get_type(elm))))
529
517
  get_attr_value_r(elm, @@pattern_readonly_m)
530
518
  else
531
519
  super(elm, attr_name)
@@ -535,11 +523,9 @@ module Meteor
535
523
  private :get_attr_value_
536
524
 
537
525
  def get_type(elm)
538
- if !elm.type_value
539
- elm.type_value = get_attr_value_(elm, "type")
540
- if !elm.type_value
541
- elm.type_value = get_attr_value_(elm, "TYPE")
542
- end
526
+ unless elm.type_value
527
+ elm.type_value = get_attr_value_(elm, 'type')
528
+ elm.type_value = get_attr_value_(elm, 'TYPE') unless elm.type_value
543
529
  end
544
530
 
545
531
  elm.type_value
@@ -551,9 +537,9 @@ module Meteor
551
537
  @res = match_p.match(elm.attributes)
552
538
 
553
539
  if @res
554
- "true"
540
+ 'true'
555
541
  else
556
- "false"
542
+ 'false'
557
543
  end
558
544
  end
559
545
 
@@ -565,14 +551,14 @@ module Meteor
565
551
  # @return [Hash] attribute map (属性マップ)
566
552
  #
567
553
  def get_attrs(elm)
568
- attrs = Hash.new
554
+ attrs = {}
569
555
 
570
556
  elm.attributes.scan(@@pattern_get_attrs_map) do |a, b|
571
557
  attrs.store(a, unescape(b))
572
558
  end
573
559
 
574
560
  elm.attributes.scan(@@pattern_get_attrs_map2) do |a|
575
- attrs.store(a[0], "true")
561
+ attrs.store(a[0], 'true')
576
562
  end
577
563
 
578
564
  attrs
@@ -593,7 +579,7 @@ module Meteor
593
579
  end
594
580
 
595
581
  elm.attributes.scan(@@pattern_get_attrs_map2) do |a|
596
- attrs.store(a[0], "true")
582
+ attrs.store(a[0], 'true')
597
583
  end
598
584
 
599
585
  attrs.recordable = true
@@ -604,16 +590,15 @@ module Meteor
604
590
  private :get_attr_map
605
591
 
606
592
  def remove_attrs_(elm, attr_name)
607
- if !is_match(@@attr_bool, attr_name)
608
- # attribute search pattern (属性検索用パターン)
609
- @pattern = Meteor::Core::Util::PatternCache.get(String.new("") << attr_name << "=\"[^\"]*\"\\s?")
610
- # @pattern = Meteor::Core::Util::PatternCache.get("#{attr_name}=\"[^\"]*\"\\s?")
611
- elm.attributes.sub!(@pattern, "")
612
- else
613
- # attribute search pattern (属性検索用パターン)
614
- @pattern = Meteor::Core::Util::PatternCache.get(attr_name)
615
- elm.attributes.sub!(@pattern, "")
616
- end
593
+ @pattern = if !is_match(@@attr_bool, attr_name)
594
+ # attribute search pattern (属性検索用パターン)
595
+ Meteor::Core::Util::PatternCache.get(String.new('') << attr_name << '="[^"]*"\\s?')
596
+ # @pattern = Meteor::Core::Util::PatternCache.get("#{attr_name}=\"[^\"]*\"\\s?")
597
+ else
598
+ # attribute search pattern (属性検索用パターン)
599
+ Meteor::Core::Util::PatternCache.get(attr_name)
600
+ end
601
+ elm.attributes.sub!(@pattern, '')
617
602
  end
618
603
 
619
604
  private :remove_attrs_