Class: SeparatedValues::Document

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rows, options = DEFAULT_OPTIONS) ⇒ Document

Returns a new instance of Document.



5
6
7
8
# File 'lib/separated_values/document.rb', line 5

def initialize(rows, options = DEFAULT_OPTIONS)
  @rows = rows
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

#rowsObject (readonly)

Returns the value of attribute rows.



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

def rows
  @rows
end

Instance Method Details

#[](index) ⇒ Object



10
11
12
# File 'lib/separated_values/document.rb', line 10

def [](index)
  rows[index]
end

#to_hash_arrayObject



14
15
16
17
18
# File 'lib/separated_values/document.rb', line 14

def to_hash_array
  rows.map do |row|
    row.to_h(options[:schema])
  end
end