Results for: "Data"

Return true if the caused method was called as private.

When this module is included in another, Ruby calls append_features in this module, passing it the receiving module in mod. Ruby’s default implementation is to add the constants, methods, and module variables of this module to mod if this module has not already been added to mod or one of its ancestors. See also Module#include.

When this module is prepended in another, Ruby calls prepend_features in this module, passing it the receiving module in mod. Ruby’s default implementation is to overlay the constants, methods, and module variables of this module to mod if this module has not already been added to mod or one of its ancestors. See also Module#prepend.

Creates instance variables and corresponding methods that return the value of each instance variable. Equivalent to calling “attr:name” on each name in turn. String arguments are converted to symbols. Returns an array of defined method names as symbols.

Creates an accessor method to allow assignment to the attribute symbol.id2name. String arguments are converted to symbols. Returns an array of defined method names as symbols.

Defines a named attribute for this module, where the name is symbol.id2name, creating an instance variable (@name) and a corresponding access method to read it. Also creates a method called name= to set the attribute. String arguments are converted to symbols. Returns an array of defined method names as symbols.

module Mod
  attr_accessor(:one, :two) #=> [:one, :one=, :two, :two=]
end
Mod.instance_methods.sort   #=> [:one, :one=, :two, :two=]

Returns an array containing the names of the public and protected instance methods in the receiver. For a module, these are the public and protected methods; for a class, they are the instance (not singleton) methods. If the optional parameter is false, the methods of any ancestors are not included.

module A
  def method1()  end
end
class B
  include A
  def method2()  end
end
class C < B
  def method3()  end
end

A.instance_methods(false)                   #=> [:method1]
B.instance_methods(false)                   #=> [:method2]
B.instance_methods(true).include?(:method1) #=> true
C.instance_methods(false)                   #=> [:method3]
C.instance_methods.include?(:method2)       #=> true

Note that method visibility changes in the current class, as well as aliases, are considered as methods of the current class by this method:

class C < B
  alias method4 method2
  protected :method2
end
C.instance_methods(false).sort               #=> [:method2, :method3, :method4]

Makes a list of existing constants public.

Returns an UnboundMethod representing the given instance method in mod.

class Interpreter
  def do_a() print "there, "; end
  def do_d() print "Hello ";  end
  def do_e() print "!\n";     end
  def do_v() print "Dave";    end
  Dispatcher = {
    "a" => instance_method(:do_a),
    "d" => instance_method(:do_d),
    "e" => instance_method(:do_e),
    "v" => instance_method(:do_v)
  }
  def interpret(string)
    string.each_char {|b| Dispatcher[b].bind(self).call }
  end
end

interpreter = Interpreter.new
interpreter.interpret('dave')

produces:

Hello there, Dave!

Import a JSON Marshalled object.

method used for JSON marshalling support.

Deserializes JSON string by converting numerator value n, denominator value d, to a Rational object.

Synonym for ENV.

Returns the fractional part of the day in range (Rational(0, 1)…Rational(1, 1)):

DateTime.new(2001,2,3,12).day_fraction # => (1/2)

Returns a copy of self with the given start value:

d0 = Date.new(2000, 2, 3)
d0.julian? # => false
d1 = d0.new_start(Date::JULIAN)
d1.julian? # => true

See argument start.

Equivalent to Date#+ with argument n.

Equivalent to Date#- with argument n.

Deserializes JSON string by converting Julian year y, month m, day d and Day of Calendar Reform sg to Date.

Deserializes JSON string by converting year y, month m, day d, hour H, minute M, second S, offset of and Day of Calendar Reform sg to DateTime.

Deserializes JSON string by converting time since epoch to Time

Waits until IO is readable and returns a truthy value, or a falsy value when times out. Returns a truthy value immediately when buffered data is available.

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

Waits until IO is writable and returns a truthy value or a falsy value when times out.

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

Returns the path associated with the IO, or nil if there is no path associated with the IO. It is not guaranteed that the path exists on the filesystem.

$stdin.path # => "<STDIN>"

File.open("testfile") {|f| f.path} # => "testfile"

Deserializes JSON string by constructing new Struct object with values t serialized by to_json.

Deserializes JSON string by constructing new Range object with arguments a serialized by to_json.

Deserializes JSON string by constructing new Regexp object with source s (Regexp or String) and options o serialized by to_json

Search took: 5ms  ·  Total Results: 1397