Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/appswarm/tools.rb,
lib/appswarm/proxy_testing.rb

Instance Method Summary collapse

Instance Method Details

#camelCaseObject

convert lowercase underscored strings to camelcase



50
51
52
53
# File 'lib/appswarm/tools.rb', line 50

def camelCase
  return self if length<2
  (self[0..0].upcase+self[1..-1]).gsub(/(_.)/){|s|s[1..-1].upcase}
end

#dirNameObject

convert camelcase to lowercase underscored



60
61
62
# File 'lib/appswarm/tools.rb', line 60

def dirName
  underscored
end

#to_base64Object



74
75
76
# File 'lib/appswarm/tools.rb', line 74

def to_base64
  [self].pack("m")
end

#to_hObject

convert plaintext to html (entities and newlines)



70
71
72
# File 'lib/appswarm/tools.rb', line 70

def to_h
  self.to_hents.gsub("\n","<br>\n")
end

#to_hentsObject

convvert (some) html-entities



65
66
67
# File 'lib/appswarm/tools.rb', line 65

def to_hents
  self.gsub("&","&amp;").gsub("<","&lt;").gsub(">","&gt;")
end

#underscoredObject



55
56
57
# File 'lib/appswarm/tools.rb', line 55

def underscored
  (self[0..0].downcase+self[1..-1]).gsub(/([A-Z])/){|s|"_"+s.downcase}
end

#valid_html?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/appswarm/proxy_testing.rb', line 45

def valid_html?
  self=~/html/i # FIXME
end