Sha256: 0174cba6f549ab73f9d38252e6f9b658a59edd7c1e89a48f2ad04a90d9d0cbe5
Contents?: true
Size: 966 Bytes
Versions: 16
Compression:
Stored size: 966 Bytes
Contents
require "chop/diff" module Chop class DefinitionList < Diff self.default_selector = "dl" self.rows_finder = ->(root) do root.all("dt,dd").slice_before do |node| node.tag_name == "dt" end end self.cells_finder = ->(row) { row } def column index, &block transformation do |rows| rows.map.with_index do |row, row_index| row[index] = block.call(row[index]) if row.length > index row end end end def field key transformation do |rows| rows.map do |row| if row.first.text.parameterize.underscore == key.to_s row[1] = yield(row[1]) end row end end end def image *cols block = ->(cell){ cell_to_image_filename(cell) } cols.each do |col| method = col.is_a?(Symbol) ? :field : :column send method, col, &block end end end Dl = DefinitionList end
Version data entries
16 entries across 16 versions & 1 rubygems