Class: RubyPost::Picture
Overview
wrapper for the metapost picture pictures are collection of drawables
Direct Known Subclasses
Constant Summary collapse
- @@default_name =
store a unique picture name incase it was not specified.
0
Instance Attribute Summary collapse
-
#name ⇒ Object
writeonly
Sets the attribute name.
Instance Method Summary collapse
- #add_drawable(d) ⇒ Object
- #compile ⇒ Object
-
#initialize(name = "pic" + numbers_to_letters(@@default_name) + "blerg") ⇒ Picture
constructor
intialise a picture with it’s name, use a string!.
-
#precompile ⇒ Object
creates the definition of the picture that goes at the start of the file.
Constructor Details
#initialize(name = "pic" + numbers_to_letters(@@default_name) + "blerg") ⇒ Picture
intialise a picture with it’s name, use a string!
32 33 34 35 36 37 38 |
# File 'lib/drawable.rb', line 32 def initialize(name="pic" + numbers_to_letters(@@default_name) + "blerg") super() @name = name @draw_commands = Array.new @@default_name = @@default_name + 1 @@picture_precompiler.add_picture(self) end |
Instance Attribute Details
#name=(value) ⇒ Object (writeonly)
Sets the attribute name
26 27 28 |
# File 'lib/drawable.rb', line 26 def name=(value) @name = value end |
Instance Method Details
#add_drawable(d) ⇒ Object
40 41 42 |
# File 'lib/drawable.rb', line 40 def add_drawable(d) @draw_commands.push(d) end |
#compile ⇒ Object
54 55 56 |
# File 'lib/drawable.rb', line 54 def compile @name.compile end |
#precompile ⇒ Object
creates the definition of the picture that goes at the start of the file
46 47 48 49 50 51 52 |
# File 'lib/drawable.rb', line 46 def precompile str = "picture " + @name + ";\n" @draw_commands.each do |d| str = str + d.compile + "\n" end str = str + @name + " := currentpicture; currentpicture := " + @@org_picture + ";\n" end |