Class: String
- Defined in:
- opal/stdlib/pp.rb,
opal/stdlib/json.rb,
opal/stdlib/native.rb,
opal/stdlib/shellwords.rb,
opal/stdlib/bigdecimal/util.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#pretty_print(q) ⇒ Object
:nodoc:.
-
#shellescape ⇒ Object
call-seq: str.shellescape => string.
-
#shellsplit ⇒ Object
call-seq: str.shellsplit => array.
-
#to_d ⇒ Object
call-seq: str.to_d -> bigdecimal.
- #to_json ⇒ Object
-
#to_n ⇒ Object
The internal JavaScript value (with
valueOf
).
Instance Method Details
#pretty_print(q) ⇒ Object
:nodoc:
415 416 417 418 419 420 421 422 423 424 425 426 |
# File 'opal/stdlib/pp.rb', line 415 def pretty_print(q) # :nodoc: lines = self.lines if lines.size > 1 q.group(0, '', '') do q.seplist(lines, lambda { q.text ' +'; q.breakable }) do |v| q.pp v end end else q.text inspect end end |
#shellescape ⇒ Object
call-seq: str.shellescape => string
Escapes +str+ so that it can be safely used in a Bourne shell command line.
See Shellwords.shellescape for details.
224 225 226 |
# File 'opal/stdlib/shellwords.rb', line 224 def shellescape Shellwords.escape(self) end |
#shellsplit ⇒ Object
call-seq: str.shellsplit => array
Splits +str+ into an array of tokens in the same way the UNIX Bourne shell does.
See Shellwords.shellsplit for details.
213 214 215 |
# File 'opal/stdlib/shellwords.rb', line 213 def shellsplit Shellwords.split(self) end |
#to_d ⇒ Object
call-seq: str.to_d -> bigdecimal
Returns the result of interpreting leading characters in +str+ as a BigDecimal.
require 'bigdecimal'
require 'bigdecimal/util'
"0.5".to_d # => 0.5e0
"123.45e1".to_d # => 0.12345e4
"45.67 degrees".to_d # => 0.4567e2
See also BigDecimal::new.
68 69 70 |
# File 'opal/stdlib/bigdecimal/util.rb', line 68 def to_d BigDecimal(`#{self}.replace("_", '').replace(/ .*$/,'')`) end |
#to_json ⇒ Object
189 190 191 |
# File 'opal/stdlib/json.rb', line 189 def to_json `JSON.stringify(self)` end |
#to_n ⇒ Object
Returns the internal JavaScript value (with valueOf
).
460 461 462 |
# File 'opal/stdlib/native.rb', line 460 def to_n `self.valueOf()` end |