Class: Katello::Util::ReportTable

Inherits:
Object
  • Object
show all
Defined in:
app/lib/katello/util/report_table.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ ReportTable

Returns a new instance of ReportTable.



8
9
10
11
12
13
14
15
# File 'app/lib/katello/util/report_table.rb', line 8

def initialize(params)
  self.transform = params[:transforms]
  self.column_names = params.fetch(:column_names, []) #retained for ordering
  self.data = params[:data]
  self.renamed_columns = {}
  self.column_hash = {}
  column_names.each { |name| column_hash[name] = {:name => name} }
end

Instance Attribute Details

#column_hashObject

Returns the value of attribute column_hash.



6
7
8
# File 'app/lib/katello/util/report_table.rb', line 6

def column_hash
  @column_hash
end

#column_namesObject

Returns the value of attribute column_names.



6
7
8
# File 'app/lib/katello/util/report_table.rb', line 6

def column_names
  @column_names
end

#dataObject

Returns the value of attribute data.



6
7
8
# File 'app/lib/katello/util/report_table.rb', line 6

def data
  @data
end

#renamed_columnsObject

Returns the value of attribute renamed_columns.



6
7
8
# File 'app/lib/katello/util/report_table.rb', line 6

def renamed_columns
  @renamed_columns
end

#transformObject

Returns the value of attribute transform.



6
7
8
# File 'app/lib/katello/util/report_table.rb', line 6

def transform
  @transform
end

Instance Method Details

#as(type) ⇒ Object



21
22
23
24
25
26
27
# File 'app/lib/katello/util/report_table.rb', line 21

def as(type)
  if type == :csv
    as_csv(transform_data)
  elsif type == :text
    as_text(transform_data)
  end
end

#rename_column(original, new) ⇒ Object



17
18
19
# File 'app/lib/katello/util/report_table.rb', line 17

def rename_column(original, new)
  column_hash[original][:name] = new
end