Module: Csv2schema::Schema
- Included in:
- CSV
- Defined in:
- lib/csv2schema/schema.rb
Instance Method Summary collapse
Instance Method Details
#get_type(format) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/csv2schema/schema.rb', line 21 def get_type(format) { string: 'http://www.w3.org/2001/XMLSchema#string', numeric: 'http://www.w3.org/2001/XMLSchema#int' }[format] end |
#schema ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/csv2schema/schema.rb', line 4 def schema fields = @column_headers.map do |key,col| { name: col['name'], title: col['name'], constraints: { required: col['required'], type: get_type(col['format']) } } end { "fields": fields }.to_json end |