Sha256: fb65d5cf0b54310e2b65c794ca79a2013cc006f61605f3925d8c209bc9007455
Contents?: true
Size: 1.09 KB
Versions: 4
Compression:
Stored size: 1.09 KB
Contents
# encoding: UTF-8 # # To create a custom class that extends Prawn's functionality, # use the <code>Prawn::View</code> mixin. This approach is safer than creating # subclasses of <code>Prawn::Document</code> while being just as convenient. # # By using this mixin, your state will be kept completely separate # from <code>Prawn::Document</code>'s state, and you will avoid accidental method # collisions within <code>Prawn::Document</code>. # # To build custom classes that make use of other custom classes, # you can define a method named <code>document()</code> that returns # any object that acts similar to a <code>Prawn::Document</code> # object. <code>Prawn::View</code> will then direct all delegated # calls to that object instead. require_relative "../example_helper" class Greeter include Prawn::View def initialize(name) @name = name end def say_hello text "Hello, #{@name}!" end def say_goodbye font("Courier") do text "Goodbye, #{@name}!" end end end greeter = Greeter.new("Gregory") greeter.say_hello greeter.say_goodbye greeter.save_as("greetings.pdf")
Version data entries
4 entries across 4 versions & 2 rubygems
Version | Path |
---|---|
prawn-git-2.0.1 | manual/basic_concepts/view.rb |
prawn-2.0.1 | manual/basic_concepts/view.rb |
prawn-2.0.0 | manual/basic_concepts/view.rb |
prawn-1.3.0 | manual/basic_concepts/view.rb |