Class: Dieses::Application::Sheet
- Inherits:
-
Object
- Object
- Dieses::Application::Sheet
- Extended by:
- DSL, Forwardable
- Defined in:
- lib/dieses/application/sheet.rb
Direct Known Subclasses
Dieses::Application::Sheets::Copperplate, Dieses::Application::Sheets::Cursive, Dieses::Application::Sheets::Graph, Dieses::Application::Sheets::Italics, Dieses::Application::Sheets::Lettering, Dieses::Application::Sheets::Lined, Dieses::Application::Sheets::Print, Dieses::Application::Sheets::Ruled, Dieses::Application::Sheets::Spencerian, Dieses::Application::Sheets::Table, Dieses::Application::Sheets::Thumbnail
Defined Under Namespace
Instance Attribute Summary collapse
-
#paper ⇒ Object
readonly
Returns the value of attribute paper.
-
#variant ⇒ Object
readonly
Returns the value of attribute variant.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(paper, variant: Undefined) ⇒ Sheet
constructor
A new instance of Sheet.
- #produce(**kwargs) ⇒ Object
Methods included from DSL
Constructor Details
#initialize(paper, variant: Undefined) ⇒ Sheet
Returns a new instance of Sheet.
73 74 75 76 77 78 79 80 81 |
# File 'lib/dieses/application/sheet.rb', line 73 def initialize(paper, variant: Undefined) @paper = paper @variant = Undefined.equal?(variant) ? self.class.default_variant : self.class.variant!(variant) @param = parametrize @canvas = Canvas.new(paper) @pen = Pen.new(@canvas) setup if respond_to? :setup end |
Instance Attribute Details
#paper ⇒ Object (readonly)
Returns the value of attribute paper.
71 72 73 |
# File 'lib/dieses/application/sheet.rb', line 71 def paper @paper end |
#variant ⇒ Object (readonly)
Returns the value of attribute variant.
71 72 73 |
# File 'lib/dieses/application/sheet.rb', line 71 def variant @variant end |
Class Method Details
.default_variant ⇒ Object
97 98 99 100 101 |
# File 'lib/dieses/application/sheet.rb', line 97 def default_variant return variant!(default) unless Undefined.equal?(proto.default) variants.values.first end |
.variant!(name) ⇒ Object
103 104 105 106 107 108 |
# File 'lib/dieses/application/sheet.rb', line 103 def variant!(name) raise Error, "No variant defined: #{self.class}" if variants.empty? raise Error, "No such variant for #{self.class}: #{name}" unless variants.key?(name = name.to_sym) variants[name] end |
Instance Method Details
#produce(**kwargs) ⇒ Object
83 84 85 86 |
# File 'lib/dieses/application/sheet.rb', line 83 def produce(**kwargs) call canvas.render(variables: self.class.style.to_h, **kwargs) end |