class Tempo::Views::Formatters::Base

Public Class Methods

new(options={}) click to toggle source
# File lib/tempo/views/formatters/base.rb, line 16
def initialize(options={})
  @options = options
end

Public Instance Methods

format_records(records) click to toggle source

Here we check if our class methods include a proc block to handle the particular record type. See View Records for all possible record types. See screen formatter for examples of proc blocks.

# File lib/tempo/views/formatters/base.rb, line 35
def format_records(records)
  records.each do |record|
    report record
  end
end
format_records_container(container) click to toggle source

Records containers handle nested records

# File lib/tempo/views/formatters/base.rb, line 42
def format_records_container(container)
  report container.pre if container.pre
  container.records.each do |record|
    report record
  end
  report container.post if container.post
end
report(record) click to toggle source
# File lib/tempo/views/formatters/base.rb, line 20
def report(record)
  class_block = "#{record.type}_block"

  # We handle containers separately
  if /container/.match class_block
    format_records_container(record)
  else
    send(class_block, record) if respond_to? class_block
  end
end