lib/npr/entity/text.rb in npr-0.1.2 vs lib/npr/entity/text.rb in npr-1.1.0
- old
+ new
@@ -15,8 +15,27 @@
#-----------------
def to_s
@paragraphs.map(&:to_s).join("\n")
end
+
+ #-----------------
+ # Turn this text node into an embeddable
+ # block of HTML.
+ #
+ # This is useful if the fullText attribute
+ # is missing on an NPR Story. It will not
+ # be as robust as a full HTML body from
+ # NPR, but it will work in most cases.
+ #
+ def to_html
+ result = ""
+
+ @paragraphs.each do |paragraph|
+ result << "<p>" + paragraph.to_s + "</p>\n"
+ end
+
+ result
+ end
end # Text
end # Entity
end # NPR