Class: TextStyle

Inherits:
Style show all
Defined in:
lib/yesroff/text.rb

Instance Attribute Summary collapse

Attributes inherited from Style

#name, #parent

Instance Method Summary collapse

Methods inherited from Style

#base_style, #child_of?, #initialize

Constructor Details

This class inherits a constructor from Style

Instance Attribute Details

#boldObject

Returns the value of attribute bold.



24
25
26
# File 'lib/yesroff/text.rb', line 24

def bold
  @bold
end

#codeObject

Returns the value of attribute code.



24
25
26
# File 'lib/yesroff/text.rb', line 24

def code
  @code
end

#italicObject

Returns the value of attribute italic.



24
25
26
# File 'lib/yesroff/text.rb', line 24

def italic
  @italic
end

Instance Method Details

#start(w) ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'lib/yesroff/text.rb', line 34

def start(w)
  if @bold
    w.start_bold
  elsif @italic
    w.start_italic
  elsif @code
    w.start_code
  end
end

#stop(w) ⇒ Object



44
45
46
47
48
49
50
51
52
# File 'lib/yesroff/text.rb', line 44

def stop(w)
  if @bold
    w.end_bold
  elsif @italic
    w.end_italic
  elsif @code
    w.end_code
  end    
end

#to_sObject



26
27
28
29
30
31
32
# File 'lib/yesroff/text.rb', line 26

def to_s
  result = "[Style: #{name}"
  result += 'B' if @bold
  result += 'I' if @italic
  result += 'C' if @code
  result += ']'
end