Sha256: 8a1b964cebc151eea329e020cd1d50e12d62273cf735cc9ca883b5cba0a40236

Contents?: true

Size: 458 Bytes

Versions: 67

Compression:

Stored size: 458 Bytes

Contents

# encoding: utf-8

class String
  # convert table format string to array.
  #
  # === Example
  #
  # sample case.
  #
  #   BEFORE =<<-EOS
  #   |header1|header2 |header3|
  #   |line1_1| line1_2|line1_3|
  #   EOS
  #   BEFORE.table_to_array
  #
  # result
  #
  #   [["header1", "header2", "header3"], ["line1_1", "line1_2", "line1_3"]]
  #
  def table_to_array
    split("\n").map { |v|v.split('|')[1..-1].map(&:strip) }
  end
end

Version data entries

67 entries across 67 versions & 1 rubygems

Version Path
tbpgr_utils-0.0.131 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.130 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.129 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.128 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.127 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.126 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.125 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.124 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.123 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.122 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.121 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.120 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.119 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.118 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.117 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.116 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.115 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.114 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.113 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.112 lib/open_classes/string/table_to_array.rb