Class: Section
- Inherits:
-
Object
- Object
- Section
- Defined in:
- lib/leif/section.rb
Instance Attribute Summary collapse
-
#io ⇒ Object
readonly
Returns the value of attribute io.
Class Method Summary collapse
Instance Method Summary collapse
- #banner(banner) {|_self| ... } ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(io) ⇒ Section
constructor
A new instance of Section.
- #print(message) ⇒ Object
Constructor Details
#initialize(io) ⇒ Section
Returns a new instance of Section.
5 6 7 8 |
# File 'lib/leif/section.rb', line 5 def initialize(io) @io = io @empty = true end |
Instance Attribute Details
#io ⇒ Object (readonly)
Returns the value of attribute io.
2 3 4 |
# File 'lib/leif/section.rb', line 2 def io @io end |
Class Method Details
.banner(banner, io = $stdout, &message) ⇒ Object
10 11 12 |
# File 'lib/leif/section.rb', line 10 def self.(, io = $stdout, &) new(io).(, &) end |
Instance Method Details
#banner(banner) {|_self| ... } ⇒ Object
14 15 16 17 18 |
# File 'lib/leif/section.rb', line 14 def (, &) io.puts "-- #{banner} --" yield self print '[empty]' if empty? end |
#empty? ⇒ Boolean
3 |
# File 'lib/leif/section.rb', line 3 def empty?() @empty end |
#print(message) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/leif/section.rb', line 20 def print() @empty = false Array().each do |line| io.puts " #{line}" end end |