Class: Shoes::TextBlock
- Inherits:
-
Object
- Object
- Shoes::TextBlock
- Defined in:
- lib/blue_shoes/text_block.rb
Instance Attribute Summary collapse
-
#label ⇒ Object
Returns the value of attribute label.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
-
#contents ⇒ Object
Lists all of the strings and styled text objects inside this block.
-
#initialize(text) ⇒ TextBlock
constructor
A new instance of TextBlock.
-
#replace(str) ⇒ Object
Replaces the text of the entire block with the characters of a string.
- #to_label ⇒ Object
-
#to_s ⇒ Object
An alias for text.
Constructor Details
#initialize(text) ⇒ TextBlock
Returns a new instance of TextBlock.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/blue_shoes/text_block.rb', line 11 def initialize(text) if text.is_a? Shoes::Text text = text else text = Shoes::Text.new(text.to_s) end self.label = Qt::Label.new label.setText text.to_s if text.strong? label.setFont(Qt::Font.new("Purisa", 12, Qt::Font::Bold)); else label.setFont(Qt::Font.new("Purisa", 12)); end end |
Instance Attribute Details
#label ⇒ Object
Returns the value of attribute label.
9 10 11 |
# File 'lib/blue_shoes/text_block.rb', line 9 def label @label end |
#text ⇒ Object
Returns the value of attribute text.
31 32 33 |
# File 'lib/blue_shoes/text_block.rb', line 31 def text @text end |
Instance Method Details
#contents ⇒ Object
Lists all of the strings and styled text objects inside this block.
4 5 6 7 |
# File 'lib/blue_shoes/text_block.rb', line 4 def contents # returns an array of elements throw NotImplementedError end |
#replace(str) ⇒ Object
Replaces the text of the entire block with the characters of a string.
27 28 29 |
# File 'lib/blue_shoes/text_block.rb', line 27 def replace(str) label.setText str.to_s end |
#to_label ⇒ Object
38 39 40 |
# File 'lib/blue_shoes/text_block.rb', line 38 def to_label label end |
#to_s ⇒ Object
An alias for text. Returns a flattened string of all of this TextBlock’s contents.
34 35 36 |
# File 'lib/blue_shoes/text_block.rb', line 34 def to_s label.getText end |