Class: CSVModel::Model
- Inherits:
-
Object
- Object
- CSVModel::Model
- Includes:
- Utilities::Options
- Defined in:
- lib/csv_model/model.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#header ⇒ Object
readonly
Returns the value of attribute header.
-
#keys ⇒ Object
readonly
Returns the value of attribute keys.
-
#parse_error ⇒ Object
readonly
Returns the value of attribute parse_error.
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
Attributes included from Utilities::Options
Instance Method Summary collapse
-
#initialize(data, options = {}) ⇒ Model
constructor
A new instance of Model.
- #row_count ⇒ Object
- #structure_errors ⇒ Object
- #structure_valid? ⇒ Boolean
Methods included from Utilities::Options
Constructor Details
#initialize(data, options = {}) ⇒ Model
Returns a new instance of Model.
9 10 11 12 13 14 |
# File 'lib/csv_model/model.rb', line 9 def initialize(data, = {}) @data = data @rows = [] @options = @keys = Set.new end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
7 8 9 |
# File 'lib/csv_model/model.rb', line 7 def data @data end |
#header ⇒ Object (readonly)
Returns the value of attribute header.
7 8 9 |
# File 'lib/csv_model/model.rb', line 7 def header @header end |
#keys ⇒ Object (readonly)
Returns the value of attribute keys.
7 8 9 |
# File 'lib/csv_model/model.rb', line 7 def keys @keys end |
#parse_error ⇒ Object (readonly)
Returns the value of attribute parse_error.
7 8 9 |
# File 'lib/csv_model/model.rb', line 7 def parse_error @parse_error end |
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
7 8 9 |
# File 'lib/csv_model/model.rb', line 7 def rows @rows end |
Instance Method Details
#row_count ⇒ Object
16 17 18 |
# File 'lib/csv_model/model.rb', line 16 def row_count rows.count end |
#structure_errors ⇒ Object
20 21 22 23 24 |
# File 'lib/csv_model/model.rb', line 20 def structure_errors return [parse_error] if parse_error return header.errors if !header.valid? [] end |
#structure_valid? ⇒ Boolean
26 27 28 |
# File 'lib/csv_model/model.rb', line 26 def structure_valid? parse_error.nil? && header.valid? end |