Results for: "pstore"

Returns a new Time object with the same value as self; if self is a Julian date, derives its Gregorian date for conversion to the Time object:

Date.new(2001, 2, 3).to_time               # => 2001-02-03 00:00:00 -0600
Date.new(2001, 2, 3, Date::JULIAN).to_time # => 2001-02-16 00:00:00 -0600

Returns self.

Returns a DateTime whose value is the same as self:

Date.new(2001, 2, 3).to_datetime # => #<DateTime: 2001-02-03T00:00:00+00:00>

See as_json.

Returns a JSON string representing self:

require 'json/add/date'
puts Date.today.to_json

Output:

{"json_class":"Date","y":2023,"m":11,"d":21,"sg":2299161.0}

Returns a hash of the name/value pairs, to use in pattern matching. Possible keys are: :year, :month, :day, :wday, :yday, :hour, :min, :sec, :sec_fraction, :zone.

Possible usages:

dt = DateTime.new(2022, 10, 5, 13, 30)

if d in wday: 1..5, hour: 10..18  # uses deconstruct_keys underneath
  puts "Working time"
end
#=> prints "Working time"

case dt
in year: ...2022
  puts "too old"
in month: ..9
  puts "quarter 1-3"
in wday: 1..5, month:
  puts "working day in month #{month}"
end
#=> prints "working day in month 10"

Note that deconstruction by pattern can also be combined with class check:

if d in DateTime(wday: 1..5, hour: 10..18, day: ..7)
  puts "Working time, first week of the month"
end

Returns a Time object which denotes self.

Returns a Date object which denotes self.

Returns self.

See as_json.

Returns a JSON string representing self:

require 'json/add/datetime'
puts DateTime.now.to_json

Output:

{"json_class":"DateTime","y":2023,"m":11,"d":21,"sg":2299161.0}

Returns self.

Returns a Date object which denotes self.

Returns a DateTime object which denotes self.

See as_json.

Returns a JSON string representing self:

require 'json/add/time'
puts Time.now.to_json

Output:

{"json_class":"Time","s":1700931678,"n":980650786}

Returns a hash of the name/value pairs, to use in pattern matching. Possible keys are: :year, :month, :day, :yday, :wday, :hour, :min, :sec, :subsec, :dst, :zone.

Possible usages:

t = Time.utc(2022, 10, 5, 21, 25, 30)

if t in wday: 3, day: ..7  # uses deconstruct_keys underneath
  puts "first Wednesday of the month"
end
#=> prints "first Wednesday of the month"

case t
in year: ...2022
  puts "too old"
in month: ..9
  puts "quarter 1-3"
in wday: 1..5, month:
  puts "working day in month #{month}"
end
#=> prints "working day in month 10"

Note that deconstruction by pattern can also be combined with class check:

if t in Time(wday: 3, day: ..7)
  puts "first Wednesday of the month"
end

Moves the cursor up n lines.

You must require ‘io/console’ to use this method.

Moves the cursor down n lines.

You must require ‘io/console’ to use this method.

Moves the cursor left n columns.

You must require ‘io/console’ to use this method.

Moves the cursor right n columns.

You must require ‘io/console’ to use this method.

Set the cursor position at column in the same line of the current position.

You must require ‘io/console’ to use this method.

Erases the screen at the cursor corresponding to mode. mode may be either: 0: after cursor 1: before and cursor 2: entire screen

You must require ‘io/console’ to use this method.

Scrolls the entire scrolls forward n lines.

You must require ‘io/console’ to use this method.

Clears the entire screen and moves the cursor top-left corner.

You must require ‘io/console’ to use this method.

Search took: 3ms  ·  Total Results: 4418