Returns the values in self
as an array:
Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe.to_a # => ["Joe Smith", "123 Maple, Anytown NC", 12345]
Related: members
.
Like Symbol#<=>
, but case-insensitive; equivalent to self.to_s.casecmp(object.to_s)
:
lower = :abc upper = :ABC upper.casecmp(lower) # => 0 lower.casecmp(lower) # => 0 lower.casecmp(upper) # => 0
Returns nil if self
and object
have incompatible encodings, or if object
is not a symbol:
sym = 'äöü'.encode("ISO-8859-1").to_sym other_sym = 'ÄÖÜ' sym.casecmp(other_sym) # => nil :foo.casecmp(2) # => nil
Unlike Symbol#casecmp?
, case-insensitivity does not work for characters outside of ‘A’..‘Z’ and ‘a’..‘z’:
lower = :äöü upper = :ÄÖÜ upper.casecmp(lower) # => -1 lower.casecmp(lower) # => 0 lower.casecmp(upper) # => 1
Related: Symbol#casecmp?
, String#casecmp
.
Returns true
if self
and object
are equal after Unicode case folding, otherwise false
:
lower = :abc upper = :ABC upper.casecmp?(lower) # => true lower.casecmp?(lower) # => true lower.casecmp?(upper) # => true
Returns nil if self
and object
have incompatible encodings, or if object
is not a symbol:
sym = 'äöü'.encode("ISO-8859-1").to_sym other_sym = 'ÄÖÜ' sym.casecmp?(other_sym) # => nil :foo.casecmp?(2) # => nil
Unlike Symbol#casecmp
, works for characters outside of ‘A’..‘Z’ and ‘a’..‘z’:
lower = :äöü upper = :ÄÖÜ upper.casecmp?(lower) # => true lower.casecmp?(lower) # => true lower.casecmp?(upper) # => true
Related: Symbol#casecmp
, String#casecmp?
.
Returns true
if self
is :''
, false
otherwise.
Enters exclusive section.
Enters exclusive section and executes the block. Leaves the exclusive section automatically when the block exits. See example under MonitorMixin
.
The opposite of Pathname#absolute?
It returns false
if the pathname begins with a slash.
p = Pathname.new('/im/sure') p.relative? #=> false p = Pathname.new('not/so/sure') p.relative? #=> true
Creates a full path, including any intermediate directories that don’t yet exist.
See FileUtils.mkpath
and FileUtils.mkdir_p
Returns the real (absolute) pathname for self
in the actual filesystem.
Does not contain symlinks or useless dots, ..
and .
.
All components of the pathname must exist when this method is called.
Returns the real (absolute) pathname of self
in the actual filesystem.
Does not contain symlinks or useless dots, ..
and .
.
The last component of the real pathname can be nonexistent.
Returns the birth time for the file. If the platform doesn’t have birthtime, raises NotImplementedError
.
See File.birthtime
.
Returns the last change time, using directory information, not the file itself.
See File.ctime
.
Update the access and modification times of the file.
Same as Pathname#utime
, but does not follow symbolic links.
See File.lutime
.