Results for: "OptionParser"

Compiled instruction sequence represented by a RubyVM::InstructionSequence instance on the :script_compiled event.

Note that this method is MRI specific.

Returns the current execution stack—an array containing backtrace location objects.

See Thread::Backtrace::Location for more information.

The optional start parameter determines the number of initial stack entries to omit from the top of the stack.

A second optional length parameter can be used to limit how many entries are returned from the stack.

Returns nil if start is greater than the size of current execution stack.

Optionally you can pass a range, which will return an array containing the entries within the specified range.

Parse a file at filename. Returns the Psych::Nodes::Document.

Raises a Psych::SyntaxError when a YAML syntax error is detected.

Parse a YAML string in yaml. Returns the Psych::Nodes::Stream. This method can handle multiple YAML documents contained in yaml. filename is used in the exception message if a Psych::SyntaxError is raised.

If a block is given, a Psych::Nodes::Document node will be yielded to the block as it’s being parsed.

Raises a Psych::SyntaxError when a YAML syntax error is detected.

Example:

Psych.parse_stream("---\n - a\n - b") # => #<Psych::Nodes::Stream:0x00>

Psych.parse_stream("--- a\n--- b") do |node|
  node # => #<Psych::Nodes::Document:0x00>
end

begin
  Psych.parse_stream("--- `", filename: "file.txt")
rescue Psych::SyntaxError => ex
  ex.file    # => 'file.txt'
  ex.message # => "(file.txt): found character that cannot start any token"
end

Raises a TypeError when NilClass is passed.

See Psych::Nodes for more information about YAML AST.

Returns the version of libyaml being used

Returns the string which represents the version of zlib library.

A Gem::Version for the currently running Ruby.

A Gem::Version for the currently running RubyGems

How String Gem paths should be split. Overridable for esoteric platforms.

Remove all observers associated with this object.

Return the number of observers associated with this object.

Returns true if the source parses with errors.

Mirror the Prism.parse_file API by using the serialization API. This uses native strings instead of Ruby strings because it allows us to use mmap when it is available.

Mirror the Prism.parse_comments API by using the serialization API.

Mirror the Prism.parse_lex API by using the serialization API.

Mirror the Prism.parse_success? API by using the serialization API.

Returns true if the array and other_ary have at least one element in common, otherwise returns false:

a = [ 1, 2, 3 ]
b = [ 3, 4, 5 ]
c = [ 5, 6, 7 ]
a.intersect?(b)   #=> true
a.intersect?(c)   #=> false

Array elements are compared using eql? (items must also implement hash correctly).

Returns a new Array with the elements of self in reverse order:

a = ['foo', 'bar', 'two']
a1 = a.reverse
a1 # => ["two", "bar", "foo"]

Reverses self in place:

a = ['foo', 'bar', 'two']
a.reverse! # => ["two", "bar", "foo"]

Calls the block, if given, with combinations of elements of self; returns self. The order of combinations is indeterminate.

When a block and an in-range positive Integer argument n (0 < n <= self.size) are given, calls the block with all n-tuple combinations of self.

Example:

a = [0, 1, 2]
a.combination(2) {|combination| p combination }

Output:

[0, 1]
[0, 2]
[1, 2]

Another example:

a = [0, 1, 2]
a.combination(3) {|combination| p combination }

Output:

[0, 1, 2]

When n is zero, calls the block once with a new empty Array:

a = [0, 1, 2]
a1 = a.combination(0) {|combination| p combination }

Output:

[]

When n is out of range (negative or larger than self.size), does not call the block:

a = [0, 1, 2]
a.combination(-1) {|combination| fail 'Cannot happen' }
a.combination(4) {|combination| fail 'Cannot happen' }

Returns a new Enumerator if no block given:

a = [0, 1, 2]
a.combination(2) # => #<Enumerator: [0, 1, 2]:combination(2)>

Returns the value as a rational. The optional argument eps is always ignored.

Returns a Rational object whose value is exactly or approximately equivalent to that of self.real.

With no argument epsilon given, returns a Rational object whose value is exactly equal to that of self.real.rationalize:

Complex(1, 0).rationalize              # => (1/1)
Complex(1, Rational(0, 1)).rationalize # => (1/1)
Complex(3.14159, 0).rationalize        # => (314159/100000)

With argument epsilon given, returns a Rational object whose value is exactly or approximately equal to that of self.real to the given precision:

Complex(3.14159, 0).rationalize(0.1)          # => (16/5)
Complex(3.14159, 0).rationalize(0.01)         # => (22/7)
Complex(3.14159, 0).rationalize(0.001)        # => (201/64)
Complex(3.14159, 0).rationalize(0.0001)       # => (333/106)
Complex(3.14159, 0).rationalize(0.00001)      # => (355/113)
Complex(3.14159, 0).rationalize(0.000001)     # => (7433/2366)
Complex(3.14159, 0).rationalize(0.0000001)    # => (9208/2931)
Complex(3.14159, 0).rationalize(0.00000001)   # => (47460/15107)
Complex(3.14159, 0).rationalize(0.000000001)  # => (76149/24239)
Complex(3.14159, 0).rationalize(0.0000000001) # => (314159/100000)
Complex(3.14159, 0).rationalize(0.0)          # => (3537115888337719/1125899906842624)

Related: Complex#to_r.

Returns zero as a Rational:

nil.rationalize # => (0/1)

Argument eps is ignored.

Returns a new string with the characters from self in reverse order.

'stressed'.reverse # => "desserts"

Returns self with its characters reversed:

s = 'stressed'
s.reverse! # => "desserts"
s          # => "desserts"
Search took: 6ms  ·  Total Results: 5424