Class: Section

Inherits:
Object
  • Object
show all
Defined in:
lib/leif/section.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#ioObject (readonly)

Returns the value of attribute io.



2
3
4
# File 'lib/leif/section.rb', line 2

def io
  @io
end

Class Method Details



10
11
12
# File 'lib/leif/section.rb', line 10

def self.banner(banner, io = $stdout, &message)
  new(io).banner(banner, &message)
end

Instance Method Details

Yields:

  • (_self)

Yield Parameters:

  • _self (Section)

    the object that the method was called on



14
15
16
17
18
# File 'lib/leif/section.rb', line 14

def banner(banner, &message)
  io.puts "-- #{banner} --"
  yield self
  print '[empty]' if empty?
end

#empty?Boolean

Returns:

  • (Boolean)


3
# File 'lib/leif/section.rb', line 3

def empty?() @empty end


20
21
22
23
24
25
# File 'lib/leif/section.rb', line 20

def print(message)
  @empty = false
  Array(message).each do |line|
    io.puts "  #{line}"
  end
end