Class: Sqlite::Dataset
- Inherits:
-
Object
- Object
- Sqlite::Dataset
- Defined in:
- lib/dataset.rb
Instance Attribute Summary collapse
-
#header ⇒ Object
readonly
Returns the value of attribute header.
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
Instance Method Summary collapse
- #compare(other) ⇒ Object
-
#initialize(data) ⇒ Dataset
constructor
A new instance of Dataset.
Constructor Details
#initialize(data) ⇒ Dataset
Returns a new instance of Dataset.
5 6 7 8 9 |
# File 'lib/dataset.rb', line 5 def initialize(data) rows = data.split(/\n+/i) @header = rows.shift.split(/\|/) @rows = rows.map { |row| row.split(/\|/) } end |
Instance Attribute Details
#header ⇒ Object (readonly)
Returns the value of attribute header.
3 4 5 |
# File 'lib/dataset.rb', line 3 def header @header end |
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
3 4 5 |
# File 'lib/dataset.rb', line 3 def rows @rows end |
Instance Method Details
#compare(other) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/dataset.rb', line 11 def compare(other) same_header = same_header other.header same_rows = same_rows other.rows if same_header & same_rows :equals elsif !same_header :distinct_columns else :distinct_rows end end |