Class: Sqlite::Dataset

Inherits:
Object
  • Object
show all
Defined in:
lib/dataset.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Dataset

Returns a new instance of Dataset.



5
6
7
8
9
10
11
12
# File 'lib/dataset.rb', line 5

def initialize(data)
  @header = @rows = []
  rows = split_lines data
  unless rows.empty?
    @header = split_pipe rows.shift
    @rows = rows.map { |item| split_pipe item }
  end
end

Instance Attribute Details

#headerObject (readonly)

Returns the value of attribute header.



3
4
5
# File 'lib/dataset.rb', line 3

def header
  @header
end

#rowsObject (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



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/dataset.rb', line 14

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