From bffa75092387f579173127e87422d9fc99abc87a Mon Sep 17 00:00:00 2001 From: Jessica Lynn Suttles Date: Mon, 18 Feb 2013 12:07:16 -0800 Subject: [PATCH] adds Property::Foundation#format --- lib/microformats2/property/foundation.rb | 4 ++++ spec/lib/microformats2/collection_spec.rb | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/microformats2/property/foundation.rb b/lib/microformats2/property/foundation.rb index 3ab0cf0..6bc0070 100644 --- a/lib/microformats2/property/foundation.rb +++ b/lib/microformats2/property/foundation.rb @@ -18,6 +18,10 @@ module Microformats2 @to_s ||= value_class_pattern || element_value || text_value end + def format + formats.first + end + def formats @formats ||= format_classes.length >=1 ? FormatParser.parse(@element) : [] end diff --git a/spec/lib/microformats2/collection_spec.rb b/spec/lib/microformats2/collection_spec.rb index ff98414..11123ca 100644 --- a/spec/lib/microformats2/collection_spec.rb +++ b/spec/lib/microformats2/collection_spec.rb @@ -149,9 +149,12 @@ describe Microformats2::Collection do it "HCard#author is a Property::Text" do @collection.entry.author.should be_kind_of Microformats2::Property::Text end - it "assigns HCard to Property::Text#formats" do + it "assigns all HCard to Property::Text#formats" do @collection.entry.author.formats.first.should be_kind_of HCard end + it "assigns the first HCard to Property::Text#format" do + @collection.entry.author.format.should be_kind_of HCard + end end end end