$99 GRAYBYTE WORDPRESS FILE MANAGER $77

SERVER : premium201.web-hosting.com #1 SMP Wed Mar 26 12:08:09 UTC 2025
SERVER IP : 104.21.43.35 | ADMIN IP 216.73.216.23
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/opt/alt/ruby21/lib64/ruby/2.1.0/

HOME
Current File : /opt/alt/ruby21/lib64/ruby/2.1.0//forwardable.rb
#
#   forwardable.rb -
#       $Release Version: 1.1$
#       $Revision: 40906 $
#       by Keiju ISHITSUKA([email protected])
#       original definition by delegator.rb
#       Revised by Daniel J. Berger with suggestions from Florian Gross.
#
#       Documentation by James Edward Gray II and Gavin Sinclair



# The Forwardable module provides delegation of specified
# methods to a designated object, using the methods #def_delegator
# and #def_delegators.
#
# For example, say you have a class RecordCollection which
# contains an array <tt>@records</tt>.  You could provide the lookup method
# #record_number(), which simply calls #[] on the <tt>@records</tt>
# array, like this:
#
#   require 'forwardable'
#
#   class RecordCollection
#     attr_accessor :records
#     extend Forwardable
#     def_delegator :@records, :[], :record_number
#   end
#
# We can use the lookup method like so:
#
#   r = RecordCollection.new
#   r.records = [4,5,6]
#   r.record_number(0)  # => 4
#
# Further, if you wish to provide the methods #size, #<<, and #map,
# all of which delegate to @records, this is how you can do it:
#
#   class RecordCollection # re-open RecordCollection class
#     def_delegators :@records, :size, :<<, :map
#   end
#
#   r = RecordCollection.new
#   r.records = [1,2,3]
#   r.record_number(0)   # => 1
#   r.size               # => 3
#   r << 4               # => [1, 2, 3, 4]
#   r.map { |x| x * 2 }  # => [2, 4, 6, 8]
#
# You can even extend regular objects with Forwardable.
#
#   my_hash = Hash.new
#   my_hash.extend Forwardable              # prepare object for delegation
#   my_hash.def_delegator "STDOUT", "puts"  # add delegation for STDOUT.puts()
#   my_hash.puts "Howdy!"
#
# == Another example
#
# We want to rely on what has come before obviously, but with delegation we can
# take just the methods we need and even rename them as appropriate.  In many
# cases this is preferable to inheritance, which gives us the entire old
# interface, even if much of it isn't needed.
#
#   class Queue
#     extend Forwardable
#
#     def initialize
#       @q = [ ]    # prepare delegate object
#     end
#
#     # setup preferred interface, enq() and deq()...
#     def_delegator :@q, :push, :enq
#     def_delegator :@q, :shift, :deq
#
#     # support some general Array methods that fit Queues well
#     def_delegators :@q, :clear, :first, :push, :shift, :size
#   end
#
#   q = Queue.new
#   q.enq 1, 2, 3, 4, 5
#   q.push 6
#
#   q.shift    # => 1
#   while q.size > 0
#     puts q.deq
#   end
#
#   q.enq "Ruby", "Perl", "Python"
#   puts q.first
#   q.clear
#   puts q.first
#
# This should output:
#
#   2
#   3
#   4
#   5
#   6
#   Ruby
#   nil
#
# == Notes
#
# Be advised, RDoc will not detect delegated methods.
#
# +forwardable.rb+ provides single-method delegation via the def_delegator and
# def_delegators methods. For full-class delegation via DelegateClass, see
# +delegate.rb+.
#
module Forwardable
  # Version of +forwardable.rb+
  FORWARDABLE_VERSION = "1.1.0"

  FILE_REGEXP = %r"#{Regexp.quote(__FILE__)}"

  @debug = nil
  class << self
    # If true, <tt>__FILE__</tt> will remain in the backtrace in the event an
    # Exception is raised.
    attr_accessor :debug
  end

  # 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.
  #
  # :call-seq:
  #    delegate method => accessor
  #    delegate [method, method, ...] => accessor
  #
  def instance_delegate(hash)
    hash.each{ |methods, accessor|
      methods = [methods] unless methods.respond_to?(:each)
      methods.each{ |method|
        def_instance_delegator(accessor, method)
      }
    }
  end

  #
  # Shortcut for defining multiple delegator methods, but with no
  # provision for using a different name.  The following two code
  # samples have the same effect:
  #
  #   def_delegators :@records, :size, :<<, :map
  #
  #   def_delegator :@records, :size
  #   def_delegator :@records, :<<
  #   def_delegator :@records, :map
  #
  def def_instance_delegators(accessor, *methods)
    methods.delete("__send__")
    methods.delete("__id__")
    for method in methods
      def_instance_delegator(accessor, method)
    end
  end

  # Define +method+ as delegator instance method with an optional
  # alias name +ali+. Method calls to +ali+ will be delegated to
  # +accessor.method+.
  #
  #   class MyQueue
  #     extend Forwardable
  #     attr_reader :queue
  #     def initialize
  #       @queue = []
  #     end
  #
  #     def_delegator :@queue, :push, :mypush
  #   end
  #
  #   q = MyQueue.new
  #   q.mypush 42
  #   q.queue    #=> [42]
  #   q.push 23  #=> NoMethodError
  #
  def def_instance_delegator(accessor, method, ali = method)
    line_no = __LINE__; str = %{
      def #{ali}(*args, &block)
        begin
          #{accessor}.__send__(:#{method}, *args, &block)
        rescue Exception
          [email protected]_if{|s| Forwardable::FILE_REGEXP =~ s} unless Forwardable::debug
          ::Kernel::raise
        end
      end
    }
    # If it's not a class or module, it's an instance
    begin
      module_eval(str, __FILE__, line_no)
    rescue
      instance_eval(str, __FILE__, line_no)
    end

  end

  alias delegate instance_delegate
  alias def_delegators def_instance_delegators
  alias def_delegator def_instance_delegator
end

# SingleForwardable can be used to setup delegation at the object level as well.
#
#    printer = String.new
#    printer.extend SingleForwardable        # prepare object for delegation
#    printer.def_delegator "STDOUT", "puts"  # add delegation for STDOUT.puts()
#    printer.puts "Howdy!"
#
# Also, SingleForwardable can be used to set up delegation for a Class or Module.
#
#   class Implementation
#     def self.service
#       puts "serviced!"
#     end
#   end
#
#   module Facade
#     extend SingleForwardable
#     def_delegator :Implementation, :service
#   end
#
#   Facade.service #=> serviced!
#
# If you want to use both Forwardable and SingleForwardable, you can
# use methods def_instance_delegator and def_single_delegator, etc.
module SingleForwardable
  # 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.
  #
  # :call-seq:
  #    delegate method => accessor
  #    delegate [method, method, ...] => accessor
  #
  def single_delegate(hash)
    hash.each{ |methods, accessor|
      methods = [methods] unless methods.respond_to?(:each)
      methods.each{ |method|
        def_single_delegator(accessor, method)
      }
    }
  end

  #
  # Shortcut for defining multiple delegator methods, but with no
  # provision for using a different name.  The following two code
  # samples have the same effect:
  #
  #   def_delegators :@records, :size, :<<, :map
  #
  #   def_delegator :@records, :size
  #   def_delegator :@records, :<<
  #   def_delegator :@records, :map
  #
  def def_single_delegators(accessor, *methods)
    methods.delete("__send__")
    methods.delete("__id__")
    for method in methods
      def_single_delegator(accessor, method)
    end
  end

  # :call-seq:
  #   def_single_delegator(accessor, method, new_name=method)
  #
  # Defines a method _method_ which delegates to _accessor_ (i.e. it calls
  # the method of the same name in _accessor_).  If _new_name_ is
  # provided, it is used as the name for the delegate method.
  def def_single_delegator(accessor, method, ali = method)
    str = %{
      def #{ali}(*args, &block)
        begin
          #{accessor}.__send__(:#{method}, *args, &block)
        rescue Exception
          [email protected]_if{|s| Forwardable::FILE_REGEXP =~ s} unless Forwardable::debug
          ::Kernel::raise
        end
      end
    }

    instance_eval(str, __FILE__, __LINE__)
  end

  alias delegate single_delegate
  alias def_delegators def_single_delegators
  alias def_delegator def_single_delegator
end


Current_dir [ NOT WRITEABLE ] Document_root [ NOT WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
3 Mar 2024 10.43 PM
root / root
0755
cgi
--
3 Mar 2024 10.43 PM
root / linksafe
0755
date
--
3 Mar 2024 10.43 PM
root / linksafe
0755
digest
--
3 Mar 2024 10.43 PM
root / linksafe
0755
dl
--
3 Mar 2024 10.43 PM
root / linksafe
0755
drb
--
3 Mar 2024 10.43 PM
root / linksafe
0755
fiddle
--
3 Mar 2024 10.43 PM
root / linksafe
0755
io
--
3 Mar 2024 10.43 PM
root / linksafe
0755
irb
--
3 Mar 2024 10.43 PM
root / linksafe
0755
json
--
3 Mar 2024 10.43 PM
root / linksafe
0755
matrix
--
3 Mar 2024 10.43 PM
root / linksafe
0755
net
--
3 Mar 2024 10.43 PM
root / linksafe
0755
openssl
--
3 Mar 2024 10.43 PM
root / linksafe
0755
optparse
--
3 Mar 2024 10.43 PM
root / linksafe
0755
psych
--
3 Mar 2024 10.43 PM
root / linksafe
0755
racc
--
3 Mar 2024 10.43 PM
root / linksafe
0755
rake
--
3 Mar 2024 10.53 PM
root / linksafe
0755
rbconfig
--
3 Mar 2024 10.43 PM
root / linksafe
0755
rdoc
--
3 Mar 2024 10.43 PM
root / linksafe
0755
rexml
--
3 Mar 2024 10.43 PM
root / linksafe
0755
rinda
--
3 Mar 2024 10.43 PM
root / linksafe
0755
ripper
--
3 Mar 2024 10.43 PM
root / linksafe
0755
rss
--
3 Mar 2024 10.43 PM
root / linksafe
0755
rubygems
--
3 Mar 2024 10.43 PM
root / linksafe
0755
shell
--
3 Mar 2024 10.43 PM
root / linksafe
0755
syslog
--
3 Mar 2024 10.43 PM
root / root
0755
test
--
3 Mar 2024 10.43 PM
root / linksafe
0755
uri
--
3 Mar 2024 10.43 PM
root / linksafe
0755
webrick
--
3 Mar 2024 10.43 PM
root / linksafe
0755
x86_64-linux
--
3 Mar 2024 10.43 PM
root / root
0755
xmlrpc
--
3 Mar 2024 10.43 PM
root / linksafe
0755
yaml
--
3 Mar 2024 10.43 PM
root / linksafe
0755
English.rb
6.443 KB
4 Feb 2013 2.50 AM
root / linksafe
0644
abbrev.rb
3.313 KB
21 Feb 2013 5.35 PM
root / linksafe
0644
base64.rb
2.631 KB
19 May 2013 3.10 AM
root / linksafe
0644
benchmark.rb
17.952 KB
20 Sep 2013 4.05 PM
root / linksafe
0644
cgi.rb
9.841 KB
18 Jul 2013 1.50 PM
root / linksafe
0644
cmath.rb
8.927 KB
3 Jul 2015 9.12 AM
root / linksafe
0644
complex.rb
0.371 KB
16 Aug 2009 3.34 PM
root / linksafe
0644
csv.rb
81.682 KB
14 Sep 2014 3.25 PM
root / linksafe
0644
date.rb
0.924 KB
26 Jul 2023 2.22 PM
root / linksafe
0644
debug.rb
29.077 KB
14 Dec 2013 2.48 PM
root / linksafe
0644
delegate.rb
11.125 KB
2 Feb 2014 1.46 PM
root / linksafe
0644
digest.rb
2.338 KB
26 Jul 2023 2.22 PM
root / linksafe
0644
dl.rb
0.273 KB
26 Jul 2023 2.22 PM
root / linksafe
0644
drb.rb
0.019 KB
2 Oct 2009 10.45 AM
root / linksafe
0644
e2mmap.rb
3.891 KB
17 Dec 2013 11.20 AM
root / linksafe
0644
erb.rb
26.073 KB
11 Aug 2014 2.55 PM
root / linksafe
0644
expect.rb
2.144 KB
26 Jul 2023 2.22 PM
root / linksafe
0644
fiddle.rb
1.652 KB
26 Jul 2023 2.22 PM
root / linksafe
0644
fileutils.rb
47.171 KB
28 Apr 2015 5.16 AM
root / linksafe
0644
find.rb
2.359 KB
15 Oct 2014 3.31 PM
root / linksafe
0644
forwardable.rb
7.863 KB
23 May 2013 9.46 PM
root / linksafe
0644
getoptlong.rb
15.381 KB
19 May 2013 2.50 PM
root / linksafe
0644
gserver.rb
8.856 KB
6 Jul 2014 1.57 PM
root / linksafe
0644
ipaddr.rb
17.051 KB
29 Oct 2015 2.36 PM
root / linksafe
0644
irb.rb
20.034 KB
25 Mar 2016 8.22 AM
root / linksafe
0644
json.rb
1.737 KB
26 Jul 2023 2.22 PM
root / linksafe
0644
kconv.rb
5.737 KB
26 Jul 2023 2.22 PM
root / linksafe
0644
logger.rb
22.371 KB
25 Feb 2016 11.04 AM
root / linksafe
0644
mathn.rb
6.524 KB
26 Aug 2011 10.22 PM
root / linksafe
0644
matrix.rb
45.432 KB
11 Jul 2014 2.08 PM
root / linksafe
0644
mkmf.rb
80.503 KB
26 Jul 2023 2.19 PM
root / linksafe
0644
monitor.rb
6.935 KB
16 Nov 2012 4.55 PM
root / linksafe
0644
mutex_m.rb
2.002 KB
20 Feb 2013 2.51 AM
root / linksafe
0644
observer.rb
5.807 KB
21 Nov 2013 4.44 AM
root / linksafe
0644
open-uri.rb
24.268 KB
22 Feb 2014 8.54 AM
root / linksafe
0644
open3.rb
20.366 KB
1 Dec 2013 3.13 AM
root / linksafe
0644
openssl.rb
0.516 KB
26 Jul 2023 2.22 PM
root / linksafe
0644
optparse.rb
50.796 KB
28 Nov 2013 7.34 AM
root / linksafe
0644
ostruct.rb
7.702 KB
23 Oct 2013 3.14 PM
root / linksafe
0644
pathname.rb
15.297 KB
26 Jul 2023 2.22 PM
root / linksafe
0644
pp.rb
14.097 KB
22 Oct 2013 9.29 AM
root / linksafe
0644
prettyprint.rb
16.331 KB
19 May 2013 3.10 AM
root / linksafe
0644
prime.rb
13.203 KB
15 Jul 2013 4.21 AM
root / linksafe
0644
profile.rb
0.2 KB
2 Oct 2009 10.45 AM
root / linksafe
0644
profiler.rb
4.509 KB
19 May 2013 11.04 PM
root / linksafe
0644
pstore.rb
14.849 KB
11 Nov 2012 4.23 AM
root / linksafe
0644
psych.rb
14.878 KB
26 Jul 2023 2.22 PM
root / linksafe
0644
rake.rb
2.116 KB
11 Oct 2013 9.35 PM
root / linksafe
0644
rational.rb
0.301 KB
24 Sep 2009 12.42 AM
root / linksafe
0644
rdoc.rb
4.921 KB
22 Dec 2013 10.25 AM
root / linksafe
0644
resolv-replace.rb
1.732 KB
11 Mar 2013 1.47 PM
root / linksafe
0644
resolv.rb
72.308 KB
13 May 2015 5.33 AM
root / linksafe
0644
ripper.rb
2.525 KB
26 Jul 2023 2.22 PM
root / linksafe
0644
rss.rb
2.841 KB
11 May 2011 10.22 AM
root / linksafe
0644
rubygems.rb
30.974 KB
26 Jul 2023 2.19 PM
root / linksafe
0644
scanf.rb
23.542 KB
14 Dec 2013 2.55 AM
root / linksafe
0644
securerandom.rb
8.49 KB
7 Nov 2013 6.04 PM
root / linksafe
0644
set.rb
18.704 KB
22 Nov 2013 11.50 PM
root / linksafe
0644
shell.rb
10.299 KB
19 May 2013 3.10 AM
root / linksafe
0644
shellwords.rb
5.941 KB
14 Dec 2013 6.26 PM
root / linksafe
0644
singleton.rb
4.018 KB
18 May 2011 2.09 PM
root / linksafe
0644
socket.rb
25.596 KB
26 Jul 2023 2.22 PM
root / linksafe
0644
sync.rb
7.255 KB
19 May 2013 3.10 AM
root / linksafe
0644
tempfile.rb
11.398 KB
21 Nov 2013 9.28 AM
root / linksafe
0644
thwait.rb
3.377 KB
7 Nov 2013 5.02 PM
root / linksafe
0644
time.rb
21.316 KB
17 Aug 2015 7.41 AM
root / linksafe
0644
timeout.rb
3.697 KB
17 Aug 2015 7.55 AM
root / linksafe
0644
tmpdir.rb
4.149 KB
19 May 2013 3.10 AM
root / linksafe
0644
tracer.rb
6.402 KB
18 Jul 2013 1.50 PM
root / linksafe
0644
tsort.rb
14.145 KB
17 Oct 2013 3.59 PM
root / linksafe
0644
ubygems.rb
0.262 KB
2 Oct 2009 10.45 AM
root / linksafe
0644
un.rb
8.873 KB
5 Jul 2013 1.43 PM
root / linksafe
0644
uri.rb
3.07 KB
13 May 2011 8.03 PM
root / linksafe
0644
weakref.rb
3.229 KB
9 Nov 2013 10.42 PM
root / linksafe
0644
webrick.rb
6.689 KB
5 Oct 2013 11.39 PM
root / linksafe
0644
xmlrpc.rb
8.488 KB
12 Dec 2013 3.09 AM
root / linksafe
0644
yaml.rb
2.313 KB
12 Aug 2013 3.49 AM
root / linksafe
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025 CONTACT ME
Static GIF