Class: Frame

Inherits:
Object
  • Object
show all
Defined in:
lib/fresnel/frame.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Frame

Returns a new instance of Frame.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fresnel/frame.rb', line 6

def initialize(options)
  @header=options[:header]||Array.new
  @body=options[:body]||String.new
  @footer=options[:footer]||Array.new
  @output=String.new
  
  line="+"
  (@@term_size-3).times{line+="-"}
  line+="+"

  collect=Array.new
  collect << line
  if header.any?
    header.each{|l|collect << l.chomp}
    collect << line
  end
  collect << ""
  collect += @body.chomp.wrap(@@term_size-5).split("\n")
  collect << ""
  collect << line
  if footer.any?
    footer.each{|l|collect << l.chomp}
    collect << line
  end
  
  collect.each do |l|
    self.output+="#{"| " unless l=~/^\+/}#{l.ljust(@@term_size-5)}#{" |" unless l=~/^\+/}\n"
  end
  
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



4
5
6
# File 'lib/fresnel/frame.rb', line 4

def body
  @body
end

Returns the value of attribute footer.



4
5
6
# File 'lib/fresnel/frame.rb', line 4

def footer
  @footer
end

#headerObject

Returns the value of attribute header.



4
5
6
# File 'lib/fresnel/frame.rb', line 4

def header
  @header
end

#outputObject

Returns the value of attribute output.



4
5
6
# File 'lib/fresnel/frame.rb', line 4

def output
  @output
end

Instance Method Details

#to_sObject



37
38
39
# File 'lib/fresnel/frame.rb', line 37

def to_s
  output
end