microformats / microformats-ruby

Ruby gem that parse HTML containing microformats/microformats2 and returns Ruby objects, a Ruby hash or a JSON hash
https://rubygems.org/gems/microformats
Creative Commons Zero v1.0 Universal
100 stars 29 forks source link

collection.entry.author.name.to_s gives a NoMethodError: undefined method `name' error #25

Closed jeena closed 10 years ago

jeena commented 10 years ago

I'm not sure how to use it, it seems to have all the data parsed, because I can to .to_json and it looks right but I can't get the data out. I am trying to get the author name, his/her url, the content and the h-entry url, so nothing fancy.

I am trying to do it with: https://brid-gy.appspot.com/like/twitter/jeena/424554756917702656/109427493

I know it should be possible because this looks exactly like I want to have it: http://indiewebify.me/validate-h-entry/?url=https%3A%2F%2Fbrid-gy.appspot.com%2Flike%2Ftwitter%2Fjeena%2F424554756917702656%2F109427493

collection.entry.content.to_s works fine, I am getting "favorited this." and so does collection.entry.url.to_s. But when I try to get the author, then I get R Ç tag:twitter.com,2013:schnarfedwhich is understandable, it is the u-id, but then I can't get the collection.entry.author.name.to_s because I get:

NoMethodError: undefined method `name' for #<Microformats2::Property::Text:0x007fbbfc88ac60>

same with collection.entry.author.url.to_s. So Either I don't understand how this should be called or something is not working. Could someone help me out here?

jlsuttles commented 10 years ago

@jeena I believe collection.entry.author.format.name.to_s and collection.entry.author.format.url.to_s are what you are looking for. I will better document this case, thanks!

jeena commented 10 years ago

format? Hm is there somewhere some kind of documentation of this? I would never guessed to add the string format in there, but I'll try it :)