Module: StupidFormatter

Defined in:
lib/stupid_formatter.rb

Defined Under Namespace

Modules: CoderayHelper Classes: AbstractFormatter, Erb, RDiscount

Class Method Summary collapse

Class Method Details

.chainObject

Returns the current processing chain. Defaults to [StupidFormatter::Erb, StupidFormatter::RDiscount]



20
21
22
# File 'lib/stupid_formatter.rb', line 20

def chain
  @chain ||= [StupidFormatter::Erb, StupidFormatter::RDiscount]
end

.chain=(chain) ⇒ Object

Make the formatter chain configurable. Pass in an Array of Formatters in the order you want them processed in.



28
29
30
# File 'lib/stupid_formatter.rb', line 28

def chain=(chain)
  @chain = chain
end

.result(input) ⇒ Object

Will put the input string through all formatters in the chain



35
36
37
38
39
40
41
# File 'lib/stupid_formatter.rb', line 35

def result(input)
  output = input.clone
  chain.each do |formatter|
    output = formatter.new(output).result
  end
  output
end