Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
#here's the grammar in BNF #dyn ::= <columns> #columns ::= <columns> '+' <column> | <column> #column ::= <numeral> ':' <range> | <numeral> #range ::= <numeral> <range_op> <numeral> | <numeral> #range_op ::= '..' | ',' #numeral ::= the set of integer numbers def translate_composite(row, spec) result = '' columns = spec.split('+') columns.each do |unparsed_column| col_and_range = unparsed_column.split(':') column = col_and_range[0].to_i result << if col_and_range.length > 1 slicer(row[column].strip, col_and_range[1]) else row[column].to_s end end result.blank? ? nil : result end
This paste will be private.
From the Design Piracy series on my blog: