Added usage examples of collection.to_hash and .to_json

As per @aaronpk wanting this feature to the point of considering creating a separate parser — turns out it is possible, just a little buried!
This commit is contained in:
Barnaby Walters 2014-06-11 16:45:17 +00:00
parent 0734bc5c44
commit 96ed937040

View file

@ -78,6 +78,12 @@ collection = Microformats2.parse(source)
collection.entry.name.to_s #=> "Microformats 2"
# accessing nested microformats
collection.entry.author.format.name.to_s #=> "Jessica Lynn Suttles"
# getting a copy of the canonical microformats2 hash structure
collection.to_hash
# the above, as JSON in a string
collection.to_json
```
* `source` can be a URL, filepath, or HTML