Class: CSV2HTML::Conversor
- Inherits:
-
Object
- Object
- CSV2HTML::Conversor
- Defined in:
- lib/csv2html.rb
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
Instance Method Summary collapse
- #get_binding ⇒ Object
- #header_class(options, index) ⇒ Object
-
#initialize(data, options) ⇒ Conversor
constructor
A new instance of Conversor.
- #row_class(options, index) ⇒ Object
- #tag(name, opts = {}) ⇒ Object
Constructor Details
#initialize(data, options) ⇒ Conversor
Returns a new instance of Conversor.
13 14 15 16 17 18 |
# File 'lib/csv2html.rb', line 13 def initialize(data, ) parser = CSV.parse(data, headers: true) @headers = parser.headers = @rows = parser end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
11 12 13 |
# File 'lib/csv2html.rb', line 11 def headers @headers end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/csv2html.rb', line 11 def end |
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
11 12 13 |
# File 'lib/csv2html.rb', line 11 def rows @rows end |
Instance Method Details
#get_binding ⇒ Object
20 21 22 |
# File 'lib/csv2html.rb', line 20 def get_binding binding end |
#header_class(options, index) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/csv2html.rb', line 40 def header_class(, index) classes = [:header_class] if classes.nil? || classes[index].nil? '' else " class=\"#{classes[index]}\"" end end |
#row_class(options, index) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/csv2html.rb', line 31 def row_class(, index) classes = [:row_class] if classes.nil? || classes[index].nil? '' else " class=\"#{classes[index]}\"" end end |
#tag(name, opts = {}) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/csv2html.rb', line 24 def tag(name, opts={}) output = [name] output << "class=\"#{opts[:class]}\"" if opts.has_key?(:class) output << "id=\"#{opts[:id]}\"" if opts.has_key?(:id) "<" + output.join(' ') + ">" end |