diff options
| author | Oskari Timperi <oskari.timperi@iki.fi> | 2017-10-25 23:19:38 +0300 |
|---|---|---|
| committer | Oskari Timperi <oskari.timperi@iki.fi> | 2017-10-25 23:19:38 +0300 |
| commit | f27c02d9b77d1f179ba676e711c79ed53bceb218 (patch) | |
| tree | 5e0097b755557194e5cb6a8a61e85bdc94b90a62 | |
| parent | 46b03de3685b8714f97013d435a337ba4c0eaa8e (diff) | |
| download | nimrec-f27c02d9b77d1f179ba676e711c79ed53bceb218.tar.gz nimrec-f27c02d9b77d1f179ba676e711c79ed53bceb218.zip | |
Add some simple examples
| -rw-r--r-- | examples/emails.nim | 10 | ||||
| -rw-r--r-- | examples/names.nim | 5 | ||||
| -rw-r--r-- | examples/persons.rec | 23 | ||||
| -rw-r--r-- | nimrec.nimble | 2 |
4 files changed, 39 insertions, 1 deletions
diff --git a/examples/emails.nim b/examples/emails.nim new file mode 100644 index 0000000..fff8148 --- /dev/null +++ b/examples/emails.nim @@ -0,0 +1,10 @@ +import nimrec +import streams + +for record in records(newFileStream("persons.rec")): + if not hasField(record, "Email"): + continue + echo(record["Name"]) + for label, value in record: + if label == "Email": + echo(" " & value) diff --git a/examples/names.nim b/examples/names.nim new file mode 100644 index 0000000..d81c51b --- /dev/null +++ b/examples/names.nim @@ -0,0 +1,5 @@ +import nimrec +import streams + +for record in records(newFileStream("persons.rec")): + echo(record["Name"]) diff --git a/examples/persons.rec b/examples/persons.rec new file mode 100644 index 0000000..a9dd3e6 --- /dev/null +++ b/examples/persons.rec @@ -0,0 +1,23 @@ +Name: John Doe +Age: 34 + +Name: Jane Doe +Age: 32 + +Name: Tressa Tardiff +Age: 41 + +Name: Elvis Eisert +Age: 66 + +Name: Zackary Zermeno +Age: 21 + +Name: Alix Aumann +Age: 52 +Email: alix.aumann@foobar.com +Email: aumann@company.com + +Name: Ines Isham +Age: 58 +Email: ines.isham@foobar.com diff --git a/nimrec.nimble b/nimrec.nimble index fe1dc33..19d8e18 100644 --- a/nimrec.nimble +++ b/nimrec.nimble @@ -9,4 +9,4 @@ license = "MIT" requires "nim >= 0.17.2" -skipDirs = @["tests"] +skipDirs = @["tests", "examples"] |
