Last active
December 18, 2015 12:49
-
-
Save advorak/5785917 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'prawn' | |
def name | |
'Andy' | |
end | |
# When I don't specify a block variable, @name is neglected and the output | |
# to a pdf file is (approximately): "\nmore text" | |
pdf = Prawn::Document.new do | |
text name | |
text "more text" | |
end | |
# When I specify a block variable (ie. 't'), I can access the @name class variable | |
# for which the pdf file outputs: "Andy\nmore text" | |
pdf = Prawn::Document.new do |t| | |
t.text name | |
t.text "more text" | |
end | |
# How can I access the @name class varaible within the first example? | |
# I recognize this may be a problem of scope..... but I want to try to do this in the first example .. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment