Class: Portable::Rendering::Sheet
- Inherits:
-
Object
- Object
- Portable::Rendering::Sheet
- Defined in:
- lib/portable/rendering/sheet.rb
Overview
Understands the connection between a document’s sheets and the internal row renderer necessary to render each sheet’s data table.
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
:nodoc: all.
-
#resolver ⇒ Object
readonly
:nodoc: all.
Instance Method Summary collapse
-
#initialize(document, resolver: Objectable.resolver) ⇒ Sheet
constructor
A new instance of Sheet.
- #row_renderer(sheet_name, keys) ⇒ Object
Constructor Details
#initialize(document, resolver: Objectable.resolver) ⇒ Sheet
Returns a new instance of Sheet.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/portable/rendering/sheet.rb', line 19 def initialize(document, resolver: Objectable.resolver) @document = Document.make(document, nullable: false) @resolver = resolver @row_renderers = @document.sheets.each_with_object({}) do |sheet, memo| memo[sheet.name] = Row.new(sheet.columns, resolver: resolver) end freeze end |
Instance Attribute Details
#document ⇒ Object (readonly)
:nodoc: all
17 18 19 |
# File 'lib/portable/rendering/sheet.rb', line 17 def document @document end |
#resolver ⇒ Object (readonly)
:nodoc: all
17 18 19 |
# File 'lib/portable/rendering/sheet.rb', line 17 def resolver @resolver end |
Instance Method Details
#row_renderer(sheet_name, keys) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/portable/rendering/sheet.rb', line 30 def row_renderer(sheet_name, keys) sheet = document.sheet(sheet_name) row_renderer = row_renderers.fetch(sheet_name.to_s) return row_renderer unless sheet.auto? dynamic_row_renderer(keys).merge(row_renderer) end |