Sha256: 159df80f970426e47425d00fd5252953f3507887dfaaac6f92ba3252f82bda6d

Contents?: true

Size: 640 Bytes

Versions: 1

Compression:

Stored size: 640 Bytes

Contents

require "active_support/concern"

module Himekaminize
  module Filterable
    extend ::ActiveSupport::Concern

    def initialize(markdown)
      @markdown = markdown
      to_lines
    end

    def to_a
      filters.inject(lines) do |result, filter|
        filter.call(result)
      end
    end

    private

    def filters
      @filters ||= self.class.filter_classes.map(&:new)
    end

    def markdown
      @markdown
    end

    def lines
      @lines
    end

    def to_lines
      @lines = markdown.lines
    end

    module ClassMethods
      def filter_classes
        raise ::NotImplementedError
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
himekaminize-0.0.2 lib/himekaminize/filterable.rb