mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
4996531a14
commit
3e621acadc
3 changed files with 17 additions and 0 deletions
|
|
@ -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(/&/, "&").gsub(/\"/, """).gsub(/>/, ">").gsub(/</, "<")
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue