class Erlash::TemplateFormatter
ex:
class HelloFormatter < TemplateFormatter def format object.greetings end end
Attributes
formatter[R]
object[R]
opts[R]
output[R]
Public Class Methods
call(*args)
click to toggle source
# File lib/erlash/formatters/template_formatter.rb, line 10 def self.call(*args) new(*args).safe_call; nil end
format(*args)
click to toggle source
# File lib/erlash/formatters/template_formatter.rb, line 14 def self.format(*args) new(*args).format end
new(formatter, object, opts = {})
click to toggle source
# File lib/erlash/formatters/template_formatter.rb, line 19 def initialize(formatter, object, opts = {}) @object = object @opts = opts @formatter = formatter @output = formatter.output @executed = false end
Public Instance Methods
format()
click to toggle source
# File lib/erlash/formatters/template_formatter.rb, line 27 def format raise NotImplementedMethod end
format_elem(elem)
click to toggle source
# File lib/erlash/formatters/template_formatter.rb, line 37 def format_elem(elem) Formatter.format(formatter, elem) end
safe_call()
click to toggle source
# File lib/erlash/formatters/template_formatter.rb, line 31 def safe_call return if @executed call @excuted = true end
Protected Instance Methods
call()
click to toggle source
# File lib/erlash/formatters/template_formatter.rb, line 43 def call @call ||= Fusu::Array.wrap(format).each do |e| output.puts e end end