Skip to content

Instantly share code, notes, and snippets.

@advorak
Last active December 18, 2015 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save advorak/5785917 to your computer and use it in GitHub Desktop.
Save advorak/5785917 to your computer and use it in GitHub Desktop.
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