Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/appswarm/tools.rb,
lib/appswarm/proxy_testing.rb
Instance Method Summary collapse
-
#camelCase ⇒ Object
convert lowercase underscored strings to camelcase.
-
#dirName ⇒ Object
convert camelcase to lowercase underscored.
- #to_base64 ⇒ Object
-
#to_h ⇒ Object
convert plaintext to html (entities and newlines).
-
#to_hents ⇒ Object
convvert (some) html-entities.
- #underscored ⇒ Object
- #valid_html? ⇒ Boolean
Instance Method Details
#camelCase ⇒ Object
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 |
#dirName ⇒ Object
convert camelcase to lowercase underscored
60 61 62 |
# File 'lib/appswarm/tools.rb', line 60 def dirName underscored end |
#to_base64 ⇒ Object
74 75 76 |
# File 'lib/appswarm/tools.rb', line 74 def to_base64 [self].pack("m") end |
#to_h ⇒ Object
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_hents ⇒ Object
convvert (some) html-entities
65 66 67 |
# File 'lib/appswarm/tools.rb', line 65 def to_hents self.gsub("&","&").gsub("<","<").gsub(">",">") end |
#underscored ⇒ Object
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
45 46 47 |
# File 'lib/appswarm/proxy_testing.rb', line 45 def valid_html? self=~/html/i # FIXME end |