Class: Anoubis::Export
- Inherits:
-
Object
- Object
- Anoubis::Export
- Defined in:
- app/controllers/anoubis/export.rb
Instance Method Summary collapse
- #add(data) ⇒ Object
-
#initialize(options = {}) ⇒ Export
constructor
A new instance of Export.
- #to_h ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Export
Returns a new instance of Export.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/anoubis/export.rb', line 8 def initialize( = {}) self.data = [] self.title = [] [:format] = 'xls' if !.key? :format self.format = [:format] self.fields = if .key?(:fields) then [:fields] else nil end if self.fields self.fields.each do |field| self.title.push field[:title] end end end |
Instance Method Details
#add(data) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/anoubis/export.rb', line 21 def add (data) data.each do |dat| new_data = [] self.fields.each do |field| if dat.key? field[:id].to_sym new_data.push dat[field[:id].to_sym] else new_data.push '' end end #new_data = dat.except :actions, :sys_title self.data.push(new_data) end end |
#to_h ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'app/controllers/anoubis/export.rb', line 36 def to_h { data: self.data, title: self.title, fields: self.fields, format: self.format } end |