Results for: "uniq!"

Removes duplicate elements from self, the first occurrence always being retained; returns self if any elements removed, nil otherwise.

With no block given, identifies and removes elements using method eql? to compare.

Returns self if any elements removed:

a = [0, 0, 1, 1, 2, 2]
a.uniq! # => [0, 1, 2]

Returns nil if no elements removed.

With a block given, calls the block for each element; identifies (using method eql?) and removes elements for which the block returns duplicate values.

Returns self if any elements removed:

a = ['a', 'aa', 'aaa', 'b', 'bb', 'bbb']
a.uniq! {|element| element.size } # => ['a', 'aa', 'aaa']

Returns nil if no elements removed.

UNIXServer represents a UNIX domain stream server socket.

UNIXSocket represents a UNIX domain stream client socket.

Ruby supports two forms of objectified methods. Class Method is used to represent methods that are associated with a particular object: these method objects are bound to that object. Bound method objects for an object can be created using Object#method.

Ruby also supports unbound methods; methods objects that are not associated with a particular object. These can be created either by calling Module#instance_method or by calling unbind on a bound method object. The result of both of these is an UnboundMethod object.

Unbound methods can only be called after they are bound to an object. That object must be a kind_of? the method’s original class.

class Square
  def area
    @side * @side
  def initialize(side)
    @side = side

area_un = Square.instance_method(:area)

s =
area = area_un.bind(s)   #=> 144

Unbound methods are a reference to the method at the time it was objectified: subsequent changes to the underlying class will not affect the unbound method.

class Test
  def test
um = Test.instance_method(:test)
class Test
  def test
t =
t.test            #=> :modified
um.bind(t).call   #=> :original

define UnicodeNormalize module here so that we don’t have to look it up

A base class for objects representing a C union

A pointer to a C union

This exception is raised if the required unicode support is missing on the system. Usually this means that the iconv library is not installed.

Implements DRb over a UNIX socket

DRb UNIX socket URIs look like drbunix:<path>?<option>. The option is optional.

No documentation available

Raised when removing a gem with the uninstall command fails

An Uninstaller.

The uninstaller fires pre and post uninstall hooks. Hooks can be added either through a rubygems_plugin.rb file in an installed gem or via a rubygems/defaults/#{RUBY_ENGINE}.rb or rubygems/defaults/operating_system.rb file. See Gem.pre_uninstall and Gem.post_uninstall for details.

Helper methods for both Gem::Installer and Gem::Uninstaller

The class of the singleton object nil.

Several of its methods act as operators:

Others act as converters, carrying the concept of nullity to other classes:

Another method provides inspection:

Finally, there is this query method:

A generic error class raised when an invalid operation is attempted. Kernel#raise will raise a RuntimeError if no Exception class is specified.

raise "ouch"

raises the exception:

RuntimeError: ouch

Use the Monitor class when you want to have a lock object for blocks with mutual exclusion.

require 'monitor'

lock =
lock.synchronize do
  # exclusive access

Raised when OLE processing failed.


obj ="NonExistProgID")

raises the exception:

WIN32OLERuntimeError: unknown OLE server: `NonExistProgID'
    HRESULT error code:0x800401f3
      Invalid class string

Raised when throw is called with a tag which does not have corresponding catch block.

throw "foo", "bar"

raises the exception:

UncaughtThrowError: uncaught throw "foo"

The Warning module contains a single method named warn, and the module extends itself, making Warning.warn available. Warning.warn is called for all warnings issued by Ruby. By default, warnings are printed to $stderr.

Changing the behavior of Warning.warn is useful to customize how warnings are handled by Ruby, for instance by filtering some warnings, and/or outputting warnings somewhere other than $stderr.

If you want to change the behavior of Warning.warn you should use Warning.extend(MyNewModuleWithWarnMethod) and you can use super to get the default behavior of printing the warning to $stderr.


module MyWarningFilter
  def warn(message, category: nil, **kwargs)
    if /some warning I want to ignore/.match?(message)
      # ignore
Warning.extend MyWarningFilter

You should never redefine Warning#warn (the instance method), as that will then no longer provide a way to use the default behavior.

The warning gem provides convenient ways to customize Warning.warn.

In concurrent programming, a monitor is an object or module intended to be used safely by more than one thread. The defining characteristic of a monitor is that its methods are executed with mutual exclusion. That is, at each point in time, at most one thread may be executing any of its methods. This mutual exclusion greatly simplifies reasoning about the implementation of monitors compared to reasoning about parallel code that updates a data structure.

You can read more about the general principles on the Wikipedia page for Monitors.


Simple object.extend

require 'monitor.rb'

buf = []
empty_cond = buf.new_cond

# consumer
Thread.start do
  loop do
    buf.synchronize do
      empty_cond.wait_while { buf.empty? }
      print buf.shift

# producer
while line = ARGF.gets
  buf.synchronize do

The consumer thread waits for the producer thread to push a line to buf while buf.empty?. The producer thread (main thread) reads a line from ARGF and pushes it into buf then calls empty_cond.signal to notify the consumer thread of new data.

Simple Class include

require 'monitor'

class SynchronizedArray < Array

  include MonitorMixin

  def initialize(*args)

  alias :old_shift :shift
  alias :old_unshift :unshift

  def shift(n=1)
    self.synchronize do

  def unshift(item)
    self.synchronize do

  # other methods ...

SynchronizedArray implements an Array with synchronized access to items. This Class is implemented as subclass of Array which includes the MonitorMixin module.

Gem uninstaller command line tool

See ‘gem help uninstall`


A representation of a C function



@libc = Fiddle.dlopen "/lib/"
   #=> #<Fiddle::Handle:0x00000001d7a8d8>
f =
  [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP],
   #=> #<Fiddle::Function:0x00000001d8ee00>
buff = "000"
   #=> "000"
str =, "123")
   #=> #<Fiddle::Pointer:0x00000001d0c380 ptr=0x000000018a21b8 size=0 free=0x00000000000000>
=> "123"

ABI check

@libc = Fiddle.dlopen "/lib/"
   #=> #<Fiddle::Handle:0x00000001d7a8d8>
   #=> #<Fiddle::Function:0x00000001d8ee00>
f.abi == Fiddle::Function::DEFAULT
   #=> true

Error raised by the DRb module when an attempt is made to refer to the context’s current drb server but the context does not have one. See current_server.

An exception wrapping a DRb::DRbUnknown object

Class wrapping a marshalled object whose type is unknown locally.

If an object is returned by a method invoked over drb, but the class of the object is unknown in the client namespace, or the object is a constant unknown in the client namespace, then the still-marshalled object is returned wrapped in a DRbUnknown instance.

If this object is passed as an argument to a method invoked over drb, then the wrapped object is passed instead.

The class or constant name of the object can be read from the name attribute. The marshalled object is held in the buf attribute.

Search took: 4ms  ·  Total Results: 462