2004-01-27 22:46:13 -05:00
|
|
|
module RSS
|
|
|
|
|
2004-10-16 00:51:15 -04:00
|
|
|
module Utils
|
2004-01-27 22:46:13 -05:00
|
|
|
|
2005-02-03 10:31:57 -05:00
|
|
|
module_function
|
|
|
|
def to_class_name(name)
|
|
|
|
name.split(/_/).collect do |part|
|
|
|
|
"#{part[0, 1].upcase}#{part[1..-1]}"
|
|
|
|
end.join("")
|
|
|
|
end
|
|
|
|
|
2004-10-16 00:51:15 -04:00
|
|
|
def get_file_and_line_from_caller(i=0)
|
|
|
|
file, line, = caller[i].split(':')
|
|
|
|
[file, line.to_i]
|
|
|
|
end
|
2004-01-27 22:46:13 -05:00
|
|
|
|
2004-10-16 00:51:15 -04:00
|
|
|
def html_escape(s)
|
|
|
|
s.to_s.gsub(/&/, "&").gsub(/\"/, """).gsub(/>/, ">").gsub(/</, "<")
|
|
|
|
end
|
|
|
|
alias h html_escape
|
|
|
|
|
2005-04-05 02:42:03 -04:00
|
|
|
def new_with_value_if_need(klass, value)
|
|
|
|
if value.is_a?(klass)
|
|
|
|
value
|
|
|
|
else
|
|
|
|
klass.new(value)
|
|
|
|
end
|
|
|
|
end
|
2004-10-16 00:51:15 -04:00
|
|
|
end
|
2004-01-27 22:46:13 -05:00
|
|
|
|
|
|
|
end
|