Class: Shoes::TextBlock

Inherits:
Object
  • Object
show all
Defined in:
lib/blue_shoes/text_block.rb

Direct Known Subclasses

Banner, Caption, Inscription, Para, Subtitle, Tagline, Title

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#labelObject

Returns the value of attribute label.



9
10
11
# File 'lib/blue_shoes/text_block.rb', line 9

def label
  @label
end

#textObject

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

#contentsObject

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_labelObject



38
39
40
# File 'lib/blue_shoes/text_block.rb', line 38

def to_label
  label
end

#to_sObject

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