Module: ExtractTicketNumbers
- Defined in:
- lib/extract_ticket_numbers.rb,
lib/extract_ticket_numbers/version.rb
Constant Summary collapse
- VERSION =
"0.0.5"
Class Method Summary collapse
Class Method Details
.add_to_csv(in_path, out_path = out_path_from(in_path)) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/extract_ticket_numbers.rb', line 6 def self.add_to_csv(in_path, out_path = out_path_from(in_path)) CSV.open(out_path, "wb", col_sep: ';') do |out_row| CSV.foreach(in_path, col_sep: ';', headers: false) do |in_row| tickets = in_row.to_s.scan(/[a-zA-Z]+\-[0-9]+/) in_row.concat tickets out_row << in_row end end end |
.out_path_from(in_path) ⇒ Object
16 17 18 |
# File 'lib/extract_ticket_numbers.rb', line 16 def self.out_path_from(in_path) File.join(File.dirname(in_path), File.basename(in_path, '.csv') + '-with_ticket_numbers.csv') end |