1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/lib/rss/utils.rb
kou 966a25465a * lib/rss, test/rss:
- supported Atom.
  - bumped version 0.1.6 to 0.1.7.
* sample/rss/convert.rb: added new sample.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12087 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-17 10:13:25 +00:00

32 lines
723 B
Ruby

module RSS
module Utils
module_function
def to_class_name(name)
name.split(/_/).collect do |part|
"#{part[0, 1].upcase}#{part[1..-1]}"
end.join("")
end
def get_file_and_line_from_caller(i=0)
file, line, = caller[i].split(':')
[file, line.to_i]
end
def html_escape(s)
s.to_s.gsub(/&/, "&amp;").gsub(/\"/, "&quot;").gsub(/>/, "&gt;").gsub(/</, "&lt;")
end
alias h html_escape
def new_with_value_if_need(klass, value)
if value.is_a?(klass)
value
else
klass.new(value)
end
end
def element_initialize_arguments?(args)
[true, false].include?(args[0]) and args[1].is_a?(Hash)
end
end
end