Results for: "Data"

The primary interface to this library. Use to setup delegation when defining your class.

class MyClass < DelegateClass(ClassToDelegateTo) # Step 1
  def initialize
    super(obj_of_ClassToDelegateTo)              # Step 2
  end
end

or:

MyClass = DelegateClass(ClassToDelegateTo) do    # Step 1
  def initialize
    super(obj_of_ClassToDelegateTo)              # Step 2
  end
end

Here’s a sample of use from Tempfile which is really a File object with a few special rules about storage location and when the File should be deleted. That makes for an almost textbook perfect example of how to use delegation.

class Tempfile < DelegateClass(File)
  # constant and class member data initialization...

  def initialize(basename, tmpdir=Dir::tmpdir)
    # build up file path/name in var tmpname...

    @tmpfile = File.open(tmpname, File::RDWR|File::CREAT|File::EXCL, 0600)

    # ...

    super(@tmpfile)

    # below this point, all methods of File are supported...
  end

  # ...
end

Return the matchee associated with this NoMatchingPatternKeyError exception.

In the first form, returns an array of the names of all constants accessible from the point of call. This list includes the names of all modules and classes defined in the global scope.

Module.constants.first(4)
   # => [:ARGF, :ARGV, :ArgumentError, :Array]

Module.constants.include?(:SEEK_SET)   # => false

class IO
  Module.constants.include?(:SEEK_SET) # => true
end

The second form calls the instance method constants.

The first form is equivalent to attr_reader. The second form is equivalent to attr_accessor(name) but deprecated. The last form is equivalent to attr_reader(name) but deprecated. Returns an array of defined method names as symbols.

Returns an array of the names of the constants accessible in mod. This includes the names of constants in any included modules (example at start of section), unless the inherit parameter is set to false.

The implementation makes no guarantees about the order in which the constants are yielded.

IO.constants.include?(:SYNC)        #=> true
IO.constants(false).include?(:SYNC) #=> false

Also see Module#const_defined?.

With no arguments, sets the default visibility for subsequently defined methods to private. With arguments, sets the named methods to have private visibility. String arguments are converted to symbols. An Array of Symbols and/or Strings is also accepted. If a single argument is passed, it is returned. If no argument is passed, nil is returned. If multiple arguments are passed, the arguments are returned as an array.

module Mod
  def a()  end
  def b()  end
  private
  def c()  end
  private :a
end
Mod.private_instance_methods   #=> [:a, :c]

Note that to show a private method on RDoc, use :doc:.

Returns a new Date object constructed from the present date:

Date.today.to_s # => "2022-07-06"

See argument start.

Returns the day of the year, in range (1..366):

Date.new(2001, 2, 3).yday # => 34

Returns the day of the month in range (1..31):

Date.new(2001, 2, 3).mday # => 3

Returns the day of the month in range (1..31):

Date.new(2001, 2, 3).mday # => 3

Returns the commercial-date weekday index for self (see Date.commercial); 1 is Monday:

Date.new(2001, 2, 3).cwday # => 6

Returns the day of week in range (0..6); Sunday is 0:

Date.new(2001, 2, 3).wday # => 6

Returns true if self is a Sunday, false otherwise.

Returns true if self is a Monday, false otherwise.

Returns true if self is a Tuesday, false otherwise.

Returns true if self is a Wednesday, false otherwise.

Returns true if self is a Thursday, false otherwise.

Returns true if self is a Friday, false otherwise.

Returns the Julian start date for calendar reform; if not an infinity, the returned value is suitable for passing to Date#jd:

d = Date.new(2001, 2, 3, Date::ITALY)
s = d.start     # => 2299161.0
Date.jd(s).to_s # => "1582-10-15"

d = Date.new(2001, 2, 3, Date::ENGLAND)
s = d.start     # => 2361222.0
Date.jd(s).to_s # => "1752-09-14"

Date.new(2001, 2, 3, Date::GREGORIAN).start # => -Infinity
Date.new(2001, 2, 3, Date::JULIAN).start    # => Infinity

See argument start.

Equivalent to Date#new_start with argument Date::ITALY.

Returns the integer day of the month for self, in range (1..31):

t = Time.new(2000, 1, 2, 3, 4, 5, 6)
# => 2000-01-02 03:04:05 +000006
t.mday # => 2

Related: Time#year, Time#hour, Time#min.

Returns the integer day of the month for self, in range (1..31):

t = Time.new(2000, 1, 2, 3, 4, 5, 6)
# => 2000-01-02 03:04:05 +000006
t.mday # => 2

Related: Time#year, Time#hour, Time#min.

Returns the integer day of the week for self, in range (0..6), with Sunday as zero.

t = Time.new(2000, 1, 2, 3, 4, 5, 6)
# => 2000-01-02 03:04:05 +000006
t.wday    # => 0
t.sunday? # => true

Related: Time#year, Time#hour, Time#min.

Returns the integer day of the year of self, in range (1..366).

Time.new(2000, 1, 1).yday   # => 1
Time.new(2000, 12, 31).yday # => 366

Returns true if self represents a Sunday, false otherwise:

t = Time.utc(2000, 1, 2) # => 2000-01-02 00:00:00 UTC
t.sunday?                # => true

Related: Time#monday?, Time#tuesday?, Time#wednesday?.

Search took: 5ms  ·  Total Results: 1540