public
Fork of Caged/gitnub
Description: A Gitk-like application written in RubyCocoa that looks like it belongs on a Mac. See the wiki for downloads and screenshots.
Homepage: http://alternateidea.com
Clone URL: git://github.com/kballard/gitnub.git
Search Repo:
Caged (author)
Wed May 14 12:23:52 -0700 2008
commit  72ace73a9eac10790b23d01c47cd1ef0ea3ac423
tree    9a4e836db8e5a5f4d47a29c4d6478e7c768efb73
parent  019f7eab430c325acd58a548baa7856fdf69b24e
gitnub / lib / string_extensions.rb
100644 19 lines (17 sloc) 0.367 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class String
  HTML_ESCAPES = {
    ?& => "amp",
    ?" => "quot",
    ?< => "lt",
    ?> => "gt"
  }.freeze
 
  def escapeHTML
    self.split("").collect { |x| HTML_ESCAPES.key?(x.ord) ? "&#{HTML_ESCAPES[x.ord]};" : x }.join("")
  end
 
  # Ruby 1.9 forward-compatibility
  unless String.method_defined?(:ord)
    define_method :ord do
      self[0]
    end
  end
end