X7ROOT File Manager
Current Path:
/opt/alt/ruby23/lib64/ruby/2.3.0
opt
/
alt
/
ruby23
/
lib64
/
ruby
/
2.3.0
/
ðŸ“
..
📄
English.rb
(6.45 KB)
📄
abbrev.rb
(3.49 KB)
📄
base64.rb
(3.31 KB)
📄
benchmark.rb
(17.9 KB)
ðŸ“
cgi
📄
cgi.rb
(9.8 KB)
📄
cmath.rb
(9.48 KB)
📄
csv.rb
(82.15 KB)
📄
date.rb
(1011 B)
📄
debug.rb
(29.97 KB)
📄
delegate.rb
(10.29 KB)
ðŸ“
digest
📄
digest.rb
(2.82 KB)
ðŸ“
drb
📄
drb.rb
(50 B)
📄
e2mmap.rb
(3.8 KB)
📄
erb.rb
(26.45 KB)
📄
expect.rb
(2.17 KB)
ðŸ“
fiddle
📄
fiddle.rb
(1.68 KB)
📄
fileutils.rb
(47.47 KB)
📄
find.rb
(2.51 KB)
📄
forwardable.rb
(7.97 KB)
📄
getoptlong.rb
(15.41 KB)
ðŸ“
io
📄
ipaddr.rb
(17.08 KB)
ðŸ“
irb
📄
irb.rb
(20.06 KB)
ðŸ“
json
📄
json.rb
(1.77 KB)
📄
kconv.rb
(5.77 KB)
📄
logger.rb
(21.93 KB)
📄
mathn.rb
(3.87 KB)
ðŸ“
matrix
📄
matrix.rb
(53.37 KB)
📄
mkmf.rb
(83.79 KB)
📄
monitor.rb
(7.01 KB)
📄
mutex_m.rb
(2.03 KB)
ðŸ“
net
📄
observer.rb
(5.83 KB)
📄
open-uri.rb
(24.61 KB)
📄
open3.rb
(20.67 KB)
ðŸ“
openssl
📄
openssl.rb
(445 B)
📄
optionparser.rb
(59 B)
ðŸ“
optparse
📄
optparse.rb
(56.91 KB)
📄
ostruct.rb
(9.95 KB)
📄
pathname.rb
(16.08 KB)
📄
pp.rb
(14.2 KB)
📄
prettyprint.rb
(15.89 KB)
📄
prime.rb
(12.35 KB)
📄
profile.rb
(236 B)
📄
profiler.rb
(4.54 KB)
📄
pstore.rb
(14.58 KB)
ðŸ“
psych
📄
psych.rb
(15.29 KB)
📄
psych_jars.rb
(175 B)
ðŸ“
racc
ðŸ“
rbconfig
ðŸ“
rdoc
📄
rdoc.rb
(5.07 KB)
📄
resolv-replace.rb
(1.76 KB)
📄
resolv.rb
(73.52 KB)
ðŸ“
rexml
ðŸ“
rinda
ðŸ“
ripper
📄
ripper.rb
(2.56 KB)
ðŸ“
rss
📄
rss.rb
(2.87 KB)
ðŸ“
rubygems
📄
rubygems.rb
(32.24 KB)
📄
scanf.rb
(23.56 KB)
📄
securerandom.rb
(7.49 KB)
📄
set.rb
(19.67 KB)
ðŸ“
shell
📄
shell.rb
(11.33 KB)
📄
shellwords.rb
(6.28 KB)
📄
singleton.rb
(4.05 KB)
📄
socket.rb
(43.49 KB)
📄
sync.rb
(7.29 KB)
ðŸ“
syslog
📄
tempfile.rb
(10.87 KB)
📄
thwait.rb
(3.34 KB)
📄
time.rb
(22.28 KB)
📄
timeout.rb
(3.68 KB)
📄
tmpdir.rb
(4.17 KB)
📄
tracer.rb
(6.43 KB)
📄
tsort.rb
(14.3 KB)
📄
ubygems.rb
(299 B)
📄
un.rb
(8.87 KB)
ðŸ“
unicode_normalize
📄
unicode_normalize.rb
(3.19 KB)
ðŸ“
uri
📄
uri.rb
(3.1 KB)
📄
weakref.rb
(2.95 KB)
ðŸ“
webrick
📄
webrick.rb
(6.72 KB)
ðŸ“
x86_64-linux
ðŸ“
xmlrpc
📄
xmlrpc.rb
(8.93 KB)
ðŸ“
yaml
📄
yaml.rb
(1.73 KB)
Editing: singleton.rb
# frozen_string_literal: false require 'thread' # The Singleton module implements the Singleton pattern. # # == Usage # # To use Singleton, include the module in your class. # # class Klass # include Singleton # # ... # end # # This ensures that only one instance of Klass can be created. # # a,b = Klass.instance, Klass.instance # # a == b # # => true # # Klass.new # # => NoMethodError - new is private ... # # The instance is created at upon the first call of Klass.instance(). # # class OtherKlass # include Singleton # # ... # end # # ObjectSpace.each_object(OtherKlass){} # # => 0 # # OtherKlass.instance # ObjectSpace.each_object(OtherKlass){} # # => 1 # # # This behavior is preserved under inheritance and cloning. # # == Implementation # # This above is achieved by: # # * Making Klass.new and Klass.allocate private. # # * Overriding Klass.inherited(sub_klass) and Klass.clone() to ensure that the # Singleton properties are kept when inherited and cloned. # # * Providing the Klass.instance() method that returns the same object each # time it is called. # # * Overriding Klass._load(str) to call Klass.instance(). # # * Overriding Klass#clone and Klass#dup to raise TypeErrors to prevent # cloning or duping. # # == Singleton and Marshal # # By default Singleton's #_dump(depth) returns the empty string. Marshalling by # default will strip state information, e.g. instance variables and taint # state, from the instance. Classes using Singleton can provide custom # _load(str) and _dump(depth) methods to retain some of the previous state of # the instance. # # require 'singleton' # # class Example # include Singleton # attr_accessor :keep, :strip # def _dump(depth) # # this strips the @strip information from the instance # Marshal.dump(@keep, depth) # end # # def self._load(str) # instance.keep = Marshal.load(str) # instance # end # end # # a = Example.instance # a.keep = "keep this" # a.strip = "get rid of this" # a.taint # # stored_state = Marshal.dump(a) # # a.keep = nil # a.strip = nil # b = Marshal.load(stored_state) # p a == b # => true # p a.keep # => "keep this" # p a.strip # => nil # module Singleton # Raises a TypeError to prevent cloning. def clone raise TypeError, "can't clone instance of singleton #{self.class}" end # Raises a TypeError to prevent duping. def dup raise TypeError, "can't dup instance of singleton #{self.class}" end # By default, do not retain any state when marshalling. def _dump(depth = -1) '' end module SingletonClassMethods # :nodoc: def clone # :nodoc: Singleton.__init__(super) end # By default calls instance(). Override to retain singleton state. def _load(str) instance end private def inherited(sub_klass) super Singleton.__init__(sub_klass) end end class << Singleton # :nodoc: def __init__(klass) # :nodoc: klass.instance_eval { @singleton__instance__ = nil @singleton__mutex__ = Mutex.new } def klass.instance # :nodoc: return @singleton__instance__ if @singleton__instance__ @singleton__mutex__.synchronize { return @singleton__instance__ if @singleton__instance__ @singleton__instance__ = new() } @singleton__instance__ end klass end private # extending an object with Singleton is a bad idea undef_method :extend_object def append_features(mod) # help out people counting on transitive mixins unless mod.instance_of?(Class) raise TypeError, "Inclusion of the OO-Singleton module in module #{mod}" end super end def included(klass) super klass.private_class_method :new, :allocate klass.extend SingletonClassMethods Singleton.__init__(klass) end end ## # :singleton-method: _load # By default calls instance(). Override to retain singleton state. end
Upload File
Create Folder