Method: UniProp::PropFile#shaped_lines

Defined in:
lib/uniprop/unicode_elements.rb

#shaped_linesArray

Note:

strip_regexp==/s+/ の場合であっても、各列の最初と最後の空白しか除去されない。「0000; 1111 2222; 3333;」の、1111と2222の間の空白は除去されない。

lines_without_commentをstrip_regexpとsplit_regexpで処理した配列を取得def values

Returns:

  • (Array)


264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
# File 'lib/uniprop/unicode_elements.rb', line 264

def shaped_lines
  return @shaped_lines if @shaped_lines

  @shaped_lines = []

  # String#splitはlimit==0(デフォルト)の場合、配列末尾の空文字列が削除される
  # それを防ぐため、limit==-1としてある。これはlimit<0にする事が目的であり、-1という値に意味は無い
  if strip_regexp == /\s+/
    lines_without_comment.each do |line|
      @shaped_lines << line.split(sep=split_regexp, limit=-1)
                    .map { _1.gsub(/^\s+/, '') }
                    .map { _1.gsub(/\s+$/, '') }
    end
  else
    lines_without_comment.each do |line|
      @shaped_lines << line.split(sep=split_regexp, limit=-1)
                    .map { _1.gsub(strip_regexp, '') }
    end
  end
  @shaped_lines
end