Class: Iiko::CSV
- Inherits:
-
Object
- Object
- Iiko::CSV
- Defined in:
- lib/iiko/csv.rb
Instance Attribute Summary collapse
-
#headers ⇒ Object
(also: #h)
Returns the value of attribute headers.
-
#options ⇒ Object
Returns the value of attribute options.
-
#path_to_csv ⇒ Object
readonly
Returns the value of attribute path_to_csv.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(path_to_csv, options = {}) ⇒ CSV
constructor
A new instance of CSV.
- #load ⇒ Object
Constructor Details
#initialize(path_to_csv, options = {}) ⇒ CSV
Returns a new instance of CSV.
11 12 13 14 15 16 17 |
# File 'lib/iiko/csv.rb', line 11 def initialize(path_to_csv, = {}) = { col_sep: ';', quote_char: "\'" }.merge() [:headers] = false raise ArgumentError, "'path_to_csv' is required" unless path_to_csv @path_to_csv = path_to_csv end |
Instance Attribute Details
#headers ⇒ Object Also known as: h
Returns the value of attribute headers.
6 7 8 |
# File 'lib/iiko/csv.rb', line 6 def headers @headers end |
#options ⇒ Object
Returns the value of attribute options.
6 7 8 |
# File 'lib/iiko/csv.rb', line 6 def end |
#path_to_csv ⇒ Object (readonly)
Returns the value of attribute path_to_csv.
7 8 9 |
# File 'lib/iiko/csv.rb', line 7 def path_to_csv @path_to_csv end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
7 8 9 |
# File 'lib/iiko/csv.rb', line 7 def raw @raw end |
Instance Method Details
#data ⇒ Object
25 26 27 |
# File 'lib/iiko/csv.rb', line 25 def data raw[1..-1] end |
#load ⇒ Object
19 20 21 22 23 |
# File 'lib/iiko/csv.rb', line 19 def load @raw = ::CSV.read(path_to_csv, ) prepare_headers self end |