Class: RubyPost::BaseLabel
Overview
Base class for labels in rubypost
Direct Known Subclasses
Instance Attribute Summary collapse
-
#position ⇒ Object
writeonly
Sets the attribute position.
-
#text ⇒ Object
writeonly
Sets the attribute text.
Instance Method Summary collapse
- #add_option(o) ⇒ Object
- #bot ⇒ Object
-
#bottom ⇒ Object
place the text bellow the position.
-
#bottom_left ⇒ Object
place the text to the bottom left the position.
-
#bottom_right ⇒ Object
place the text to the bottom right the position.
-
#color(r, g, b) ⇒ Object
macro for setting the colour of the draw command.
-
#colour(r, g, b) ⇒ Object
macro for setting the colour of the draw command.
-
#compile_options ⇒ Object
utility function to compile all the options.
-
#initialize(t = nil, p = nil) ⇒ BaseLabel
constructor
You can set the text in the constructor.
-
#left ⇒ Object
place the text to the left the position.
- #lft ⇒ Object
- #llft ⇒ Object
- #lrt ⇒ Object
-
#right ⇒ Object
place the text to the right of the position.
-
#rotate(a) ⇒ Object
macro for rotating the label.
- #rt ⇒ Object
-
#scale(s) ⇒ Object
macro for scaling the draw command.
-
#set_position(d) ⇒ Object
set the text for this label.
-
#set_text(d) ⇒ Object
set the text for this label.
-
#top ⇒ Object
place the text above the position.
-
#top_left ⇒ Object
place the text to the upper left of the position.
-
#top_right ⇒ Object
place the text to the upper right the position.
-
#translate(x, y) ⇒ Object
macro for translating the label.
- #ulft ⇒ Object
- #urt ⇒ Object
Methods inherited from Object
Constructor Details
#initialize(t = nil, p = nil) ⇒ BaseLabel
You can set the text in the constructor. At the moment you must use etex/btex for the string to display correct. This can be achieve using latex(“string”).
12 13 14 15 16 17 18 |
# File 'lib/label.rb', line 12 def initialize(t=nil, p=nil) @options = Array.new @text = t @position = p top self end |
Instance Attribute Details
#position=(value) ⇒ Object (writeonly)
Sets the attribute position
6 7 8 |
# File 'lib/label.rb', line 6 def position=(value) @position = value end |
#text=(value) ⇒ Object (writeonly)
Sets the attribute text
6 7 8 |
# File 'lib/label.rb', line 6 def text=(value) @text = value end |
Instance Method Details
#add_option(o) ⇒ Object
20 21 22 23 |
# File 'lib/label.rb', line 20 def add_option(o) @options.push(o) self end |
#bot ⇒ Object
83 84 85 |
# File 'lib/label.rb', line 83 def bot bottom end |
#bottom ⇒ Object
place the text bellow the position. Wraps the metapost bot command for labels
79 80 81 82 |
# File 'lib/label.rb', line 79 def bottom @place = "bot" self end |
#bottom_left ⇒ Object
place the text to the bottom left the position. Wraps the metapost bot command for labels
126 127 128 129 |
# File 'lib/label.rb', line 126 def bottom_left @place = "llft" self end |
#bottom_right ⇒ Object
place the text to the bottom right the position. Wraps the metapost bot command for labels
146 147 148 149 |
# File 'lib/label.rb', line 146 def bottom_right @place = "lrt" self end |
#color(r, g, b) ⇒ Object
macro for setting the colour of the draw command. Spelt incorrectly.
52 53 54 |
# File 'lib/label.rb', line 52 def color(r,g,b) colour(r,g,b) end |
#colour(r, g, b) ⇒ Object
macro for setting the colour of the draw command
45 46 47 48 |
# File 'lib/label.rb', line 45 def colour(r,g,b) add_option(Colour.new(r,g,b)) self end |
#compile_options ⇒ Object
utility function to compile all the options
38 39 40 41 42 |
# File 'lib/label.rb', line 38 def str = String.new @options.each { |o| str = str + ' ' + o.compile } return str end |
#left ⇒ Object
place the text to the left the position. Wraps the metapost bot command for labels
106 107 108 109 |
# File 'lib/label.rb', line 106 def left @place = "lft" self end |
#lft ⇒ Object
110 111 112 |
# File 'lib/label.rb', line 110 def lft left end |
#llft ⇒ Object
130 131 132 |
# File 'lib/label.rb', line 130 def llft bottom_left end |
#lrt ⇒ Object
150 151 152 |
# File 'lib/label.rb', line 150 def lrt bottom_right end |
#right ⇒ Object
place the text to the right of the position. Wraps the metapost bot command for labels
96 97 98 99 |
# File 'lib/label.rb', line 96 def right @place = "rt" self end |
#rotate(a) ⇒ Object
macro for rotating the label. This is the same as using add_option(Rotate.new(a))
72 73 74 75 |
# File 'lib/label.rb', line 72 def rotate(a) add_option(Rotate.new(a)) self end |
#rt ⇒ Object
100 101 102 |
# File 'lib/label.rb', line 100 def rt right end |
#scale(s) ⇒ Object
macro for scaling the draw command. This is the same as using add_option(Scale.new(s))
58 59 60 61 |
# File 'lib/label.rb', line 58 def scale(s) add_option(Scale.new(s)) self end |
#set_position(d) ⇒ Object
set the text for this label. You can also use BaseLabel.position=
32 33 34 35 |
# File 'lib/label.rb', line 32 def set_position(d) @position = d self end |
#set_text(d) ⇒ Object
set the text for this label. You can also use BaseLabel.text=
26 27 28 29 |
# File 'lib/label.rb', line 26 def set_text(d) @text = d self end |
#top ⇒ Object
place the text above the position. Wraps the metapost bot command for labels
89 90 91 92 |
# File 'lib/label.rb', line 89 def top @place = "top" self end |
#top_left ⇒ Object
place the text to the upper left of the position. Wraps the metapost bot command for labels
116 117 118 119 |
# File 'lib/label.rb', line 116 def top_left @place = "ulft" self end |
#top_right ⇒ Object
place the text to the upper right the position. Wraps the metapost bot command for labels
136 137 138 139 |
# File 'lib/label.rb', line 136 def top_right @place = "urt" self end |
#translate(x, y) ⇒ Object
macro for translating the label. This is the same as using add_option(Translate.new(x,y))
65 66 67 68 |
# File 'lib/label.rb', line 65 def translate(x,y) add_option(Translate.new(Pair.new(x,y))) self end |
#ulft ⇒ Object
120 121 122 |
# File 'lib/label.rb', line 120 def ulft top_left end |
#urt ⇒ Object
140 141 142 |
# File 'lib/label.rb', line 140 def urt top_right end |