Class: Csv::Configuration
- Inherits:
-
Object
- Object
- Csv::Configuration
- Defined in:
- lib/csvreader/reader.rb
Instance Attribute Summary collapse
-
#blanks ⇒ Object
Returns the value of attribute blanks.
-
#comments ⇒ Object
Returns the value of attribute comments.
-
#dialect ⇒ Object
Returns the value of attribute dialect.
-
#na ⇒ Object
not available (string or array of strings or nil) - rename to nas/nils/nulls - why? why not?.
-
#sep ⇒ Object
col_sep (column separator).
-
#trim ⇒ Object
allow ltrim/rtrim/trim - why? why not?.
Instance Method Summary collapse
-
#blanks? ⇒ Boolean
skip blank lines (with only 1+ spaces) note: for now blank lines with no spaces will always get skipped.
- #comments? ⇒ Boolean
-
#default_options ⇒ Object
built-in (default) options todo: find a better name?.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#trim? ⇒ Boolean
strip leading and trailing spaces.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/csvreader/reader.rb', line 44 def initialize @sep = ',' @blanks = true @comments = true @trim = true ## note: do NOT add headers as global - should ALWAYS be explicit ## headers (true/false) - changes resultset and requires different processing!!! self ## return self for chaining end |
Instance Attribute Details
#blanks ⇒ Object
Returns the value of attribute blanks.
40 41 42 |
# File 'lib/csvreader/reader.rb', line 40 def blanks @blanks end |
#comments ⇒ Object
Returns the value of attribute comments.
41 42 43 |
# File 'lib/csvreader/reader.rb', line 41 def comments @comments end |
#dialect ⇒ Object
Returns the value of attribute dialect.
42 43 44 |
# File 'lib/csvreader/reader.rb', line 42 def dialect @dialect end |
#na ⇒ Object
not available (string or array of strings or nil) - rename to nas/nils/nulls - why? why not?
38 39 40 |
# File 'lib/csvreader/reader.rb', line 38 def na @na end |
#sep ⇒ Object
col_sep (column separator)
37 38 39 |
# File 'lib/csvreader/reader.rb', line 37 def sep @sep end |
#trim ⇒ Object
allow ltrim/rtrim/trim - why? why not?
39 40 41 |
# File 'lib/csvreader/reader.rb', line 39 def trim @trim end |
Instance Method Details
#blanks? ⇒ Boolean
skip blank lines (with only 1+ spaces) note: for now blank lines with no spaces will always get skipped
60 |
# File 'lib/csvreader/reader.rb', line 60 def blanks?() @blanks; end |
#comments? ⇒ Boolean
63 |
# File 'lib/csvreader/reader.rb', line 63 def comments?() @comments; end |
#default_options ⇒ Object
built-in (default) options
todo: find a better name?
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/csvreader/reader.rb', line 68 def ## note: ## do NOT include sep character and ## do NOT include headers true/false here ## ## make default sep its own "global" default config ## e.g. Csv.config.sep = ## common options ## skip comments starting with # ## skip blank lines ## strip leading and trailing spaces ## NOTE/WARN: leading and trailing spaces NOT allowed/working with double quoted values!!!! defaults = { blanks: @blanks, ## note: skips lines with no whitespaces only!! (e.g. line with space is NOT blank!!) comments: @comments, trim: @trim ## :converters => :strip } defaults end |
#trim? ⇒ Boolean
strip leading and trailing spaces
56 |
# File 'lib/csvreader/reader.rb', line 56 def trim?() @trim; end |