Class: Container
- Inherits:
-
Object
- Object
- Container
- Defined in:
- lib/yesroff/text.rb
Instance Attribute Summary collapse
-
#contents ⇒ Object
Returns the value of attribute contents.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#style ⇒ Object
Returns the value of attribute style.
Instance Method Summary collapse
- #<<(content) ⇒ Object
-
#initialize(style, parent = nil, contents = []) ⇒ Container
constructor
A new instance of Container.
- #length ⇒ Object
- #render(w) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(style, parent = nil, contents = []) ⇒ Container
Returns a new instance of Container.
80 81 82 83 84 |
# File 'lib/yesroff/text.rb', line 80 def initialize(style, parent=nil, contents=[]) @style = style @contents = contents @parent = parent end |
Instance Attribute Details
#contents ⇒ Object
Returns the value of attribute contents.
78 79 80 |
# File 'lib/yesroff/text.rb', line 78 def contents @contents end |
#parent ⇒ Object
Returns the value of attribute parent.
78 79 80 |
# File 'lib/yesroff/text.rb', line 78 def parent @parent end |
#style ⇒ Object
Returns the value of attribute style.
78 79 80 |
# File 'lib/yesroff/text.rb', line 78 def style @style end |
Instance Method Details
#<<(content) ⇒ Object
86 87 88 |
# File 'lib/yesroff/text.rb', line 86 def <<(content) @contents << content end |
#length ⇒ Object
90 91 92 93 94 |
# File 'lib/yesroff/text.rb', line 90 def length l = 0 @contents.each {|kid| l += kid.length} l end |
#render(w) ⇒ Object
96 97 98 99 100 101 |
# File 'lib/yesroff/text.rb', line 96 def render(w) #log "========= rendering #{self.class} size: #{contents.size}" #pp contents #puts "Rendering:" contents.each {|c| c.render(w)} end |
#to_s ⇒ Object
103 104 105 106 107 108 109 |
# File 'lib/yesroff/text.rb', line 103 def to_s result = "Container #{style}" if @contents result += @contents.join(' ') end result end |