Class: Tableware::Parser
- Inherits:
-
Object
show all
- Defined in:
- lib/tableware/parser.rb
Defined Under Namespace
Classes: TableWithoutHeaderError
Constant Summary
collapse
- ROW_START =
/^>?\s*\|?/
- ROW_END =
/\|?\s*$/
Instance Method Summary
collapse
Instance Method Details
#arrays(input) ⇒ Object
10
11
12
|
# File 'lib/tableware/parser.rb', line 10
def arrays(input)
make_arrays(input)
end
|
#hashes(input) ⇒ Object
14
15
16
17
18
|
# File 'lib/tableware/parser.rb', line 14
def hashes(input)
items = make_arrays(input)
raise TableWithoutHeaderError, 'Sorry, only text tables with header rows can be turned into hashes' unless @headers
items.map! { |row| @headers.zip(row).to_h }
end
|