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.
8 9 10 11 |
# File 'lib/magic_cloud/word.rb', line 8 def initialize(text, ) super() @text, @options = text.to_s, end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
13 14 15 |
# File 'lib/magic_cloud/word.rb', line 13 def @options end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
13 14 15 |
# File 'lib/magic_cloud/word.rb', line 13 def text @text end |
Instance Method Details
#draw(canvas, opts = {}) ⇒ Object
19 20 21 |
# File 'lib/magic_cloud/word.rb', line 19 def draw(canvas, opts = {}) canvas.draw_text(text, @options.merge(x: x, y: y).merge(opts)) end |
#inspect ⇒ Object
27 28 29 |
# File 'lib/magic_cloud/word.rb', line 27 def inspect "#<#{self.class} #{text}:#{}>" end |
#measure(canvas) ⇒ Object
23 24 25 |
# File 'lib/magic_cloud/word.rb', line 23 def measure(canvas) canvas.measure_text(text, @options) end |
#size ⇒ Object
15 16 17 |
# File 'lib/magic_cloud/word.rb', line 15 def size [:font_size] # FIXME end |