class TableData::Presenter

Attributes

table[R]

Public Class Methods

new(table, options) click to toggle source
# File lib/tabledata/presenter.rb, line 26
def initialize(table, options)
  @table   = table
  @options = options
end
present(table, format, options) click to toggle source
# File lib/tabledata/presenter.rb, line 15
def self.present(table, format, options)
  code, constant, default_options = *@presenters[format]
  raise ArgumentError, "Unknown format #{format.inspect}" unless code
  require code
  klass = constant.inject(Object) { |source, current| source.const_get(current) }

  klass.new(table, options ? default_options.merge(options) : default_options.dup)
end

Public Instance Methods

write(path, options=nil) click to toggle source
# File lib/tabledata/presenter.rb, line 31
def write(path, options=nil)
  File.write(path, string, encoding: 'utf-8')
end