Module: Himekaminize::Filterable

Extended by:
ActiveSupport::Concern
Included in:
Outline, TaskList
Defined in:
lib/himekaminize/filterable.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#call(markdown, context = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/himekaminize/filterable.rb', line 10

def call(markdown, context = {})
  @markdown = markdown
  to_lines
  @result ||= Hash.new
  context = default_context.merge(context)

  @result = filters.inject(context: context, output: lines) do |output, filter|
    filter.call(output)
  end

  to_s
  @result
end

#initialize(default_context = {}) ⇒ Object



6
7
8
# File 'lib/himekaminize/filterable.rb', line 6

def initialize(default_context = {})
  @default_context = default_context
end

#resultObject



24
25
26
# File 'lib/himekaminize/filterable.rb', line 24

def result
  @result
end