2004-01-28 03:46:13 +00:00
|
|
|
module RSS
|
2004-10-16 04:51:15 +00:00
|
|
|
module Utils
|
2005-02-03 15:31:57 +00: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 04:51:15 +00:00
|
|
|
def get_file_and_line_from_caller(i=0)
|
|
|
|
file, line, = caller[i].split(':')
|
|
|
|
[file, line.to_i]
|
|
|
|
end
|
2004-01-28 03:46:13 +00:00
|
|
|
|
2004-10-16 04:51:15 +00:00
|
|
|
def html_escape(s)
|
|
|
|
s.to_s.gsub(/&/, "&").gsub(/\"/, """).gsub(/>/, ">").gsub(/</, "<")
|
|
|
|
end
|
|
|
|
alias h html_escape
|
|
|
|
|
2005-04-05 06:42:03 +00:00
|
|
|
def new_with_value_if_need(klass, value)
|
|
|
|
if value.is_a?(klass)
|
|
|
|
value
|
|
|
|
else
|
|
|
|
klass.new(value)
|
|
|
|
end
|
|
|
|
end
|
2004-01-28 03:46:13 +00:00
|
|
|
|
2007-03-17 10:13:25 +00:00
|
|
|
def element_initialize_arguments?(args)
|
|
|
|
[true, false].include?(args[0]) and args[1].is_a?(Hash)
|
|
|
|
end
|
|
|
|
end
|
2004-01-28 03:46:13 +00:00
|
|
|
end
|