Zlib::GzipReader
wrapper that unzips data
.
Return the best specification that contains the file matching path
, among those already activated.
Return the best specification in the record that contains the file matching path
, among those already activated.
Returns true
if the given year is a leap year in the proleptic Julian calendar, false
otherwise:
Date.julian_leap?(1900) # => true Date.julian_leap?(1901) # => false
Related: Date.gregorian_leap?
.
Returns the array of WIN32OLE::Method
object. The element is OLE method of WIN32OLE
object.
excel = WIN32OLE.new('Excel.Application') methods = excel.ole_methods
Returns WIN32OLE::Method
object corresponding with method specified by 1st argument.
excel = WIN32OLE.new('Excel.Application') method = excel.ole_method_help('Quit')
Returns the file extension appended to the names of backup copies of modified files under in-place edit mode. This value can be set using ARGF.inplace_mode=
or passing the -i
switch to the Ruby binary.
Sets the filename extension for in-place editing mode to the given String
. The backup copy of each file being edited has this value appended to its filename.
For example:
$ ruby argf.rb file.txt ARGF.inplace_mode = '.bak' ARGF.each_line do |line| print line.sub("foo","bar") end
First, file.txt.bak is created as a backup copy of file.txt. Then, each line of file.txt has the first occurrence of “foo” replaced with “bar”.
Turns FIPS mode on or off. Turning on FIPS mode will obviously only have an effect for FIPS-capable installations of the OpenSSL
library. Trying to do so otherwise will result in an error.
OpenSSL.fips_mode = true # turn FIPS mode on OpenSSL.fips_mode = false # and off again
The mode needed to read a file as straight binary.
Removes the file entry given by path
, which should be the entry for a regular file or a symbolic link.
Argument path
should be interpretable as a path.
Optional argument force
specifies whether to ignore raised exceptions of StandardError
and its descendants.
Related: methods for deleting.
Removes the file entry given by path
, which should be the entry for a regular file or a symbolic link.
Argument path
should be interpretable as a path.
Optional argument force
specifies whether to ignore raised exceptions of StandardError
and its descendants.
Related: methods for deleting.
Takes a hash as its argument. The key is a symbol or an array of symbols. These symbols correspond to method names. The value is the accessor to which the methods will be delegated.
Creates a stub Makefile.
Processes the data contents of the “depend” file. Each line of this file is expected to be a file name.
Returns the output of findings, in Makefile format.
Mirror the Prism.dump_file
API by using the serialization API.
Mirror the Prism.lex_file
API by using the serialization API.
If object
is an Array
object, returns object
.
Otherwise if object
responds to :to_ary
, calls object.to_ary
and returns the result.
Returns nil
if object
does not respond to :to_ary
Raises an exception unless object.to_ary
returns an Array
object.
Replaces the content of self
with the content of other_array
; returns self
:
a = [:foo, 'bar', 2] a.replace(['foo', :bar, 3]) # => ["foo", :bar, 3]
If object
is an Integer object, returns object
.
Integer.try_convert(1) # => 1
Otherwise if object
responds to :to_int
, calls object.to_int
and returns the result.
Integer.try_convert(1.25) # => 1
Returns nil
if object
does not respond to :to_int
Integer.try_convert([]) # => nil
Raises an exception unless object.to_int
returns an Integer object.
Methods Complex#as_json
and Complex.json_create
may be used to serialize and deserialize a Complex object; see Marshal
.
Method Complex#as_json
serializes self
, returning a 2-element hash representing self
:
require 'json/add/complex' x = Complex(2).as_json # => {"json_class"=>"Complex", "r"=>2, "i"=>0} y = Complex(2.0, 4).as_json # => {"json_class"=>"Complex", "r"=>2.0, "i"=>4}
Method JSON.create
deserializes such a hash, returning a Complex object:
Complex.json_create(x) # => (2+0i) Complex.json_create(y) # => (2.0+4i)
Returns a JSON
string representing self
:
require 'json/add/complex' puts Complex(2).to_json puts Complex(2.0, 4).to_json
Output:
{"json_class":"Complex","r":2,"i":0} {"json_class":"Complex","r":2.0,"i":4}