Class: Shoes::Text

Inherits:
Object show all
Defined in:
lib/shoes/text.rb

Direct Known Subclasses

Link

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(m, str, color = nil) ⇒ Text

Returns a new instance of Text.



26
27
28
29
# File 'lib/shoes/text.rb', line 26

def initialize m, str, color=nil
  @style, @str, @color = m, str, color
  @to_s = str.map(&:to_s).join
end

Instance Attribute Details

#colorObject (readonly)

Returns the value of attribute color.



30
31
32
# File 'lib/shoes/text.rb', line 30

def color
  @color
end

#parentObject

Returns the value of attribute parent.



31
32
33
# File 'lib/shoes/text.rb', line 31

def parent
  @parent
end

#strObject (readonly)

Returns the value of attribute str.



30
31
32
# File 'lib/shoes/text.rb', line 30

def str
  @str
end

#styleObject (readonly)

Returns the value of attribute style.



30
31
32
# File 'lib/shoes/text.rb', line 30

def style
  @style
end

#to_sObject (readonly)

Returns the value of attribute to_s.



30
31
32
# File 'lib/shoes/text.rb', line 30

def to_s
  @to_s
end

Instance Method Details

#replace(*str) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/shoes/text.rb', line 33

def replace *str
  @str = str
  @to_s = str.map(&:to_s).join
  @parent.args[:markup] = @parent.markup = @parent.contents.map(&:to_s).join
  @parent.args[:styles] = @parent.styles = @parent.app.get_styles @parent.contents
  @parent.style markup: @parent.markup
end