Class: MagicCloud::Word
Overview
Class representing individual word in word cloud
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Attributes inherited from Shape
#height, #rect, #sprite, #width, #x, #y
Instance Method Summary collapse
- #draw(canvas, opts = {}) ⇒ Object
-
#initialize(text, options) ⇒ Word
constructor
A new instance of Word.
- #inspect ⇒ Object
- #measure(canvas) ⇒ Object
- #size ⇒ Object
Methods inherited from Shape
Constructor Details
#initialize(text, options) ⇒ Word
Returns a new instance of Word.
7 8 9 10 |
# File 'lib/magic_cloud/word.rb', line 7 def initialize(text, ) super() @text, @options = text.to_s, end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
12 13 14 |
# File 'lib/magic_cloud/word.rb', line 12 def @options end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
12 13 14 |
# File 'lib/magic_cloud/word.rb', line 12 def text @text end |
Instance Method Details
#draw(canvas, opts = {}) ⇒ Object
18 19 20 |
# File 'lib/magic_cloud/word.rb', line 18 def draw(canvas, opts = {}) canvas.draw_text(text, @options.merge(x: x, y: y).merge(opts)) end |
#inspect ⇒ Object
26 27 28 |
# File 'lib/magic_cloud/word.rb', line 26 def inspect "#<#{self.class} #{text}:#{}>" end |
#measure(canvas) ⇒ Object
22 23 24 |
# File 'lib/magic_cloud/word.rb', line 22 def measure(canvas) canvas.measure_text(text, @options) end |
#size ⇒ Object
14 15 16 |
# File 'lib/magic_cloud/word.rb', line 14 def size [:font_size] # FIXME end |