summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-07-19 14:54:52 +0000
committerkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-07-19 14:54:52 +0000
commit3e621acadce51ebb91a6587a012f47904faf6838 (patch)
treef81cc12b6e33f45b4098e824eeb8e8c772bce026 /lib
parent4996531a14f2e5d9b666b5de5d1bfffdd8afc7a8 (diff)
* lib/rss/parser.rb, lib/rss/utils.rb: added documents.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10570 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/rss/parser.rb8
-rw-r--r--lib/rss/utils.rb5
2 files changed, 13 insertions, 0 deletions
diff --git a/lib/rss/parser.rb b/lib/rss/parser.rb
index 6f5696edae..033bc123aa 100644
--- a/lib/rss/parser.rb
+++ b/lib/rss/parser.rb
@@ -7,6 +7,10 @@ module RSS
class NotWellFormedError < Error
attr_reader :line, :element
+
+ # Create a new NotWellFormedError for an error at +line+
+ # in +element+. If a block is given the return value of
+ # the block ends up in the error message.
def initialize(line=nil, element=nil)
message = "This is not well formed XML"
if element or line
@@ -85,6 +89,10 @@ module RSS
end
private
+
+ # Try to get the XML associated with +rss+.
+ # Return +rss+ if it already looks like XML, or treat it as a URI,
+ # or a file to get the XML,
def normalize_rss(rss)
return rss if maybe_xml?(rss)
diff --git a/lib/rss/utils.rb b/lib/rss/utils.rb
index 031ff3072b..b242a72292 100644
--- a/lib/rss/utils.rb
+++ b/lib/rss/utils.rb
@@ -1,6 +1,8 @@
module RSS
module Utils
module_function
+
+ # Convert a name_with_underscores to CamelCase.
def to_class_name(name)
name.split(/_/).collect do |part|
"#{part[0, 1].upcase}#{part[1..-1]}"
@@ -12,11 +14,14 @@ module RSS
[file, line.to_i]
end
+ # escape '&', '"', '<' and '>' for use in HTML.
def html_escape(s)
s.to_s.gsub(/&/, "&amp;").gsub(/\"/, "&quot;").gsub(/>/, "&gt;").gsub(/</, "&lt;")
end
alias h html_escape
+ # If +value+ is an instance of class +klass+, return it, else
+ # create a new instance of +klass+ with value +value+.
def new_with_value_if_need(klass, value)
if value.is_a?(klass)
value