Results for: "Logger"

Pushes back bytes (passed as a parameter) onto ios, such that a subsequent buffered read will return it. It is only guaranteed to support a single byte, and only if ungetbyte or ungetc has not already been called on ios since the previous read of at least a single byte from ios. However, it can support additional bytes if there is space in the internal buffer to allow for it.

f = File.new("testfile")   #=> #<File:testfile>
b = f.getbyte              #=> 0x38
f.ungetbyte(b)             #=> nil
f.getbyte                  #=> 0x38

If given an integer, only uses the lower 8 bits of the integer as the byte to push.

f = File.new("testfile")   #=> #<File:testfile>
f.ungetbyte(0x102)         #=> nil
f.getbyte                  #=> 0x2

Calling this method prepends to the existing buffer, even if the method has already been called previously:

f = File.new("testfile")   #=> #<File:testfile>
f.ungetbyte("ab")          #=> nil
f.ungetbyte("cd")          #=> nil
f.read(5)                  #=> "cdab8"

Has no effect with unbuffered reads (such as IO#sysread).

Pushes back characters (passed as a parameter) onto ios, such that a subsequent buffered read will return it. It is only guaranteed to support a single byte, and only if ungetbyte or ungetc has not already been called on ios since the previous read of at least a single byte from ios. However, it can support additional bytes if there is space in the internal buffer to allow for it.

f = File.new("testfile")   #=> #<File:testfile>
c = f.getc                 #=> "8"
f.ungetc(c)                #=> nil
f.getc                     #=> "8"

If given an integer, the integer must represent a valid codepoint in the external encoding of ios.

Calling this method prepends to the existing buffer, even if the method has already been called previously:

f = File.new("testfile")   #=> #<File:testfile>
f.ungetc("ab")             #=> nil
f.ungetc("cd")             #=> nil
f.read(5)                  #=> "cdab8"

Has no effect with unbuffered reads (such as IO#sysread).

Closes ios and flushes any pending writes to the operating system. The stream is unavailable for any further data operations; an IOError is raised if such an attempt is made. I/O streams are automatically closed when they are claimed by the garbage collector.

If ios is opened by IO.popen, close sets $?.

Calling this method on closed IO object is just ignored since Ruby 2.3.

Returns true if ios is completely closed (for duplex streams, both reader and writer), false otherwise.

f = File.new("testfile")
f.close         #=> nil
f.closed?       #=> true
f = IO.popen("/bin/sh","r+")
f.close_write   #=> nil
f.closed?       #=> false
f.close_read    #=> nil
f.closed?       #=> true

Returns true if the underlying file descriptor of ios will be closed automatically at its finalization, otherwise false.

Sets auto-close flag.

f = open("/dev/null")
IO.for_fd(f.fileno)
# ...
f.gets # may cause Errno::EBADF

f = open("/dev/null")
IO.for_fd(f.fileno).autoclose = false
# ...
f.gets # won't cause Errno::EBADF

Returns true if object is an element of self, false otherwise:

(1..4).include?(2)        # => true
(1..4).include?(5)        # => false
(1..4).include?(4)        # => true
(1...4).include?(4)       # => false
('a'..'d').include?('b')  # => true
('a'..'d').include?('e')  # => false
('a'..'d').include?('B')  # => false
('a'..'d').include?('d')  # => true
('a'...'d').include?('d') # => false

If begin and end are numeric, include? behaves like cover?

(1..3).include?(1.5) # => true
(1..3).cover?(1.5) # => true

But when not numeric, the two methods may differ:

('a'..'d').include?('cc') # => false
('a'..'d').cover?('cc')   # => true

Related: Range#cover?.

Range#member? is an alias for Range#include?.

Returns true if the given argument is within self, false otherwise.

With non-range argument object, evaluates with <= and <.

For range self with included end value (#exclude_end? == false), evaluates thus:

self.begin <= object <= self.end

Examples:

r = (1..4)
r.cover?(1)     # => true
r.cover?(4)     # => true
r.cover?(0)     # => false
r.cover?(5)     # => false
r.cover?('foo') # => false

r = ('a'..'d')
r.cover?('a')     # => true
r.cover?('d')     # => true
r.cover?(' ')     # => false
r.cover?('e')     # => false
r.cover?(0)       # => false

For range r with excluded end value (#exclude_end? == true), evaluates thus:

r.begin <= object < r.end

Examples:

r = (1...4)
r.cover?(1)     # => true
r.cover?(3)     # => true
r.cover?(0)     # => false
r.cover?(4)     # => false
r.cover?('foo') # => false

r = ('a'...'d')
r.cover?('a')     # => true
r.cover?('c')     # => true
r.cover?(' ')     # => false
r.cover?('d')     # => false
r.cover?(0)       # => false

With range argument range, compares the first and last elements of self and range:

r = (1..4)
r.cover?(1..4)     # => true
r.cover?(0..4)     # => false
r.cover?(1..5)     # => false
r.cover?('a'..'d') # => false

r = (1...4)
r.cover?(1..3)     # => true
r.cover?(1..4)     # => false

If begin and end are numeric, cover? behaves like include?

(1..3).cover?(1.5) # => true
(1..3).include?(1.5) # => true

But when not numeric, the two methods may differ:

('a'..'d').cover?('cc')   # => true
('a'..'d').include?('cc') # => false

Returns false if either:

Related: Range#include?.

No documentation available

Returns true if the set is a superset of the given set.

Returns true if the set and the given enumerable have at least one element in common.

Set[1, 2, 3].intersect? Set[4, 5]   #=> false
Set[1, 2, 3].intersect? Set[3, 4]   #=> true
Set[1, 2, 3].intersect? 4..5        #=> false
Set[1, 2, 3].intersect? [3, 4]      #=> true

Equivalent to Set#select!

No documentation available
No documentation available

In general, to_sym returns the Symbol corresponding to an object. As sym is already a symbol, self is returned in this case.

Callback invoked whenever a subclass of the current class is created.

Example:

class Foo
  def self.inherited(subclass)
    puts "New subclass: #{subclass}"
  end
end

class Bar < Foo
end

class Baz < Bar
end

produces:

New subclass: Bar
New subclass: Baz

Allocates space for a new object of class’s class and does not call initialize on the new instance. The returned object must be an instance of class.

klass = Class.new do
  def initialize(*args)
    @initialized = true
  end

  def initialized?
    @initialized || false
  end
end

klass.allocate.initialized? #=> false

Returns the superclass of class, or nil.

File.superclass          #=> IO
IO.superclass            #=> Object
Object.superclass        #=> BasicObject
class Foo; end
class Bar < Foo; end
Bar.superclass           #=> Foo

Returns nil when the given class does not have a parent class:

BasicObject.superclass   #=> nil
No documentation available

See FileTest.blockdev?.

See FileTest.zero?.

Returns or yields Pathname objects.

Pathname.glob("lib/i*.rb")
    #=> [#<Pathname:lib/ipaddr.rb>, #<Pathname:lib/irb.rb>]

See Dir.glob.

Returns the current working directory as a Pathname.

Pathname.getwd
    #=> #<Pathname:/home/zzak/projects/ruby>

See Dir.getwd.

Returns or yields Pathname objects.

Pathname("ruby-2.4.2").glob("R*.md")
#=> [#<Pathname:ruby-2.4.2/README.md>, #<Pathname:ruby-2.4.2/README.ja.md>]

See Dir.glob. This method uses the base keyword argument of Dir.glob.

Return true if parsed source has errors.

Search took: 4ms  ·  Total Results: 2124