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 unless 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 = "picture_number" + @@default_name.to_s) ⇒ 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 = "picture_number" + @@default_name.to_s) ⇒ Picture
intialise a picture with it’s name, use a string!
22 23 24 25 26 27 28 |
# File 'lib/drawable.rb', line 22 def initialize(name="picture_number" + @@default_name.to_s) 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
16 17 18 |
# File 'lib/drawable.rb', line 16 def name=(value) @name = value end |
Instance Method Details
#add_drawable(d) ⇒ Object
30 31 32 |
# File 'lib/drawable.rb', line 30 def add_drawable(d) @draw_commands.push(d) end |
#compile ⇒ Object
44 45 46 |
# File 'lib/drawable.rb', line 44 def compile @name.compile end |
#precompile ⇒ Object
creates the definition of the picture that goes at the start of the file
36 37 38 39 40 41 42 |
# File 'lib/drawable.rb', line 36 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 |