Class: TaskJuggler::TextReport

Inherits:
ReportBase show all
Defined in:
lib/taskjuggler/reports/TextReport.rb

Overview

This is the most basic type of report. It only contains 5 RichText elements. It’s got a header and footer and a central text with margin elements left and right.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ReportBase

#a, #filterAccountList, #filterResourceList, #filterTaskList

Constructor Details

#initialize(report) ⇒ TextReport

Returns a new instance of TextReport.



25
26
27
28
29
30
# File 'lib/taskjuggler/reports/TextReport.rb', line 25

def initialize(report)
  super

  @lWidth = @cWidth = @rWidth = 0
  @lPadding = @cPadding = @rPadding = 0
end

Instance Attribute Details

#centerObject

Returns the value of attribute center.



23
24
25
# File 'lib/taskjuggler/reports/TextReport.rb', line 23

def center
  @center
end

Returns the value of attribute footer.



23
24
25
# File 'lib/taskjuggler/reports/TextReport.rb', line 23

def footer
  @footer
end

#headerObject

Returns the value of attribute header.



23
24
25
# File 'lib/taskjuggler/reports/TextReport.rb', line 23

def header
  @header
end

#leftObject

Returns the value of attribute left.



23
24
25
# File 'lib/taskjuggler/reports/TextReport.rb', line 23

def left
  @left
end

#rightObject

Returns the value of attribute right.



23
24
25
# File 'lib/taskjuggler/reports/TextReport.rb', line 23

def right
  @right
end

Instance Method Details

#generateIntermediateFormatObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/taskjuggler/reports/TextReport.rb', line 32

def generateIntermediateFormat
  super

  # A width of 0 means, the columns flexible.
  if a('center')
    if a('left') && a('right')
      @lWidth = @rWidth = 20
      @cWidth = 60
      @lPadding = @cPadding = 2
    elsif a('left') && !a('right')
      @lWidth = 25
      @cWidth = 75
      @lPadding = 2
    elsif !a('left') && a('right')
      @cWidth = 75
      @rWidth = 25
      @cPadding = 2
    else
      @cWidth = 100
    end
  else
    if a('left') && a('right')
      @lWidth = @rWidth = 50
      @lPadding = 2
    elsif a('left') && !a('right')
      @lWidth = 100
    elsif !a('left') && a('right')
      @rWidth = 100
    end
  end
end

#to_csvObject



90
91
92
93
94
95
# File 'lib/taskjuggler/reports/TextReport.rb', line 90

def to_csv
  @report.warning('text_report_no_csv',
                  "textreport '#{@report.fullId}' cannot be converted " +
                  "into CSV format")
  nil
end

#to_htmlObject



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/taskjuggler/reports/TextReport.rb', line 64

def to_html
  html = []
  html << rt_to_html('header')
  if a('left') || a('center') || a('right')
    html << (table = XMLElement.new('table', 'class' => 'tj_text_page',
                                             'cellspacing' => '0'))
    table << (row = XMLElement.new('tr', 'class' => 'tj_text_row'))
    %w( left center right).each do |i|
      width = instance_variable_get('@' + i[0].chr + 'Width')
      padding = instance_variable_get('@' + i[0].chr + 'Padding')
      if a(i)
        row << (col = XMLElement.new('td', 'class' => "tj_column_#{i}"))
        style = ''
        style += "width:#{width}%; " if width > 0
        style += "padding-right:#{padding}%; " if padding > 0
        col['style'] = style
        col << rt_to_html(i)
      end
    end

  end
  html << rt_to_html('footer')

  html
end