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.151 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.150 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.149 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.148 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.147 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.146 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.145 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.144 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.143 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.142 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.141 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.140 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.139 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.138 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.137 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.136 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.135 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.134 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.133 lib/open_classes/string/table_to_array.rb
tbpgr_utils-0.0.132 lib/open_classes/string/table_to_array.rb