-
Notifications
You must be signed in to change notification settings - Fork 2
update readme #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,4 +4,53 @@ rbase | |
| [](https://travis-ci.org/cybrilla/rbase) | ||
| [](https://coveralls.io/github/cybrilla/rbase?branch=master) | ||
|
|
||
| Create, read and edit dbf files. | ||
| rbase gem is used to create DBF files. | ||
|
|
||
| How to use: | ||
|
|
||
| First create a DBF file. | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove |
||
| ##Creating DBF | ||
| ```ruby | ||
| RBase.create_table 'people' do |t| | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can I give the filepath where the |
||
| t.column :name, :string, size: 30 | ||
| t.column :birthdate, :date | ||
| t.column :active, :boolean | ||
| t.column :tax, :integer, size: 10, decimal: 2 | ||
| end | ||
| ``` | ||
| You can provide file path in place of name, eg. `people` can be `tmp/dbfs/people`. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. name confusing with |
||
|
|
||
| ###Options: | ||
|
|
||
| * `:size` - size of the column in characters | ||
| * `:decimal` - number of decimal positions | ||
| * `:string` - corresponds to fixed length character column. Column size is limited to 254 (default). | ||
| * `:date` - date column type | ||
| * `:boolean` - logical column type | ||
| * `:integer` - number column type. | ||
|
|
||
| -- Some column types (e.g. :date type) have fixed size that cannot be overridden. | ||
|
|
||
| --Number is stored in human readable form (text representation), so you should specify it's size in characters. Maximum column size is 18 (default). | ||
|
|
||
|
|
||
| ##Adding Records | ||
|
|
||
| The records can be added once the file is created by opening the file using `RBase::Table.open(file_path)` and then calling `create` method and passing a hash. Eg: | ||
|
|
||
| ```ruby | ||
| dbf = RBase::Table.open(people) | ||
| row = { | ||
| name: "John Doe", | ||
| birthdate: Date.current, | ||
| active: 1, | ||
| tax: 134.23 | ||
| } | ||
| dbf.create(row) | ||
| dbf.close | ||
| ``` | ||
| ##Points To Remember | ||
| - The column name can not be more than 10 characters and should not have spaces. | ||
| - The column with date type pass the date object not a string or any other. | ||
| - The gem will generate file in `dbase III` format. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. link to |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rbase provides interface for interacting with DBF files.