-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved the RDF::Enumerable#dump and RDF::Writer.dump documentation …
…a tad (closes #70).
- Loading branch information
Showing
2 changed files
with
10 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4741d37
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.
The potential problem with this is that Writer.for takes just one arg. If you were to call as graph,dump(:rdfxml, :standard_prefixes => true), you'll get an error. I used args.first to prevent this. You can get around this by passing just a hash, used by both Writer.for and Writer.dump, but this is the same with either implementation.
4741d37
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.
Note that I also changed
args.last
toargs.pop
, so it's fine fordump(:rdfxml, :standard_prefixes => true)
.The reason I prefer this approach is that in the original patch, the first argument and the last argument were getting used, but any in-between were just silently ignored. So it would have been possible to call
dump(:rdfxml, :ignored, 1, 2, 3, :ignored, :standard_prefixes => true)
without getting an error.In the reformulated version above, giving too many non-Hash arguments will result in an ArgumentError from
Writer.for
, as it ought to; i.e., the user in fact is at fault, and hence ought to get an error so as to know to adjust their code. But perhaps I missed something?4741d37
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.
Cool, I see that this does, indeed, work just fine. Thanks.
4741d37
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.
Tested it with various arguments, and thought I had a bug in there for a moment (ignore that if you got the notification for the previous comment, now deleted), but I think it's actually all working as intended.