Class: TableData::Presenter
- Inherits:
-
Object
- Object
- TableData::Presenter
- Defined in:
- lib/tabledata/presenter.rb
Direct Known Subclasses
TableData::Presenters::CSV, TableData::Presenters::Excel, TableData::Presenters::HTML, TableData::Presenters::PDF
Instance Attribute Summary collapse
-
#table ⇒ Object
readonly
Returns the value of attribute table.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(table, options) ⇒ Presenter
constructor
A new instance of Presenter.
- #write(path, options = nil) ⇒ Object
Constructor Details
#initialize(table, options) ⇒ Presenter
Returns a new instance of Presenter.
26 27 28 29 |
# File 'lib/tabledata/presenter.rb', line 26 def initialize(table, ) @table = table @options = end |
Instance Attribute Details
#table ⇒ Object (readonly)
Returns the value of attribute table.
24 25 26 |
# File 'lib/tabledata/presenter.rb', line 24 def table @table end |
Class Method Details
.present(table, format, options) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/tabledata/presenter.rb', line 15 def self.present(table, format, ) code, constant, = *@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, ? .merge() : .dup) end |
Instance Method Details
#write(path, options = nil) ⇒ Object
31 32 33 |
# File 'lib/tabledata/presenter.rb', line 31 def write(path, =nil) File.write(path, string, encoding: 'utf-8') end |