Attempts to activate the current {#possibility} @return [void]
Generates a valid JSON
document from object obj
and returns the result. If no valid JSON
document can be created this method raises a GeneratorError
exception.
Returns the generator of the group.
See the OpenSSL
documentation for EC_GROUP_get0_generator()
Returns the concatenated string from strings
.
Read one byte from the tar entry
Enumerates through the vertices of the graph. @return [Array<Vertex>] The graph’s vertices.
Passes each grapheme cluster in str to the given block, or returns an enumerator if no block is given. Unlike String#each_char
, this enumerates by grapheme clusters defined by Unicode Standard Annex #29 unicode.org/reports/tr29/
"a\u0300".each_char.to_a.size #=> 2 "a\u0300".each_grapheme_cluster.to_a.size #=> 1
Same as Enumerator#with_index(0)
, i.e. there is no starting offset.
If no block is given, a new Enumerator
is returned that includes the index.
Iterates the given block for each element with an arbitrary object, obj
, and returns obj
If no block is given, returns a new Enumerator
.
to_three = Enumerator.new do |y| 3.times do |x| y << x end end to_three_with_string = to_three.with_object("foo") to_three_with_string.each do |x,string| puts "#{string}: #{x}" end # => foo:0 # => foo:1 # => foo:2
Returns a list of the private instance methods defined in mod. If the optional parameter is false
, the methods of any ancestors are not included.
module Mod def method1() end private :method1 def method2() end end Mod.instance_methods #=> [:method2] Mod.private_instance_methods #=> [:method1]
Returns the Ruby source filename and line number containing first definition of constant specified. If the named constant is not found, nil
is returned. If the constant is found, but its source location can not be extracted (constant is defined in C code), empty array is returned.
inherit specifies whether to lookup in mod.ancestors
(true
by default).
# test.rb: class A C1 = 1 end module M C2 = 2 end class B < A include M C3 = 3 end class A # continuation of A definition end p B.const_source_location('C3') # => ["test.rb", 11] p B.const_source_location('C2') # => ["test.rb", 6] p B.const_source_location('C1') # => ["test.rb", 2] p B.const_source_location('C2', false) # => nil -- don't lookup in ancestors p Object.const_source_location('B') # => ["test.rb", 9] p Object.const_source_location('A') # => ["test.rb", 1] -- note it is first entry, not "continuation" p B.const_source_location('A') # => ["test.rb", 1] -- because Object is in ancestors p M.const_source_location('A') # => ["test.rb", 1] -- Object is not ancestor, but additionally checked for modules p Object.const_source_location('A::C1') # => ["test.rb", 2] -- nesting is supported p Object.const_source_location('String') # => [] -- constant is defined in C code
Returns true
if the named private method is defined by mod. If inherit is set, the lookup will also search mod’s ancestors. String
arguments are converted to symbols.
module A def method1() end end class B private def method2() end end class C < B include A def method3() end end A.method_defined? :method1 #=> true C.private_method_defined? "method1" #=> false C.private_method_defined? "method2" #=> true C.private_method_defined? "method2", true #=> true C.private_method_defined? "method2", false #=> false C.method_defined? "method2" #=> false
Makes existing class methods private. Often used to hide the default constructor new
.
String
arguments are converted to symbols.
class SimpleSingleton # Not thread safe private_class_method :new def SimpleSingleton.create(*args, &block) @me = new(*args, &block) if ! @me @me end end
Returns a string representation of lex_state.