Class: Portable::Document

Inherits:
Object
  • Object
show all
Includes:
Util::Pivotable, Util::Uniqueness
Defined in:
lib/portable/document.rb

Overview

Top-level object model for a renderable document.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util::Uniqueness

#assert_no_duplicate_names

Methods included from Util::Pivotable

#pivot_by_name

Constructor Details

#initialize(sheets: [], options: {}) ⇒ Document

Returns a new instance of Document.



22
23
24
25
26
27
# File 'lib/portable/document.rb', line 22

def initialize(sheets: [], options: {})
  @sheets_by_name = make_unique_sheets_by_name(sheets)
  @options        = Modeling::Options.make(options, nullable: false)

  freeze
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



20
21
22
# File 'lib/portable/document.rb', line 20

def options
  @options
end

Instance Method Details

#sheet(name) ⇒ Object



29
30
31
# File 'lib/portable/document.rb', line 29

def sheet(name)
  sheets_by_name.fetch(name.to_s)
end

#sheetsObject



33
34
35
# File 'lib/portable/document.rb', line 33

def sheets
  sheets_by_name.values
end