Class: Troo::Output
- Inherits:
-
Object
- Object
- Troo::Output
- Defined in:
- lib/troo/presentation/formatter.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
Returns the value of attribute count.
Instance Method Summary collapse
- #indent(&block) ⇒ Object
-
#initialize ⇒ Output
constructor
A new instance of Output.
- #render(lines) ⇒ Object
- #spacer(&block) ⇒ Object
Constructor Details
#initialize ⇒ Output
Returns a new instance of Output.
206 207 208 |
# File 'lib/troo/presentation/formatter.rb', line 206 def initialize @count = 0 end |
Instance Attribute Details
#count ⇒ Object
Returns the value of attribute count.
204 205 206 |
# File 'lib/troo/presentation/formatter.rb', line 204 def count @count end |
Instance Method Details
#indent(&block) ⇒ Object
225 226 227 228 229 230 231 |
# File 'lib/troo/presentation/formatter.rb', line 225 def indent(&block) @count += 1 yield ensure @count -= 1 end |
#render(lines) ⇒ Object
210 211 212 213 |
# File 'lib/troo/presentation/formatter.rb', line 210 def render(lines) Array(lines).each { |line| print indentation + line } nil end |
#spacer(&block) ⇒ Object
215 216 217 218 219 220 221 222 223 |
# File 'lib/troo/presentation/formatter.rb', line 215 def spacer(&block) if block_given? print "\n" yield print "\n" else print "\n" end end |