[フレーム]

Class: String

Inherits:
Object show all
Defined in:
opal/stdlib/pp.rb,
opal/stdlib/json.rb,
opal/stdlib/native.rb,
opal/stdlib/bigdecimal/util.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#pretty_print(q) ⇒ Object

:nodoc:

399
400
401
402
403
404
405
406
407
408
409
410
# File 'opal/stdlib/pp.rb', line 399
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

#to_dObject

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_jsonObject

189
190
191
# File 'opal/stdlib/json.rb', line 189
def to_json
 `JSON.stringify(self)`
end

#to_nObject

Returns the internal JavaScript value (with valueOf).

Returns:

  • the internal JavaScript value (with valueOf).

461
462
463
# File 'opal/stdlib/native.rb', line 461
def to_n
 `self.valueOf()`
end

AltStyle によって変換されたページ (->オリジナル) /