end
end
+ # Turn a number of seconds into a hours:minutes:seconds e.g.
+ # 3:18:10 or 5'12" or 7s
+ #
+ def Utils.secs_to_short(seconds)
+ secs = seconds.to_i # make sure it's an integer
+ mins, secs = secs.divmod 60
+ hours, mins = mins.divmod 60
+ if hours > 0
+ return ("%s:%s:%s" % [hours, mins, secs])
+ elsif mins > 0
+ return ("%s'%s\"" % [mins, secs])
+ else
+ return ("%ss" % [secs])
+ end
+ end
+
# Execute an external program, returning a String obtained by redirecting
# the program's standards errors and output
# uri_fragment:: the URI fragment of the original request
#
def Utils.get_string_html_info(text, opts={})
+ debug "getting string html info"
txt = text.dup
title = txt.ircify_html_title
+ debug opts
if frag = opts[:uri_fragment] and not frag.empty?
- fragreg = /.*?<a\s+[^>]*name=["']?#{frag}["']?.*?>/im
- txt.sub!(fragreg,'')
+ fragreg = /<a\s+[^>]*name=["']?#{frag}["']?[^>]*>/im
+ debug fragreg
+ debug txt
+ if txt.match(fragreg)
+ # grab the post-match
+ txt = $'
+ end
end
c_opts = opts.dup
c_opts[:strip] ||= title