Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/webconsole/lib/module.rb,
lib/webconsole/lib/view/javascript.rb

Instance Method Summary collapse

Instance Method Details

#is_float?Boolean

Returns:

  • (Boolean)


107
108
109
# File 'lib/webconsole/lib/module.rb', line 107

def is_float?
  true if Float(self) rescue false
end

#is_integer?Boolean

Returns:

  • (Boolean)


111
112
113
# File 'lib/webconsole/lib/module.rb', line 111

def is_integer?
  self.to_i.to_s == self
end

#javascript_argumentObject



31
32
33
# File 'lib/webconsole/lib/view/javascript.rb', line 31

def javascript_argument
  "'#{self.javascript_escape}'"
end

#javascript_escapeObject



35
36
37
# File 'lib/webconsole/lib/view/javascript.rb', line 35

def javascript_escape
  self.gsub('\\', "\\\\\\\\").gsub("\n", "\\\\n").gsub("'", "\\\\'")
end

#javascript_escape!Object



39
40
41
# File 'lib/webconsole/lib/view/javascript.rb', line 39

def javascript_escape!
  replace(self.javascript_escape)
end

#shell_escapeObject



115
116
117
# File 'lib/webconsole/lib/module.rb', line 115

def shell_escape
  Shellwords.escape(self)
end

#shell_escape!Object



119
120
121
# File 'lib/webconsole/lib/module.rb', line 119

def shell_escape!
  replace(shell_escape)
end