id int32 0 24.9k | repo stringlengths 5 58 | path stringlengths 9 168 | func_name stringlengths 9 130 | original_string stringlengths 66 10.5k | language stringclasses 1
value | code stringlengths 66 10.5k | code_tokens list | docstring stringlengths 8 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 94 266 |
|---|---|---|---|---|---|---|---|---|---|---|---|
2,400 | famished-tiger/Rley | lib/rley/parse_forest_visitor.rb | Rley.ParseForestVisitor.traverse_children | def traverse_children(aParentNode)
children = aParentNode.children
broadcast(:before_subnodes, aParentNode, children)
# Let's proceed with the visit of children
children.each_with_index do |a_node, i|
edge_sign = aParentNode.signatures[i]
if a_node.kind_of?(SPPF::CompositeNode)
... | ruby | def traverse_children(aParentNode)
children = aParentNode.children
broadcast(:before_subnodes, aParentNode, children)
# Let's proceed with the visit of children
children.each_with_index do |a_node, i|
edge_sign = aParentNode.signatures[i]
if a_node.kind_of?(SPPF::CompositeNode)
... | [
"def",
"traverse_children",
"(",
"aParentNode",
")",
"children",
"=",
"aParentNode",
".",
"children",
"broadcast",
"(",
":before_subnodes",
",",
"aParentNode",
",",
"children",
")",
"# Let's proceed with the visit of children",
"children",
".",
"each_with_index",
"do",
... | Visit event. The visitor is about to visit the children of a non
terminal node.
@param aParentNode [NonTeminalNode] the (non-terminal) parent node. | [
"Visit",
"event",
".",
"The",
"visitor",
"is",
"about",
"to",
"visit",
"the",
"children",
"of",
"a",
"non",
"terminal",
"node",
"."
] | 307a8ed6a328182c3cb83a0c3ed04c04b7135a13 | https://github.com/famished-tiger/Rley/blob/307a8ed6a328182c3cb83a0c3ed04c04b7135a13/lib/rley/parse_forest_visitor.rb#L139-L162 |
2,401 | jarib/celerity | lib/celerity/element_collection.rb | Celerity.ElementCollection.[] | def [](n)
if @elements && @elements[n - Celerity.index_offset]
element_class.new(@container, :object, @elements[n - Celerity.index_offset])
else
iterator_object(n - Celerity.index_offset)
end
end | ruby | def [](n)
if @elements && @elements[n - Celerity.index_offset]
element_class.new(@container, :object, @elements[n - Celerity.index_offset])
else
iterator_object(n - Celerity.index_offset)
end
end | [
"def",
"[]",
"(",
"n",
")",
"if",
"@elements",
"&&",
"@elements",
"[",
"n",
"-",
"Celerity",
".",
"index_offset",
"]",
"element_class",
".",
"new",
"(",
"@container",
",",
":object",
",",
"@elements",
"[",
"n",
"-",
"Celerity",
".",
"index_offset",
"]",
... | Get the element at the given index.
By default, this is 1-indexed to keep compatibility with Watir.
Also note that because of Watir's lazy loading, this will return an Element
instance even if the index is out of bounds.
@param [Fixnum] n Index of wanted element, 1-indexed unless Celerity.index_offset is changed.... | [
"Get",
"the",
"element",
"at",
"the",
"given",
"index",
".",
"By",
"default",
"this",
"is",
"1",
"-",
"indexed",
"to",
"keep",
"compatibility",
"with",
"Watir",
"."
] | 90c6eeb3db868be1d9c0195b53f040b5b53d0e91 | https://github.com/jarib/celerity/blob/90c6eeb3db868be1d9c0195b53f040b5b53d0e91/lib/celerity/element_collection.rb#L68-L74 |
2,402 | jarib/celerity | lib/celerity/elements/select_list.rb | Celerity.SelectList.selected? | def selected?(value)
assert_exists
raise UnknownObjectException, "unknown option with value #{value.inspect} for select_list #{@conditions.inspect}" unless include?(value)
[email protected] { |e| matches_option?(e, value) && e.isSelected }
end | ruby | def selected?(value)
assert_exists
raise UnknownObjectException, "unknown option with value #{value.inspect} for select_list #{@conditions.inspect}" unless include?(value)
[email protected] { |e| matches_option?(e, value) && e.isSelected }
end | [
"def",
"selected?",
"(",
"value",
")",
"assert_exists",
"raise",
"UnknownObjectException",
",",
"\"unknown option with value #{value.inspect} for select_list #{@conditions.inspect}\"",
"unless",
"include?",
"(",
"value",
")",
"!",
"!",
"@object",
".",
"getOptions",
".",
"fi... | Returns true if any of the selected options match the given value.
@param [String, Regexp] value A value.
@raise [Celerity::Exception::UnknownObjectException] if the value does not exist.
@return [true, false] | [
"Returns",
"true",
"if",
"any",
"of",
"the",
"selected",
"options",
"match",
"the",
"given",
"value",
"."
] | 90c6eeb3db868be1d9c0195b53f040b5b53d0e91 | https://github.com/jarib/celerity/blob/90c6eeb3db868be1d9c0195b53f040b5b53d0e91/lib/celerity/elements/select_list.rb#L99-L103 |
2,403 | jarib/celerity | lib/celerity/container.rb | Celerity.Container.contains_text | def contains_text(expected_text)
assert_exists
return nil unless respond_to? :text
case expected_text
when Regexp
text() =~ expected_text
when String
text().index(expected_text)
else
raise TypeError, "expected String or Regexp, got #{expected_text.inspect}:#{... | ruby | def contains_text(expected_text)
assert_exists
return nil unless respond_to? :text
case expected_text
when Regexp
text() =~ expected_text
when String
text().index(expected_text)
else
raise TypeError, "expected String or Regexp, got #{expected_text.inspect}:#{... | [
"def",
"contains_text",
"(",
"expected_text",
")",
"assert_exists",
"return",
"nil",
"unless",
"respond_to?",
":text",
"case",
"expected_text",
"when",
"Regexp",
"text",
"(",
")",
"=~",
"expected_text",
"when",
"String",
"text",
"(",
")",
".",
"index",
"(",
"e... | Check if the element contains the given text.
@param [String, Regexp] expected_text The text to look for.
@return [Fixnum, nil] The index of the matched text, or nil if it doesn't match. | [
"Check",
"if",
"the",
"element",
"contains",
"the",
"given",
"text",
"."
] | 90c6eeb3db868be1d9c0195b53f040b5b53d0e91 | https://github.com/jarib/celerity/blob/90c6eeb3db868be1d9c0195b53f040b5b53d0e91/lib/celerity/container.rb#L45-L57 |
2,404 | famished-tiger/Rley | lib/rley/engine.rb | Rley.Engine.parse | def parse(aTokenizer)
tokens = []
aTokenizer.each do |a_token|
next unless a_token
term_name = a_token.terminal
term_symb = grammar.name2symbol[term_name]
a_token.instance_variable_set(:@terminal, term_symb)
tokens << a_token
end
parser = build_parser(gra... | ruby | def parse(aTokenizer)
tokens = []
aTokenizer.each do |a_token|
next unless a_token
term_name = a_token.terminal
term_symb = grammar.name2symbol[term_name]
a_token.instance_variable_set(:@terminal, term_symb)
tokens << a_token
end
parser = build_parser(gra... | [
"def",
"parse",
"(",
"aTokenizer",
")",
"tokens",
"=",
"[",
"]",
"aTokenizer",
".",
"each",
"do",
"|",
"a_token",
"|",
"next",
"unless",
"a_token",
"term_name",
"=",
"a_token",
".",
"terminal",
"term_symb",
"=",
"grammar",
".",
"name2symbol",
"[",
"term_na... | Parse the sequence of tokens produced by the given tokenizer object.
@param aTokenizer [#each]
@return [Parser::GFGParsing] | [
"Parse",
"the",
"sequence",
"of",
"tokens",
"produced",
"by",
"the",
"given",
"tokenizer",
"object",
"."
] | 307a8ed6a328182c3cb83a0c3ed04c04b7135a13 | https://github.com/famished-tiger/Rley/blob/307a8ed6a328182c3cb83a0c3ed04c04b7135a13/lib/rley/engine.rb#L78-L94 |
2,405 | famished-tiger/Rley | lib/rley/engine.rb | Rley.Engine.to_ptree | def to_ptree(aRawParse)
factory = ParseRep::ParseTreeFactory.new(aRawParse)
if configuration.repr_builder == :default
result = factory.create(nil)
else
result = factory.create(configuration.repr_builder)
end
return result
end | ruby | def to_ptree(aRawParse)
factory = ParseRep::ParseTreeFactory.new(aRawParse)
if configuration.repr_builder == :default
result = factory.create(nil)
else
result = factory.create(configuration.repr_builder)
end
return result
end | [
"def",
"to_ptree",
"(",
"aRawParse",
")",
"factory",
"=",
"ParseRep",
"::",
"ParseTreeFactory",
".",
"new",
"(",
"aRawParse",
")",
"if",
"configuration",
".",
"repr_builder",
"==",
":default",
"result",
"=",
"factory",
".",
"create",
"(",
"nil",
")",
"else",... | Convert raw parse result into a parse tree representation
@param aRawParse [Parser::GFGParsing]
@return [Rley::PTree::ParseTree] | [
"Convert",
"raw",
"parse",
"result",
"into",
"a",
"parse",
"tree",
"representation"
] | 307a8ed6a328182c3cb83a0c3ed04c04b7135a13 | https://github.com/famished-tiger/Rley/blob/307a8ed6a328182c3cb83a0c3ed04c04b7135a13/lib/rley/engine.rb#L114-L123 |
2,406 | famished-tiger/Rley | lib/rley/engine.rb | Rley.Engine.to_pforest | def to_pforest(aRawParse)
factory = ParseRep::ParseForestFactory.new(aRawParse)
if configuration.repr_builder == :default
result = factory.create(nil)
else
result = factory.create(configuration.repr_builder)
end
return result
end | ruby | def to_pforest(aRawParse)
factory = ParseRep::ParseForestFactory.new(aRawParse)
if configuration.repr_builder == :default
result = factory.create(nil)
else
result = factory.create(configuration.repr_builder)
end
return result
end | [
"def",
"to_pforest",
"(",
"aRawParse",
")",
"factory",
"=",
"ParseRep",
"::",
"ParseForestFactory",
".",
"new",
"(",
"aRawParse",
")",
"if",
"configuration",
".",
"repr_builder",
"==",
":default",
"result",
"=",
"factory",
".",
"create",
"(",
"nil",
")",
"el... | Convert raw parse result into a parse forest representation
@param aRawParse [Parser::GFGParsing]
@return [Rley::SPPF::ParseForest] | [
"Convert",
"raw",
"parse",
"result",
"into",
"a",
"parse",
"forest",
"representation"
] | 307a8ed6a328182c3cb83a0c3ed04c04b7135a13 | https://github.com/famished-tiger/Rley/blob/307a8ed6a328182c3cb83a0c3ed04c04b7135a13/lib/rley/engine.rb#L128-L137 |
2,407 | jarib/celerity | lib/celerity/element_locator.rb | Celerity.ElementLocator.with_nullpointer_retry | def with_nullpointer_retry(max_retries = 3)
tries = 0
yield
rescue java.lang.NullPointerException => e
raise e if tries >= max_retries
tries += 1
warn "warning: celerity caught #{e} - retry ##{tries}"
retry
end | ruby | def with_nullpointer_retry(max_retries = 3)
tries = 0
yield
rescue java.lang.NullPointerException => e
raise e if tries >= max_retries
tries += 1
warn "warning: celerity caught #{e} - retry ##{tries}"
retry
end | [
"def",
"with_nullpointer_retry",
"(",
"max_retries",
"=",
"3",
")",
"tries",
"=",
"0",
"yield",
"rescue",
"java",
".",
"lang",
".",
"NullPointerException",
"=>",
"e",
"raise",
"e",
"if",
"tries",
">=",
"max_retries",
"tries",
"+=",
"1",
"warn",
"\"warning: c... | HtmlUnit throws NPEs sometimes when we're locating elements
Retry seems to work fine. | [
"HtmlUnit",
"throws",
"NPEs",
"sometimes",
"when",
"we",
"re",
"locating",
"elements",
"Retry",
"seems",
"to",
"work",
"fine",
"."
] | 90c6eeb3db868be1d9c0195b53f040b5b53d0e91 | https://github.com/jarib/celerity/blob/90c6eeb3db868be1d9c0195b53f040b5b53d0e91/lib/celerity/element_locator.rb#L152-L161 |
2,408 | jarib/celerity | lib/celerity/clickable_element.rb | Celerity.ClickableElement.click_and_attach | def click_and_attach
assert_exists_and_enabled
browser = Browser.new(@browser.options.dup)
browser.webclient.set_cookie_manager(
@browser.webclient.get_cookie_manager
) # hirobumi: we do want cookies as well.
@browser.disable_event_listener do
rescue_status_code_exception ... | ruby | def click_and_attach
assert_exists_and_enabled
browser = Browser.new(@browser.options.dup)
browser.webclient.set_cookie_manager(
@browser.webclient.get_cookie_manager
) # hirobumi: we do want cookies as well.
@browser.disable_event_listener do
rescue_status_code_exception ... | [
"def",
"click_and_attach",
"assert_exists_and_enabled",
"browser",
"=",
"Browser",
".",
"new",
"(",
"@browser",
".",
"options",
".",
"dup",
")",
"browser",
".",
"webclient",
".",
"set_cookie_manager",
"(",
"@browser",
".",
"webclient",
".",
"get_cookie_manager",
"... | Click the element and return a new Browser instance with the resulting page.
This is useful for elements that trigger popups when clicked.
@return [Celerity::Browser] | [
"Click",
"the",
"element",
"and",
"return",
"a",
"new",
"Browser",
"instance",
"with",
"the",
"resulting",
"page",
".",
"This",
"is",
"useful",
"for",
"elements",
"that",
"trigger",
"popups",
"when",
"clicked",
"."
] | 90c6eeb3db868be1d9c0195b53f040b5b53d0e91 | https://github.com/jarib/celerity/blob/90c6eeb3db868be1d9c0195b53f040b5b53d0e91/lib/celerity/clickable_element.rb#L38-L50 |
2,409 | potatosalad/ruby-erlang-terms | lib/erlang/map.rb | Erlang.Map.value? | def value?(value)
value = Erlang.from(value)
each { |k,v| return true if value == v }
return false
end | ruby | def value?(value)
value = Erlang.from(value)
each { |k,v| return true if value == v }
return false
end | [
"def",
"value?",
"(",
"value",
")",
"value",
"=",
"Erlang",
".",
"from",
"(",
"value",
")",
"each",
"{",
"|",
"k",
",",
"v",
"|",
"return",
"true",
"if",
"value",
"==",
"v",
"}",
"return",
"false",
"end"
] | Return `true` if this `Map` has one or more keys which map to the provided value.
@example
Erlang::Map["A" => 1, "B" => 2, "C" => 3].value?(2) # => true
@param value [Object] The value to check for
@return [Boolean] | [
"Return",
"true",
"if",
"this",
"Map",
"has",
"one",
"or",
"more",
"keys",
"which",
"map",
"to",
"the",
"provided",
"value",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/map.rb#L218-L222 |
2,410 | potatosalad/ruby-erlang-terms | lib/erlang/map.rb | Erlang.Map.get | def get(key)
key = Erlang.from(key)
entry = @trie.get(key)
if entry
return entry[1]
elsif @default
return @default.call(key)
end
end | ruby | def get(key)
key = Erlang.from(key)
entry = @trie.get(key)
if entry
return entry[1]
elsif @default
return @default.call(key)
end
end | [
"def",
"get",
"(",
"key",
")",
"key",
"=",
"Erlang",
".",
"from",
"(",
"key",
")",
"entry",
"=",
"@trie",
".",
"get",
"(",
"key",
")",
"if",
"entry",
"return",
"entry",
"[",
"1",
"]",
"elsif",
"@default",
"return",
"@default",
".",
"call",
"(",
"... | Retrieve the value corresponding to the provided key object. If not found, and
this `Map` has a default block, the default block is called to provide the
value. Otherwise, return `nil`.
@example
m = Erlang::Map["A" => 1, "B" => 2, "C" => 3]
m["B"] # => 2
m.get("B") # => 2
m.get("Elep... | [
"Retrieve",
"the",
"value",
"corresponding",
"to",
"the",
"provided",
"key",
"object",
".",
"If",
"not",
"found",
"and",
"this",
"Map",
"has",
"a",
"default",
"block",
"the",
"default",
"block",
"is",
"called",
"to",
"provide",
"the",
"value",
".",
"Otherw... | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/map.rb#L242-L250 |
2,411 | potatosalad/ruby-erlang-terms | lib/erlang/map.rb | Erlang.Map.fetch | def fetch(key, default = Undefined)
key = Erlang.from(key)
entry = @trie.get(key)
if entry
return entry[1]
elsif block_given?
return yield(key)
elsif not Undefined.equal?(default)
return Erlang.from(default)
else
raise KeyError, "key not found: #{key.i... | ruby | def fetch(key, default = Undefined)
key = Erlang.from(key)
entry = @trie.get(key)
if entry
return entry[1]
elsif block_given?
return yield(key)
elsif not Undefined.equal?(default)
return Erlang.from(default)
else
raise KeyError, "key not found: #{key.i... | [
"def",
"fetch",
"(",
"key",
",",
"default",
"=",
"Undefined",
")",
"key",
"=",
"Erlang",
".",
"from",
"(",
"key",
")",
"entry",
"=",
"@trie",
".",
"get",
"(",
"key",
")",
"if",
"entry",
"return",
"entry",
"[",
"1",
"]",
"elsif",
"block_given?",
"re... | Retrieve the value corresponding to the given key object, or use the provided
default value or block, or otherwise raise a `KeyError`.
@overload fetch(key)
Retrieve the value corresponding to the given key, or raise a `KeyError`
if it is not found.
@param key [Object] The key to look up
@overload fetch(key... | [
"Retrieve",
"the",
"value",
"corresponding",
"to",
"the",
"given",
"key",
"object",
"or",
"use",
"the",
"provided",
"default",
"value",
"or",
"block",
"or",
"otherwise",
"raise",
"a",
"KeyError",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/map.rb#L286-L298 |
2,412 | potatosalad/ruby-erlang-terms | lib/erlang/map.rb | Erlang.Map.slice | def slice(*wanted)
trie = Trie.new(0)
wanted.each { |key|
key = Erlang.from(key)
trie.put!(key, get(key)) if key?(key)
}
return self.class.alloc(trie, @default)
end | ruby | def slice(*wanted)
trie = Trie.new(0)
wanted.each { |key|
key = Erlang.from(key)
trie.put!(key, get(key)) if key?(key)
}
return self.class.alloc(trie, @default)
end | [
"def",
"slice",
"(",
"*",
"wanted",
")",
"trie",
"=",
"Trie",
".",
"new",
"(",
"0",
")",
"wanted",
".",
"each",
"{",
"|",
"key",
"|",
"key",
"=",
"Erlang",
".",
"from",
"(",
"key",
")",
"trie",
".",
"put!",
"(",
"key",
",",
"get",
"(",
"key",... | Return a new `Map` with only the associations for the `wanted` keys retained.
@example
m = Erlang::Map["A" => 1, "B" => 2, "C" => 3]
m.slice("B", "C") # => Erlang::Map["B" => 2, "C" => 3]
@param wanted [::Enumerable] The keys to retain
@return [Map] | [
"Return",
"a",
"new",
"Map",
"with",
"only",
"the",
"associations",
"for",
"the",
"wanted",
"keys",
"retained",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/map.rb#L621-L628 |
2,413 | bbc/hive-runner | lib/hive/worker.rb | Hive.Worker.poll_queue | def poll_queue
@job = reserve_job
if @job.nil?
@log.info('No job found')
else
@log.info('Job starting')
begin
@current_job_start_time = Time.now
execute_job
rescue => e
@log.info("Error running test: #{e.message}\n : #{e.backtrace.join("\n ... | ruby | def poll_queue
@job = reserve_job
if @job.nil?
@log.info('No job found')
else
@log.info('Job starting')
begin
@current_job_start_time = Time.now
execute_job
rescue => e
@log.info("Error running test: #{e.message}\n : #{e.backtrace.join("\n ... | [
"def",
"poll_queue",
"@job",
"=",
"reserve_job",
"if",
"@job",
".",
"nil?",
"@log",
".",
"info",
"(",
"'No job found'",
")",
"else",
"@log",
".",
"info",
"(",
"'Job starting'",
")",
"begin",
"@current_job_start_time",
"=",
"Time",
".",
"now",
"execute_job",
... | The main worker process loop
Check the queues for work | [
"The",
"main",
"worker",
"process",
"loop",
"Check",
"the",
"queues",
"for",
"work"
] | 9079f23362e201c342f416b5038d935e83e0de84 | https://github.com/bbc/hive-runner/blob/9079f23362e201c342f416b5038d935e83e0de84/lib/hive/worker.rb#L89-L103 |
2,414 | bbc/hive-runner | lib/hive/worker.rb | Hive.Worker.reserve_job | def reserve_job
@log.info "Trying to reserve job for queues: #{@queues.join(', ')}"
job = job_message_klass.reserve(@queues, reservation_details)
@log.debug "Job: #{job.inspect}"
raise InvalidJobReservationError.new("Invalid Job Reserved") if ! (job.nil? || job.valid?)
job
end | ruby | def reserve_job
@log.info "Trying to reserve job for queues: #{@queues.join(', ')}"
job = job_message_klass.reserve(@queues, reservation_details)
@log.debug "Job: #{job.inspect}"
raise InvalidJobReservationError.new("Invalid Job Reserved") if ! (job.nil? || job.valid?)
job
end | [
"def",
"reserve_job",
"@log",
".",
"info",
"\"Trying to reserve job for queues: #{@queues.join(', ')}\"",
"job",
"=",
"job_message_klass",
".",
"reserve",
"(",
"@queues",
",",
"reservation_details",
")",
"@log",
".",
"debug",
"\"Job: #{job.inspect}\"",
"raise",
"InvalidJobR... | Try to find and reserve a job | [
"Try",
"to",
"find",
"and",
"reserve",
"a",
"job"
] | 9079f23362e201c342f416b5038d935e83e0de84 | https://github.com/bbc/hive-runner/blob/9079f23362e201c342f416b5038d935e83e0de84/lib/hive/worker.rb#L106-L112 |
2,415 | bbc/hive-runner | lib/hive/worker.rb | Hive.Worker.diagnostics | def diagnostics
retn = true
protect
retn = @diagnostic_runner.run if !@diagnostic_runner.nil?
unprotect
@log.info('Diagnostics failed') if not retn
status = device_status
status = set_device_status('happy') if status == 'busy'
raise DeviceNotReady.new("Current device stat... | ruby | def diagnostics
retn = true
protect
retn = @diagnostic_runner.run if !@diagnostic_runner.nil?
unprotect
@log.info('Diagnostics failed') if not retn
status = device_status
status = set_device_status('happy') if status == 'busy'
raise DeviceNotReady.new("Current device stat... | [
"def",
"diagnostics",
"retn",
"=",
"true",
"protect",
"retn",
"=",
"@diagnostic_runner",
".",
"run",
"if",
"!",
"@diagnostic_runner",
".",
"nil?",
"unprotect",
"@log",
".",
"info",
"(",
"'Diagnostics failed'",
")",
"if",
"not",
"retn",
"status",
"=",
"device_s... | Diagnostics function to be extended in child class, as required | [
"Diagnostics",
"function",
"to",
"be",
"extended",
"in",
"child",
"class",
"as",
"required"
] | 9079f23362e201c342f416b5038d935e83e0de84 | https://github.com/bbc/hive-runner/blob/9079f23362e201c342f416b5038d935e83e0de84/lib/hive/worker.rb#L251-L261 |
2,416 | bbc/hive-runner | lib/hive/worker.rb | Hive.Worker.upload_files | def upload_files(job, *paths)
@log.info("Uploading assets")
paths.each do |path|
@log.info("Uploading files from #{path}")
Dir.foreach(path) do |item|
@log.info("File: #{item}")
next if item == '.' or item == '..'
begin
artifact = job.report_artifact... | ruby | def upload_files(job, *paths)
@log.info("Uploading assets")
paths.each do |path|
@log.info("Uploading files from #{path}")
Dir.foreach(path) do |item|
@log.info("File: #{item}")
next if item == '.' or item == '..'
begin
artifact = job.report_artifact... | [
"def",
"upload_files",
"(",
"job",
",",
"*",
"paths",
")",
"@log",
".",
"info",
"(",
"\"Uploading assets\"",
")",
"paths",
".",
"each",
"do",
"|",
"path",
"|",
"@log",
".",
"info",
"(",
"\"Uploading files from #{path}\"",
")",
"Dir",
".",
"foreach",
"(",
... | Upload any files from the test | [
"Upload",
"any",
"files",
"from",
"the",
"test"
] | 9079f23362e201c342f416b5038d935e83e0de84 | https://github.com/bbc/hive-runner/blob/9079f23362e201c342f416b5038d935e83e0de84/lib/hive/worker.rb#L294-L310 |
2,417 | bbc/hive-runner | lib/hive/worker.rb | Hive.Worker.checkout_code | def checkout_code(repository, checkout_directory, branch)
CodeCache.repo(repository).checkout(:head, checkout_directory, branch) or raise "Unable to checkout repository #{repository}"
end | ruby | def checkout_code(repository, checkout_directory, branch)
CodeCache.repo(repository).checkout(:head, checkout_directory, branch) or raise "Unable to checkout repository #{repository}"
end | [
"def",
"checkout_code",
"(",
"repository",
",",
"checkout_directory",
",",
"branch",
")",
"CodeCache",
".",
"repo",
"(",
"repository",
")",
".",
"checkout",
"(",
":head",
",",
"checkout_directory",
",",
"branch",
")",
"or",
"raise",
"\"Unable to checkout repositor... | Get a checkout of the repository | [
"Get",
"a",
"checkout",
"of",
"the",
"repository"
] | 9079f23362e201c342f416b5038d935e83e0de84 | https://github.com/bbc/hive-runner/blob/9079f23362e201c342f416b5038d935e83e0de84/lib/hive/worker.rb#L402-L404 |
2,418 | acook/remedy | lib/remedy/characters.rb | Remedy.Characters.gremlins | def gremlins
{
space: "\u2420",
tab: "\u21B9",
carriage_return: "\u23CE",
line_feed: "\u240A",
control_c: "\u2404",
control_d: "\u2403",
control_r: "\u2412",
escape: "\u238B",
backspace: "\u2408",
delete... | ruby | def gremlins
{
space: "\u2420",
tab: "\u21B9",
carriage_return: "\u23CE",
line_feed: "\u240A",
control_c: "\u2404",
control_d: "\u2403",
control_r: "\u2412",
escape: "\u238B",
backspace: "\u2408",
delete... | [
"def",
"gremlins",
"{",
"space",
":",
"\"\\u2420\"",
",",
"tab",
":",
"\"\\u21B9\"",
",",
"carriage_return",
":",
"\"\\u23CE\"",
",",
"line_feed",
":",
"\"\\u240A\"",
",",
"control_c",
":",
"\"\\u2404\"",
",",
"control_d",
":",
"\"\\u2403\"",
",",
"control_r",
... | Glyphs and Alternate Names | [
"Glyphs",
"and",
"Alternate",
"Names"
] | 66452b4e0540dc9c95ca596c69998f79e3a54db6 | https://github.com/acook/remedy/blob/66452b4e0540dc9c95ca596c69998f79e3a54db6/lib/remedy/characters.rb#L130-L151 |
2,419 | potatosalad/ruby-erlang-terms | lib/erlang/bitstring.rb | Erlang.Bitstring.bitslice | def bitslice(arg, length = (missing_length = true))
if missing_length
if arg.is_a?(Range)
from, to = arg.begin, arg.end
from += bitsize if from < 0
return nil if from < 0
to += bitsize if to < 0
to += 1 if !arg.exclude_end?
length = to ... | ruby | def bitslice(arg, length = (missing_length = true))
if missing_length
if arg.is_a?(Range)
from, to = arg.begin, arg.end
from += bitsize if from < 0
return nil if from < 0
to += bitsize if to < 0
to += 1 if !arg.exclude_end?
length = to ... | [
"def",
"bitslice",
"(",
"arg",
",",
"length",
"=",
"(",
"missing_length",
"=",
"true",
")",
")",
"if",
"missing_length",
"if",
"arg",
".",
"is_a?",
"(",
"Range",
")",
"from",
",",
"to",
"=",
"arg",
".",
"begin",
",",
"arg",
".",
"end",
"from",
"+="... | Return specific objects from the `Bitstring`. All overloads return `nil` if
the starting index is out of range.
@overload bitslice(index)
Returns a single bit at the given `index`. If `index` is negative,
count backwards from the end.
@param index [Integer] The index to retrieve. May be negative.
@retur... | [
"Return",
"specific",
"objects",
"from",
"the",
"Bitstring",
".",
"All",
"overloads",
"return",
"nil",
"if",
"the",
"starting",
"index",
"is",
"out",
"of",
"range",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/bitstring.rb#L191-L264 |
2,420 | potatosalad/ruby-erlang-terms | lib/erlang/bitstring.rb | Erlang.Bitstring.each_bit | def each_bit
return enum_for(:each_bit) unless block_given?
index = 0
headbits = (self.bytesize - 1) * 8
skipbits = 8 - @bits
@data.each_byte do |byte|
loop do
break if index == @bitsize
if index >= headbits
bit = (byte >> (7 - ((index + skipbits) & ... | ruby | def each_bit
return enum_for(:each_bit) unless block_given?
index = 0
headbits = (self.bytesize - 1) * 8
skipbits = 8 - @bits
@data.each_byte do |byte|
loop do
break if index == @bitsize
if index >= headbits
bit = (byte >> (7 - ((index + skipbits) & ... | [
"def",
"each_bit",
"return",
"enum_for",
"(",
":each_bit",
")",
"unless",
"block_given?",
"index",
"=",
"0",
"headbits",
"=",
"(",
"self",
".",
"bytesize",
"-",
"1",
")",
"*",
"8",
"skipbits",
"=",
"8",
"-",
"@bits",
"@data",
".",
"each_byte",
"do",
"|... | Call the given block once for each bit in the `Bitstring`, passing each
bit from first to last successively to the block. If no block is given,
returns an `Enumerator`.
@return [self]
@yield [Integer] | [
"Call",
"the",
"given",
"block",
"once",
"for",
"each",
"bit",
"in",
"the",
"Bitstring",
"passing",
"each",
"bit",
"from",
"first",
"to",
"last",
"successively",
"to",
"the",
"block",
".",
"If",
"no",
"block",
"is",
"given",
"returns",
"an",
"Enumerator",
... | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/bitstring.rb#L322-L341 |
2,421 | TylerRick/capybara-chrome_dev_tools | lib/capybara/chrome_dev_tools/driver_extensions.rb | Capybara::ChromeDevTools.DriverExtensions.start_crmux! | def start_crmux!(opts)
self.chrome_debugging_port = find_free_port(Capybara::ChromeDevTools.preferred_port)
self.crmux_listen_port = find_free_port(chrome_debugging_port + 1)
opts[:options].args << "--remote-debugging-port=#{chrome_debugging_port}"
#opts[:options].add_preference 'debuggerAdd... | ruby | def start_crmux!(opts)
self.chrome_debugging_port = find_free_port(Capybara::ChromeDevTools.preferred_port)
self.crmux_listen_port = find_free_port(chrome_debugging_port + 1)
opts[:options].args << "--remote-debugging-port=#{chrome_debugging_port}"
#opts[:options].add_preference 'debuggerAdd... | [
"def",
"start_crmux!",
"(",
"opts",
")",
"self",
".",
"chrome_debugging_port",
"=",
"find_free_port",
"(",
"Capybara",
"::",
"ChromeDevTools",
".",
"preferred_port",
")",
"self",
".",
"crmux_listen_port",
"=",
"find_free_port",
"(",
"chrome_debugging_port",
"+",
"1"... | Starts crmux and adds debuggerAddress to opts that points to crmux listen address. | [
"Starts",
"crmux",
"and",
"adds",
"debuggerAddress",
"to",
"opts",
"that",
"points",
"to",
"crmux",
"listen",
"address",
"."
] | 805fcc4ac84a125e15577a278de98d5590610f04 | https://github.com/TylerRick/capybara-chrome_dev_tools/blob/805fcc4ac84a125e15577a278de98d5590610f04/lib/capybara/chrome_dev_tools/driver_extensions.rb#L36-L61 |
2,422 | bbc/hive-runner | lib/hive/device.rb | Hive.Device.start | def start
parent_pid = Process.pid
@worker_pid = Process.fork do
object = Object
@worker_class.split('::').each { |sub| object = object.const_get(sub) }
object.new(@options.merge('parent_pid' => parent_pid, 'device_identity' => self.identity, 'port_allocator' => self.port_allocator, ... | ruby | def start
parent_pid = Process.pid
@worker_pid = Process.fork do
object = Object
@worker_class.split('::').each { |sub| object = object.const_get(sub) }
object.new(@options.merge('parent_pid' => parent_pid, 'device_identity' => self.identity, 'port_allocator' => self.port_allocator, ... | [
"def",
"start",
"parent_pid",
"=",
"Process",
".",
"pid",
"@worker_pid",
"=",
"Process",
".",
"fork",
"do",
"object",
"=",
"Object",
"@worker_class",
".",
"split",
"(",
"'::'",
")",
".",
"each",
"{",
"|",
"sub",
"|",
"object",
"=",
"object",
".",
"cons... | Initialise the device
Start the worker process | [
"Initialise",
"the",
"device",
"Start",
"the",
"worker",
"process"
] | 9079f23362e201c342f416b5038d935e83e0de84 | https://github.com/bbc/hive-runner/blob/9079f23362e201c342f416b5038d935e83e0de84/lib/hive/device.rb#L23-L33 |
2,423 | bbc/hive-runner | lib/hive/device.rb | Hive.Device.stop | def stop
protect_file = File.expand_path("#{@worker_pid}.protect", PIDS_DIRECTORY)
Hive.logger.debug("Checking for protected file: #{protect_file}")
if File.exists? File.expand_path("#{@worker_pid}.protect", PIDS_DIRECTORY)
Hive.logger.debug("PID #{@worker_pid} is protected")
false
... | ruby | def stop
protect_file = File.expand_path("#{@worker_pid}.protect", PIDS_DIRECTORY)
Hive.logger.debug("Checking for protected file: #{protect_file}")
if File.exists? File.expand_path("#{@worker_pid}.protect", PIDS_DIRECTORY)
Hive.logger.debug("PID #{@worker_pid} is protected")
false
... | [
"def",
"stop",
"protect_file",
"=",
"File",
".",
"expand_path",
"(",
"\"#{@worker_pid}.protect\"",
",",
"PIDS_DIRECTORY",
")",
"Hive",
".",
"logger",
".",
"debug",
"(",
"\"Checking for protected file: #{protect_file}\"",
")",
"if",
"File",
".",
"exists?",
"File",
".... | Terminate the worker process | [
"Terminate",
"the",
"worker",
"process"
] | 9079f23362e201c342f416b5038d935e83e0de84 | https://github.com/bbc/hive-runner/blob/9079f23362e201c342f416b5038d935e83e0de84/lib/hive/device.rb#L36-L63 |
2,424 | powerpak/tqdm-ruby | lib/tqdm/printer.rb | Tqdm.Printer.padded_line | def padded_line(iteration, elapsed_time)
meter_line = line(iteration, elapsed_time)
pad_size = [@last_printed_length - meter_line.size, 0].max
@last_printed_length = meter_line.size
meter_line + ' ' * pad_size
end | ruby | def padded_line(iteration, elapsed_time)
meter_line = line(iteration, elapsed_time)
pad_size = [@last_printed_length - meter_line.size, 0].max
@last_printed_length = meter_line.size
meter_line + ' ' * pad_size
end | [
"def",
"padded_line",
"(",
"iteration",
",",
"elapsed_time",
")",
"meter_line",
"=",
"line",
"(",
"iteration",
",",
"elapsed_time",
")",
"pad_size",
"=",
"[",
"@last_printed_length",
"-",
"meter_line",
".",
"size",
",",
"0",
"]",
".",
"max",
"@last_printed_len... | Initialize a new Printer.
@param options [Hash] the options for the instantiating Tqdm::Decorator
@see Tqdm::Decorator#initialize
Pads a status line so that it is long enough to overwrite the previously written line
@param iteration [Integer] number of iterations, out of the total, that are completed
@param ela... | [
"Initialize",
"a",
"new",
"Printer",
"."
] | e67b364267e3d884329044b5cc9e1c4d1fd41637 | https://github.com/powerpak/tqdm-ruby/blob/e67b364267e3d884329044b5cc9e1c4d1fd41637/lib/tqdm/printer.rb#L32-L37 |
2,425 | potatosalad/ruby-erlang-terms | lib/erlang/tuple.rb | Erlang.Tuple.put | def put(index, element = yield(get(index)))
raise IndexError, "index #{index} outside of tuple bounds" if index < -@size
element = Erlang.from(element)
index += @size if index < 0
if index > @size
suffix = Array.new(index - @size, nil)
suffix << element
return replace_suf... | ruby | def put(index, element = yield(get(index)))
raise IndexError, "index #{index} outside of tuple bounds" if index < -@size
element = Erlang.from(element)
index += @size if index < 0
if index > @size
suffix = Array.new(index - @size, nil)
suffix << element
return replace_suf... | [
"def",
"put",
"(",
"index",
",",
"element",
"=",
"yield",
"(",
"get",
"(",
"index",
")",
")",
")",
"raise",
"IndexError",
",",
"\"index #{index} outside of tuple bounds\"",
"if",
"index",
"<",
"-",
"@size",
"element",
"=",
"Erlang",
".",
"from",
"(",
"elem... | Return a new `Tuple` with a new value at the given `index`. If `index`
is greater than the length of the tuple, the returned tuple will be
padded with `nil`s to the correct size.
@overload put(index, element)
Return a new `Tuple` with the element at `index` replaced by `element`.
@param element [Object] The ... | [
"Return",
"a",
"new",
"Tuple",
"with",
"a",
"new",
"value",
"at",
"the",
"given",
"index",
".",
"If",
"index",
"is",
"greater",
"than",
"the",
"length",
"of",
"the",
"tuple",
"the",
"returned",
"tuple",
"will",
"be",
"padded",
"with",
"nil",
"s",
"to",... | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/tuple.rb#L202-L213 |
2,426 | potatosalad/ruby-erlang-terms | lib/erlang/tuple.rb | Erlang.Tuple.fetch | def fetch(index, default = (missing_default = true))
if index >= -@size && index < @size
return get(index)
elsif block_given?
return Erlang.from(yield(index))
elsif !missing_default
return Erlang.from(default)
else
raise IndexError, "index #{index} outside of tupl... | ruby | def fetch(index, default = (missing_default = true))
if index >= -@size && index < @size
return get(index)
elsif block_given?
return Erlang.from(yield(index))
elsif !missing_default
return Erlang.from(default)
else
raise IndexError, "index #{index} outside of tupl... | [
"def",
"fetch",
"(",
"index",
",",
"default",
"=",
"(",
"missing_default",
"=",
"true",
")",
")",
"if",
"index",
">=",
"-",
"@size",
"&&",
"index",
"<",
"@size",
"return",
"get",
"(",
"index",
")",
"elsif",
"block_given?",
"return",
"Erlang",
".",
"fro... | Retrieve the value at `index` with optional default.
@overload fetch(index)
Retrieve the value at the given index, or raise an `IndexError` if not
found.
@param index [Integer] The index to look up
@raise [IndexError] if index does not exist
@example
t = Erlang::Tuple["A", "B", "C", "D"]
t.f... | [
"Retrieve",
"the",
"value",
"at",
"index",
"with",
"optional",
"default",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/tuple.rb#L298-L308 |
2,427 | potatosalad/ruby-erlang-terms | lib/erlang/tuple.rb | Erlang.Tuple.slice | def slice(arg, length = (missing_length = true))
if missing_length
if arg.is_a?(Range)
from, to = arg.begin, arg.end
from += @size if from < 0
to += @size if to < 0
to += 1 if !arg.exclude_end?
length = to - from
length = 0 if length < 0
... | ruby | def slice(arg, length = (missing_length = true))
if missing_length
if arg.is_a?(Range)
from, to = arg.begin, arg.end
from += @size if from < 0
to += @size if to < 0
to += 1 if !arg.exclude_end?
length = to - from
length = 0 if length < 0
... | [
"def",
"slice",
"(",
"arg",
",",
"length",
"=",
"(",
"missing_length",
"=",
"true",
")",
")",
"if",
"missing_length",
"if",
"arg",
".",
"is_a?",
"(",
"Range",
")",
"from",
",",
"to",
"=",
"arg",
".",
"begin",
",",
"arg",
".",
"end",
"from",
"+=",
... | Return specific objects from the `Tuple`. All overloads return `nil` if
the starting index is out of range.
@overload tuple.slice(index)
Returns a single object at the given `index`. If `index` is negative,
count backwards from the end.
@param index [Integer] The index to retrieve. May be negative.
@ret... | [
"Return",
"specific",
"objects",
"from",
"the",
"Tuple",
".",
"All",
"overloads",
"return",
"nil",
"if",
"the",
"starting",
"index",
"is",
"out",
"of",
"range",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/tuple.rb#L350-L367 |
2,428 | potatosalad/ruby-erlang-terms | lib/erlang/tuple.rb | Erlang.Tuple.insert | def insert(index, *elements)
raise IndexError if index < -@size
index += @size if index < 0
elements = elements.map { |element| Erlang.from(element) }
if index < @size
suffix = flatten_suffix(@root, @levels * BITS_PER_LEVEL, index, [])
suffix.unshift(*elements)
elsif inde... | ruby | def insert(index, *elements)
raise IndexError if index < -@size
index += @size if index < 0
elements = elements.map { |element| Erlang.from(element) }
if index < @size
suffix = flatten_suffix(@root, @levels * BITS_PER_LEVEL, index, [])
suffix.unshift(*elements)
elsif inde... | [
"def",
"insert",
"(",
"index",
",",
"*",
"elements",
")",
"raise",
"IndexError",
"if",
"index",
"<",
"-",
"@size",
"index",
"+=",
"@size",
"if",
"index",
"<",
"0",
"elements",
"=",
"elements",
".",
"map",
"{",
"|",
"element",
"|",
"Erlang",
".",
"fro... | Return a new `Tuple` with the given values inserted before the element
at `index`. If `index` is greater than the current length, `nil` values
are added to pad the `Tuple` to the required size.
@example
Erlang::Tuple["A", "B", "C", "D"].insert(2, "X", "Y", "Z")
# => Erlang::Tuple["A", "B", "X", "Y", "Z", "C",... | [
"Return",
"a",
"new",
"Tuple",
"with",
"the",
"given",
"values",
"inserted",
"before",
"the",
"element",
"at",
"index",
".",
"If",
"index",
"is",
"greater",
"than",
"the",
"current",
"length",
"nil",
"values",
"are",
"added",
"to",
"pad",
"the",
"Tuple",
... | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/tuple.rb#L384-L401 |
2,429 | potatosalad/ruby-erlang-terms | lib/erlang/tuple.rb | Erlang.Tuple.delete_at | def delete_at(index)
return self if index >= @size || index < -@size
index += @size if index < 0
suffix = flatten_suffix(@root, @levels * BITS_PER_LEVEL, index, [])
return replace_suffix(index, suffix.tap { |a| a.shift })
end | ruby | def delete_at(index)
return self if index >= @size || index < -@size
index += @size if index < 0
suffix = flatten_suffix(@root, @levels * BITS_PER_LEVEL, index, [])
return replace_suffix(index, suffix.tap { |a| a.shift })
end | [
"def",
"delete_at",
"(",
"index",
")",
"return",
"self",
"if",
"index",
">=",
"@size",
"||",
"index",
"<",
"-",
"@size",
"index",
"+=",
"@size",
"if",
"index",
"<",
"0",
"suffix",
"=",
"flatten_suffix",
"(",
"@root",
",",
"@levels",
"*",
"BITS_PER_LEVEL"... | Return a new `Tuple` with the element at `index` removed. If the given `index`
does not exist, return `self`.
@example
Erlang::Tuple["A", "B", "C", "D"].delete_at(2)
# => Erlang::Tuple["A", "B", "D"]
@param index [Integer] The index to remove
@return [Tuple] | [
"Return",
"a",
"new",
"Tuple",
"with",
"the",
"element",
"at",
"index",
"removed",
".",
"If",
"the",
"given",
"index",
"does",
"not",
"exist",
"return",
"self",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/tuple.rb#L412-L418 |
2,430 | potatosalad/ruby-erlang-terms | lib/erlang/tuple.rb | Erlang.Tuple.select | def select
return enum_for(:select) unless block_given?
return reduce(self.class.empty) { |tuple, element| yield(element) ? tuple.add(element) : tuple }
end | ruby | def select
return enum_for(:select) unless block_given?
return reduce(self.class.empty) { |tuple, element| yield(element) ? tuple.add(element) : tuple }
end | [
"def",
"select",
"return",
"enum_for",
"(",
":select",
")",
"unless",
"block_given?",
"return",
"reduce",
"(",
"self",
".",
"class",
".",
"empty",
")",
"{",
"|",
"tuple",
",",
"element",
"|",
"yield",
"(",
"element",
")",
"?",
"tuple",
".",
"add",
"(",... | Return a new `Tuple` containing all elements for which the given block returns
true.
@example
Erlang::Tuple["Bird", "Cow", "Elephant"].select { |e| e.size >= 4 }
# => Erlang::Tuple["Bird", "Elephant"]
@return [Tuple]
@yield [element] Once for each element. | [
"Return",
"a",
"new",
"Tuple",
"containing",
"all",
"elements",
"for",
"which",
"the",
"given",
"block",
"returns",
"true",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/tuple.rb#L501-L504 |
2,431 | potatosalad/ruby-erlang-terms | lib/erlang/tuple.rb | Erlang.Tuple.shuffle | def shuffle
return self.class.new(((array = to_a).frozen? ? array.shuffle : array.shuffle!).freeze)
end | ruby | def shuffle
return self.class.new(((array = to_a).frozen? ? array.shuffle : array.shuffle!).freeze)
end | [
"def",
"shuffle",
"return",
"self",
".",
"class",
".",
"new",
"(",
"(",
"(",
"array",
"=",
"to_a",
")",
".",
"frozen?",
"?",
"array",
".",
"shuffle",
":",
"array",
".",
"shuffle!",
")",
".",
"freeze",
")",
"end"
] | Return a new `Tuple` with the same elements as this one, but randomly permuted.
@example
Erlang::Tuple[1, 2, 3, 4].shuffle # => Erlang::Tuple[4, 1, 3, 2]
@return [Tuple] | [
"Return",
"a",
"new",
"Tuple",
"with",
"the",
"same",
"elements",
"as",
"this",
"one",
"but",
"randomly",
"permuted",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/tuple.rb#L556-L558 |
2,432 | potatosalad/ruby-erlang-terms | lib/erlang/tuple.rb | Erlang.Tuple.reverse | def reverse
return self.class.new(((array = to_a).frozen? ? array.reverse : array.reverse!).freeze)
end | ruby | def reverse
return self.class.new(((array = to_a).frozen? ? array.reverse : array.reverse!).freeze)
end | [
"def",
"reverse",
"return",
"self",
".",
"class",
".",
"new",
"(",
"(",
"(",
"array",
"=",
"to_a",
")",
".",
"frozen?",
"?",
"array",
".",
"reverse",
":",
"array",
".",
"reverse!",
")",
".",
"freeze",
")",
"end"
] | Return a new `Tuple` with the same elements as this one, but in reverse order.
@example
Erlang::Tuple["A", "B", "C"].reverse # => Erlang::Tuple["C", "B", "A"]
@return [Tuple] | [
"Return",
"a",
"new",
"Tuple",
"with",
"the",
"same",
"elements",
"as",
"this",
"one",
"but",
"in",
"reverse",
"order",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/tuple.rb#L593-L595 |
2,433 | potatosalad/ruby-erlang-terms | lib/erlang/tuple.rb | Erlang.Tuple.rotate | def rotate(count = 1)
return self if (count % @size) == 0
return self.class.new(((array = to_a).frozen? ? array.rotate(count) : array.rotate!(count)).freeze)
end | ruby | def rotate(count = 1)
return self if (count % @size) == 0
return self.class.new(((array = to_a).frozen? ? array.rotate(count) : array.rotate!(count)).freeze)
end | [
"def",
"rotate",
"(",
"count",
"=",
"1",
")",
"return",
"self",
"if",
"(",
"count",
"%",
"@size",
")",
"==",
"0",
"return",
"self",
".",
"class",
".",
"new",
"(",
"(",
"(",
"array",
"=",
"to_a",
")",
".",
"frozen?",
"?",
"array",
".",
"rotate",
... | Return a new `Tuple` with the same elements, but rotated so that the one at
index `count` is the first element of the new tuple. If `count` is positive,
the elements will be shifted left, and those shifted past the lowest position
will be moved to the end. If `count` is negative, the elements will be shifted
right,... | [
"Return",
"a",
"new",
"Tuple",
"with",
"the",
"same",
"elements",
"but",
"rotated",
"so",
"that",
"the",
"one",
"at",
"index",
"count",
"is",
"the",
"first",
"element",
"of",
"the",
"new",
"tuple",
".",
"If",
"count",
"is",
"positive",
"the",
"elements",... | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/tuple.rb#L610-L613 |
2,434 | potatosalad/ruby-erlang-terms | lib/erlang/tuple.rb | Erlang.Tuple.sort | def sort(&comparator)
comparator = Erlang.method(:compare) unless block_given?
array = super(&comparator)
return self.class.new(array)
end | ruby | def sort(&comparator)
comparator = Erlang.method(:compare) unless block_given?
array = super(&comparator)
return self.class.new(array)
end | [
"def",
"sort",
"(",
"&",
"comparator",
")",
"comparator",
"=",
"Erlang",
".",
"method",
"(",
":compare",
")",
"unless",
"block_given?",
"array",
"=",
"super",
"(",
"comparator",
")",
"return",
"self",
".",
"class",
".",
"new",
"(",
"array",
")",
"end"
] | Return a new `Tuple` with the same elements, but sorted.
@overload sort
Compare elements with their natural sort key (`#<=>`).
@example
Erlang::Tuple["Elephant", "Dog", "Lion"].sort
# => Erlang::Tuple["Dog", "Elephant", "Lion"]
@overload sort
Uses the block as a comparator to determine sorted or... | [
"Return",
"a",
"new",
"Tuple",
"with",
"the",
"same",
"elements",
"but",
"sorted",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/tuple.rb#L715-L719 |
2,435 | potatosalad/ruby-erlang-terms | lib/erlang/tuple.rb | Erlang.Tuple.drop | def drop(n)
return self if n == 0
return self.class.empty if n >= @size
raise ArgumentError, "attempt to drop negative size" if n < 0
return self.class.new(flatten_suffix(@root, @levels * BITS_PER_LEVEL, n, []))
end | ruby | def drop(n)
return self if n == 0
return self.class.empty if n >= @size
raise ArgumentError, "attempt to drop negative size" if n < 0
return self.class.new(flatten_suffix(@root, @levels * BITS_PER_LEVEL, n, []))
end | [
"def",
"drop",
"(",
"n",
")",
"return",
"self",
"if",
"n",
"==",
"0",
"return",
"self",
".",
"class",
".",
"empty",
"if",
"n",
">=",
"@size",
"raise",
"ArgumentError",
",",
"\"attempt to drop negative size\"",
"if",
"n",
"<",
"0",
"return",
"self",
".",
... | Drop the first `n` elements and return the rest in a new `Tuple`.
@example
Erlang::Tuple["A", "B", "C", "D", "E", "F"].drop(2)
# => Erlang::Tuple["C", "D", "E", "F"]
@param n [Integer] The number of elements to remove
@return [Tuple]
@raise ArgumentError if `n` is negative. | [
"Drop",
"the",
"first",
"n",
"elements",
"and",
"return",
"the",
"rest",
"in",
"a",
"new",
"Tuple",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/tuple.rb#L749-L754 |
2,436 | potatosalad/ruby-erlang-terms | lib/erlang/tuple.rb | Erlang.Tuple.* | def *(times)
return self.class.empty if times == 0
return self if times == 1
result = (to_a * times)
return result.is_a?(Array) ? self.class.new(result) : result
end | ruby | def *(times)
return self.class.empty if times == 0
return self if times == 1
result = (to_a * times)
return result.is_a?(Array) ? self.class.new(result) : result
end | [
"def",
"*",
"(",
"times",
")",
"return",
"self",
".",
"class",
".",
"empty",
"if",
"times",
"==",
"0",
"return",
"self",
"if",
"times",
"==",
"1",
"result",
"=",
"(",
"to_a",
"*",
"times",
")",
"return",
"result",
".",
"is_a?",
"(",
"Array",
")",
... | Repetition. Return a new `Tuple` built by concatenating `times` copies
of this one together.
@example
Erlang::Tuple["A", "B"] * 3
# => Erlang::Tuple["A", "B", "A", "B", "A", "B"]
@param times [Integer] The number of times to repeat the elements in this tuple
@return [Tuple] | [
"Repetition",
".",
"Return",
"a",
"new",
"Tuple",
"built",
"by",
"concatenating",
"times",
"copies",
"of",
"this",
"one",
"together",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/tuple.rb#L806-L811 |
2,437 | potatosalad/ruby-erlang-terms | lib/erlang/tuple.rb | Erlang.Tuple.combination | def combination(n)
return enum_for(:combination, n) if not block_given?
return self if n < 0 || @size < n
if n == 0
yield []
elsif n == 1
each { |element| yield [element] }
elsif n == @size
yield self.to_a
else
combos = lambda do |result,index,remainin... | ruby | def combination(n)
return enum_for(:combination, n) if not block_given?
return self if n < 0 || @size < n
if n == 0
yield []
elsif n == 1
each { |element| yield [element] }
elsif n == @size
yield self.to_a
else
combos = lambda do |result,index,remainin... | [
"def",
"combination",
"(",
"n",
")",
"return",
"enum_for",
"(",
":combination",
",",
"n",
")",
"if",
"not",
"block_given?",
"return",
"self",
"if",
"n",
"<",
"0",
"||",
"@size",
"<",
"n",
"if",
"n",
"==",
"0",
"yield",
"[",
"]",
"elsif",
"n",
"==",... | When invoked with a block, yields all combinations of length `n` of elements
from the `Tuple`, and then returns `self`. There is no guarantee about
which order the combinations will be yielded.
If no block is given, an `Enumerator` is returned instead.
@example
t = Erlang::Tuple[5, 6, 7, 8]
t.combination(3)... | [
"When",
"invoked",
"with",
"a",
"block",
"yields",
"all",
"combinations",
"of",
"length",
"n",
"of",
"elements",
"from",
"the",
"Tuple",
"and",
"then",
"returns",
"self",
".",
"There",
"is",
"no",
"guarantee",
"about",
"which",
"order",
"the",
"combinations"... | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/tuple.rb#L886-L911 |
2,438 | potatosalad/ruby-erlang-terms | lib/erlang/tuple.rb | Erlang.Tuple.repeated_combination | def repeated_combination(n)
return enum_for(:repeated_combination, n) if not block_given?
if n < 0
# yield nothing
elsif n == 0
yield []
elsif n == 1
each { |element| yield [element] }
elsif @size == 0
# yield nothing
else
combos = lambda do |r... | ruby | def repeated_combination(n)
return enum_for(:repeated_combination, n) if not block_given?
if n < 0
# yield nothing
elsif n == 0
yield []
elsif n == 1
each { |element| yield [element] }
elsif @size == 0
# yield nothing
else
combos = lambda do |r... | [
"def",
"repeated_combination",
"(",
"n",
")",
"return",
"enum_for",
"(",
":repeated_combination",
",",
"n",
")",
"if",
"not",
"block_given?",
"if",
"n",
"<",
"0",
"# yield nothing",
"elsif",
"n",
"==",
"0",
"yield",
"[",
"]",
"elsif",
"n",
"==",
"1",
"ea... | When invoked with a block, yields all repeated combinations of length `n` of
tuples from the `Tuple`, and then returns `self`. A "repeated combination" is
one in which any tuple from the `Tuple` can appear consecutively any number of
times.
There is no guarantee about which order the combinations will be yielded i... | [
"When",
"invoked",
"with",
"a",
"block",
"yields",
"all",
"repeated",
"combinations",
"of",
"length",
"n",
"of",
"tuples",
"from",
"the",
"Tuple",
"and",
"then",
"returns",
"self",
".",
"A",
"repeated",
"combination",
"is",
"one",
"in",
"which",
"any",
"tu... | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/tuple.rb#L939-L966 |
2,439 | potatosalad/ruby-erlang-terms | lib/erlang/tuple.rb | Erlang.Tuple.permutation | def permutation(n = @size)
return enum_for(:permutation, n) if not block_given?
if n < 0 || @size < n
# yield nothing
elsif n == 0
yield []
elsif n == 1
each { |element| yield [element] }
else
used, result = [], []
perms = lambda do |index|
... | ruby | def permutation(n = @size)
return enum_for(:permutation, n) if not block_given?
if n < 0 || @size < n
# yield nothing
elsif n == 0
yield []
elsif n == 1
each { |element| yield [element] }
else
used, result = [], []
perms = lambda do |index|
... | [
"def",
"permutation",
"(",
"n",
"=",
"@size",
")",
"return",
"enum_for",
"(",
":permutation",
",",
"n",
")",
"if",
"not",
"block_given?",
"if",
"n",
"<",
"0",
"||",
"@size",
"<",
"n",
"# yield nothing",
"elsif",
"n",
"==",
"0",
"yield",
"[",
"]",
"el... | Yields all permutations of length `n` of elements from the `Tuple`, and then
returns `self`. If no length `n` is specified, permutations of all elements
will be yielded.
There is no guarantee about which order the permutations will be yielded in.
If no block is given, an `Enumerator` is returned instead.
@examp... | [
"Yields",
"all",
"permutations",
"of",
"length",
"n",
"of",
"elements",
"from",
"the",
"Tuple",
"and",
"then",
"returns",
"self",
".",
"If",
"no",
"length",
"n",
"is",
"specified",
"permutations",
"of",
"all",
"elements",
"will",
"be",
"yielded",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/tuple.rb#L989-L1016 |
2,440 | potatosalad/ruby-erlang-terms | lib/erlang/tuple.rb | Erlang.Tuple.product | def product(*tuples)
tuples = tuples.map { |tuple| Erlang.from(tuple) }
# if no tuples passed, return "product" as in result of multiplying all elements
return super if tuples.empty?
tuples.unshift(self)
if tuples.any?(&:empty?)
return block_given? ? self : []
end
co... | ruby | def product(*tuples)
tuples = tuples.map { |tuple| Erlang.from(tuple) }
# if no tuples passed, return "product" as in result of multiplying all elements
return super if tuples.empty?
tuples.unshift(self)
if tuples.any?(&:empty?)
return block_given? ? self : []
end
co... | [
"def",
"product",
"(",
"*",
"tuples",
")",
"tuples",
"=",
"tuples",
".",
"map",
"{",
"|",
"tuple",
"|",
"Erlang",
".",
"from",
"(",
"tuple",
")",
"}",
"# if no tuples passed, return \"product\" as in result of multiplying all elements",
"return",
"super",
"if",
"t... | Cartesian product or multiplication.
@overload product(*tuples)
Return a `Tuple` of all combinations of elements from this `Tuple` and each
of the given tuples or arrays. The length of the returned `Tuple` is the product
of `self.size` and the size of each argument tuple or array.
@example
t1 = Erlan... | [
"Cartesian",
"product",
"or",
"multiplication",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/tuple.rb#L1087-L1129 |
2,441 | potatosalad/ruby-erlang-terms | lib/erlang/tuple.rb | Erlang.Tuple.rindex | def rindex(obj = (missing_arg = true))
obj = Erlang.from(obj)
i = @size - 1
if missing_arg
if block_given?
reverse_each { |element| return i if yield element; i -= 1 }
return nil
else
return enum_for(:rindex)
end
else
reverse_each { |... | ruby | def rindex(obj = (missing_arg = true))
obj = Erlang.from(obj)
i = @size - 1
if missing_arg
if block_given?
reverse_each { |element| return i if yield element; i -= 1 }
return nil
else
return enum_for(:rindex)
end
else
reverse_each { |... | [
"def",
"rindex",
"(",
"obj",
"=",
"(",
"missing_arg",
"=",
"true",
")",
")",
"obj",
"=",
"Erlang",
".",
"from",
"(",
"obj",
")",
"i",
"=",
"@size",
"-",
"1",
"if",
"missing_arg",
"if",
"block_given?",
"reverse_each",
"{",
"|",
"element",
"|",
"return... | Find the index of an element, starting from the end of the tuple.
Returns `nil` if no element is found.
@overload rindex(obj)
Return the index of the last element which is `#==` to `obj`.
@example
t = Erlang::Tuple[7, 8, 9, 7, 8, 9]
t.rindex(8) # => 4
@overload rindex
Return the index of the la... | [
"Find",
"the",
"index",
"of",
"an",
"element",
"starting",
"from",
"the",
"end",
"of",
"the",
"tuple",
".",
"Returns",
"nil",
"if",
"no",
"element",
"is",
"found",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/tuple.rb#L1266-L1280 |
2,442 | potatosalad/ruby-erlang-terms | lib/erlang/enumerable.rb | Erlang.Enumerable.partition | def partition
return enum_for(:partition) if not block_given?
a,b = super
return Erlang::Tuple[self.class.new(a), self.class.new(b)]
end | ruby | def partition
return enum_for(:partition) if not block_given?
a,b = super
return Erlang::Tuple[self.class.new(a), self.class.new(b)]
end | [
"def",
"partition",
"return",
"enum_for",
"(",
":partition",
")",
"if",
"not",
"block_given?",
"a",
",",
"b",
"=",
"super",
"return",
"Erlang",
"::",
"Tuple",
"[",
"self",
".",
"class",
".",
"new",
"(",
"a",
")",
",",
"self",
".",
"class",
".",
"new"... | Return 2 collections, the first containing all the elements for which the block
evaluates to true, the second containing the rest. | [
"Return",
"2",
"collections",
"the",
"first",
"containing",
"all",
"the",
"elements",
"for",
"which",
"the",
"block",
"evaluates",
"to",
"true",
"the",
"second",
"containing",
"the",
"rest",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/enumerable.rb#L89-L93 |
2,443 | potatosalad/ruby-erlang-terms | lib/erlang/enumerable.rb | Erlang.Enumerable.inspect | def inspect
result = "#{self.class}["
each_with_index { |obj, i| result << ', ' if i > 0; result << obj.inspect }
return result << "]"
end | ruby | def inspect
result = "#{self.class}["
each_with_index { |obj, i| result << ', ' if i > 0; result << obj.inspect }
return result << "]"
end | [
"def",
"inspect",
"result",
"=",
"\"#{self.class}[\"",
"each_with_index",
"{",
"|",
"obj",
",",
"i",
"|",
"result",
"<<",
"', '",
"if",
"i",
">",
"0",
";",
"result",
"<<",
"obj",
".",
"inspect",
"}",
"return",
"result",
"<<",
"\"]\"",
"end"
] | Convert this collection to a programmer-readable `String` representation. | [
"Convert",
"this",
"collection",
"to",
"a",
"programmer",
"-",
"readable",
"String",
"representation",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/enumerable.rb#L131-L135 |
2,444 | potatosalad/ruby-erlang-terms | lib/erlang/list.rb | Erlang.List.each | def each
raise Erlang::ImproperListError if improper?
return to_enum unless block_given?
list = self
until list.empty?
yield(list.head)
list = list.tail
end
return self
end | ruby | def each
raise Erlang::ImproperListError if improper?
return to_enum unless block_given?
list = self
until list.empty?
yield(list.head)
list = list.tail
end
return self
end | [
"def",
"each",
"raise",
"Erlang",
"::",
"ImproperListError",
"if",
"improper?",
"return",
"to_enum",
"unless",
"block_given?",
"list",
"=",
"self",
"until",
"list",
".",
"empty?",
"yield",
"(",
"list",
".",
"head",
")",
"list",
"=",
"list",
".",
"tail",
"e... | Call the given block once for each item in the list, passing each
item from first to last successively to the block. If no block is given,
returns an `Enumerator`.
@return [self]
@yield [item] | [
"Call",
"the",
"given",
"block",
"once",
"for",
"each",
"item",
"in",
"the",
"list",
"passing",
"each",
"item",
"from",
"first",
"to",
"last",
"successively",
"to",
"the",
"block",
".",
"If",
"no",
"block",
"is",
"given",
"returns",
"an",
"Enumerator",
"... | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/list.rb#L151-L160 |
2,445 | potatosalad/ruby-erlang-terms | lib/erlang/list.rb | Erlang.List.flat_map | def flat_map(&block)
raise Erlang::ImproperListError if improper?
return enum_for(:flat_map) unless block_given?
return self if empty?
out = tail = Erlang::Cons.allocate
list = self
until list.empty?
head_list = Erlang::List.from_enum(yield(list.head))
if head_list.em... | ruby | def flat_map(&block)
raise Erlang::ImproperListError if improper?
return enum_for(:flat_map) unless block_given?
return self if empty?
out = tail = Erlang::Cons.allocate
list = self
until list.empty?
head_list = Erlang::List.from_enum(yield(list.head))
if head_list.em... | [
"def",
"flat_map",
"(",
"&",
"block",
")",
"raise",
"Erlang",
"::",
"ImproperListError",
"if",
"improper?",
"return",
"enum_for",
"(",
":flat_map",
")",
"unless",
"block_given?",
"return",
"self",
"if",
"empty?",
"out",
"=",
"tail",
"=",
"Erlang",
"::",
"Con... | Return a `List` which is realized by transforming each item into a `List`,
and flattening the resulting lists.
@example
Erlang::List[1, 2, 3].flat_map { |x| Erlang::List[x, 100] }
# => Erlang::List[1, 100, 2, 100, 3, 100]
@return [List] | [
"Return",
"a",
"List",
"which",
"is",
"realized",
"by",
"transforming",
"each",
"item",
"into",
"a",
"List",
"and",
"flattening",
"the",
"resulting",
"lists",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/list.rb#L203-L237 |
2,446 | potatosalad/ruby-erlang-terms | lib/erlang/list.rb | Erlang.List.select | def select(&block)
raise Erlang::ImproperListError if improper?
return enum_for(:select) unless block_given?
out = tail = Erlang::Cons.allocate
list = self
while !list.empty?
if yield(list.head)
new_node = Erlang::Cons.allocate
new_node.instance_variable_set(:@h... | ruby | def select(&block)
raise Erlang::ImproperListError if improper?
return enum_for(:select) unless block_given?
out = tail = Erlang::Cons.allocate
list = self
while !list.empty?
if yield(list.head)
new_node = Erlang::Cons.allocate
new_node.instance_variable_set(:@h... | [
"def",
"select",
"(",
"&",
"block",
")",
"raise",
"Erlang",
"::",
"ImproperListError",
"if",
"improper?",
"return",
"enum_for",
"(",
":select",
")",
"unless",
"block_given?",
"out",
"=",
"tail",
"=",
"Erlang",
"::",
"Cons",
".",
"allocate",
"list",
"=",
"s... | Return a `List` which contains all the items for which the given block
returns true.
@example
Erlang::List["Bird", "Cow", "Elephant"].select { |e| e.size >= 4 }
# => Erlang::List["Bird", "Elephant"]
@return [List]
@yield [item] Once for each item. | [
"Return",
"a",
"List",
"which",
"contains",
"all",
"the",
"items",
"for",
"which",
"the",
"given",
"block",
"returns",
"true",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/list.rb#L248-L272 |
2,447 | potatosalad/ruby-erlang-terms | lib/erlang/list.rb | Erlang.List.drop_while | def drop_while(&block)
raise Erlang::ImproperListError if improper?
return enum_for(:drop_while) unless block_given?
list = self
list = list.tail while !list.empty? && yield(list.head)
return list
end | ruby | def drop_while(&block)
raise Erlang::ImproperListError if improper?
return enum_for(:drop_while) unless block_given?
list = self
list = list.tail while !list.empty? && yield(list.head)
return list
end | [
"def",
"drop_while",
"(",
"&",
"block",
")",
"raise",
"Erlang",
"::",
"ImproperListError",
"if",
"improper?",
"return",
"enum_for",
"(",
":drop_while",
")",
"unless",
"block_given?",
"list",
"=",
"self",
"list",
"=",
"list",
".",
"tail",
"while",
"!",
"list"... | Return a `List` which contains all elements starting from the
first element for which the block returns `nil` or `false`.
@example
Erlang::List[1, 3, 5, 7, 6, 4, 2].drop_while { |e| e < 5 }
# => Erlang::List[5, 7, 6, 4, 2]
@return [List, Enumerator]
@yield [item] | [
"Return",
"a",
"List",
"which",
"contains",
"all",
"elements",
"starting",
"from",
"the",
"first",
"element",
"for",
"which",
"the",
"block",
"returns",
"nil",
"or",
"false",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/list.rb#L317-L323 |
2,448 | potatosalad/ruby-erlang-terms | lib/erlang/list.rb | Erlang.List.pop | def pop
raise Erlang::ImproperListError if improper?
return self if empty?
new_size = size - 1
return Erlang::List.new(head, tail.take(new_size - 1)) if new_size >= 1
return Erlang::Nil
end | ruby | def pop
raise Erlang::ImproperListError if improper?
return self if empty?
new_size = size - 1
return Erlang::List.new(head, tail.take(new_size - 1)) if new_size >= 1
return Erlang::Nil
end | [
"def",
"pop",
"raise",
"Erlang",
"::",
"ImproperListError",
"if",
"improper?",
"return",
"self",
"if",
"empty?",
"new_size",
"=",
"size",
"-",
"1",
"return",
"Erlang",
"::",
"List",
".",
"new",
"(",
"head",
",",
"tail",
".",
"take",
"(",
"new_size",
"-",... | Return a `List` containing all but the last item from this `List`.
@example
Erlang::List["A", "B", "C"].pop # => Erlang::List["A", "B"]
@return [List] | [
"Return",
"a",
"List",
"containing",
"all",
"but",
"the",
"last",
"item",
"from",
"this",
"List",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/list.rb#L363-L369 |
2,449 | potatosalad/ruby-erlang-terms | lib/erlang/list.rb | Erlang.List.drop | def drop(number)
raise Erlang::ImproperListError if improper?
list = self
while !list.empty? && number > 0
number -= 1
list = list.tail
end
return list
end | ruby | def drop(number)
raise Erlang::ImproperListError if improper?
list = self
while !list.empty? && number > 0
number -= 1
list = list.tail
end
return list
end | [
"def",
"drop",
"(",
"number",
")",
"raise",
"Erlang",
"::",
"ImproperListError",
"if",
"improper?",
"list",
"=",
"self",
"while",
"!",
"list",
".",
"empty?",
"&&",
"number",
">",
"0",
"number",
"-=",
"1",
"list",
"=",
"list",
".",
"tail",
"end",
"retur... | Return a `List` containing all items after the first `number` items from
this `List`.
@example
Erlang::List[1, 3, 5, 7, 6, 4, 2].drop(3)
# => Erlang::List[7, 6, 4, 2]
@param number [Integer] The number of items to skip over
@return [List] | [
"Return",
"a",
"List",
"containing",
"all",
"items",
"after",
"the",
"first",
"number",
"items",
"from",
"this",
"List",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/list.rb#L380-L388 |
2,450 | potatosalad/ruby-erlang-terms | lib/erlang/list.rb | Erlang.List.append | def append(other)
# raise Erlang::ImproperListError if improper?
other = Erlang.from(other)
return self if not improper? and Erlang.is_list(other) and other.empty?
return other if Erlang.is_list(other) and empty?
is_improper = Erlang.is_list(other) ? other.improper? : true
out = tail... | ruby | def append(other)
# raise Erlang::ImproperListError if improper?
other = Erlang.from(other)
return self if not improper? and Erlang.is_list(other) and other.empty?
return other if Erlang.is_list(other) and empty?
is_improper = Erlang.is_list(other) ? other.improper? : true
out = tail... | [
"def",
"append",
"(",
"other",
")",
"# raise Erlang::ImproperListError if improper?",
"other",
"=",
"Erlang",
".",
"from",
"(",
"other",
")",
"return",
"self",
"if",
"not",
"improper?",
"and",
"Erlang",
".",
"is_list",
"(",
"other",
")",
"and",
"other",
".",
... | Return a `List` with all items from this `List`, followed by all items from
`other`.
@example
Erlang::List[1, 2, 3].append(Erlang::List[4, 5])
# => Erlang::List[1, 2, 3, 4, 5]
@param other [List] The list to add onto the end of this one
@return [List] | [
"Return",
"a",
"List",
"with",
"all",
"items",
"from",
"this",
"List",
"followed",
"by",
"all",
"items",
"from",
"other",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/list.rb#L399-L433 |
2,451 | potatosalad/ruby-erlang-terms | lib/erlang/list.rb | Erlang.List.transpose | def transpose
raise Erlang::ImproperListError if improper?
return Erlang::Nil if empty?
return Erlang::Nil if any? { |list| list.empty? }
heads, tails = Erlang::Nil, Erlang::Nil
reverse_each { |list| heads, tails = heads.cons(list.head), tails.cons(list.tail) }
return Erlang::Cons.ne... | ruby | def transpose
raise Erlang::ImproperListError if improper?
return Erlang::Nil if empty?
return Erlang::Nil if any? { |list| list.empty? }
heads, tails = Erlang::Nil, Erlang::Nil
reverse_each { |list| heads, tails = heads.cons(list.head), tails.cons(list.tail) }
return Erlang::Cons.ne... | [
"def",
"transpose",
"raise",
"Erlang",
"::",
"ImproperListError",
"if",
"improper?",
"return",
"Erlang",
"::",
"Nil",
"if",
"empty?",
"return",
"Erlang",
"::",
"Nil",
"if",
"any?",
"{",
"|",
"list",
"|",
"list",
".",
"empty?",
"}",
"heads",
",",
"tails",
... | Gather the first element of each nested list into a new `List`, then the second
element of each nested list, then the third, and so on. In other words, if each
nested list is a "row", return a `List` of "columns" instead.
@return [List] | [
"Gather",
"the",
"first",
"element",
"of",
"each",
"nested",
"list",
"into",
"a",
"new",
"List",
"then",
"the",
"second",
"element",
"of",
"each",
"nested",
"list",
"then",
"the",
"third",
"and",
"so",
"on",
".",
"In",
"other",
"words",
"if",
"each",
"... | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/list.rb#L490-L497 |
2,452 | potatosalad/ruby-erlang-terms | lib/erlang/list.rb | Erlang.List.rotate | def rotate(count = 1)
raise Erlang::ImproperListError if improper?
raise TypeError, "expected Integer" if not count.is_a?(Integer)
return self if empty? || (count % size) == 0
count = (count >= 0) ? count % size : (size - (~count % size) - 1)
return drop(count).append(take(count))
end | ruby | def rotate(count = 1)
raise Erlang::ImproperListError if improper?
raise TypeError, "expected Integer" if not count.is_a?(Integer)
return self if empty? || (count % size) == 0
count = (count >= 0) ? count % size : (size - (~count % size) - 1)
return drop(count).append(take(count))
end | [
"def",
"rotate",
"(",
"count",
"=",
"1",
")",
"raise",
"Erlang",
"::",
"ImproperListError",
"if",
"improper?",
"raise",
"TypeError",
",",
"\"expected Integer\"",
"if",
"not",
"count",
".",
"is_a?",
"(",
"Integer",
")",
"return",
"self",
"if",
"empty?",
"||",... | Return a new `List` with the same elements, but rotated so that the one at
index `count` is the first element of the new list. If `count` is positive,
the elements will be shifted left, and those shifted past the lowest position
will be moved to the end. If `count` is negative, the elements will be shifted
right, a... | [
"Return",
"a",
"new",
"List",
"with",
"the",
"same",
"elements",
"but",
"rotated",
"so",
"that",
"the",
"one",
"at",
"index",
"count",
"is",
"the",
"first",
"element",
"of",
"the",
"new",
"list",
".",
"If",
"count",
"is",
"positive",
"the",
"elements",
... | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/list.rb#L513-L519 |
2,453 | potatosalad/ruby-erlang-terms | lib/erlang/list.rb | Erlang.List.sort | def sort(&comparator)
comparator = Erlang.method(:compare) unless block_given?
array = super(&comparator)
return List.from_enum(array)
end | ruby | def sort(&comparator)
comparator = Erlang.method(:compare) unless block_given?
array = super(&comparator)
return List.from_enum(array)
end | [
"def",
"sort",
"(",
"&",
"comparator",
")",
"comparator",
"=",
"Erlang",
".",
"method",
"(",
":compare",
")",
"unless",
"block_given?",
"array",
"=",
"super",
"(",
"comparator",
")",
"return",
"List",
".",
"from_enum",
"(",
"array",
")",
"end"
] | Return a new `List` with the same items, but sorted.
@overload sort
Compare elements with their natural sort key (`#<=>`).
@example
Erlang::List["Elephant", "Dog", "Lion"].sort
# => Erlang::List["Dog", "Elephant", "Lion"]
@overload sort
Uses the block as a comparator to determine sorted order.
... | [
"Return",
"a",
"new",
"List",
"with",
"the",
"same",
"items",
"but",
"sorted",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/list.rb#L613-L617 |
2,454 | potatosalad/ruby-erlang-terms | lib/erlang/list.rb | Erlang.List.intersperse | def intersperse(sep)
raise Erlang::ImproperListError if improper?
return self if tail.empty?
sep = Erlang.from(sep)
out = tail = Erlang::Cons.allocate
list = self
until list.empty?
new_node = Erlang::Cons.allocate
new_node.instance_variable_set(:@head, list.head)
... | ruby | def intersperse(sep)
raise Erlang::ImproperListError if improper?
return self if tail.empty?
sep = Erlang.from(sep)
out = tail = Erlang::Cons.allocate
list = self
until list.empty?
new_node = Erlang::Cons.allocate
new_node.instance_variable_set(:@head, list.head)
... | [
"def",
"intersperse",
"(",
"sep",
")",
"raise",
"Erlang",
"::",
"ImproperListError",
"if",
"improper?",
"return",
"self",
"if",
"tail",
".",
"empty?",
"sep",
"=",
"Erlang",
".",
"from",
"(",
"sep",
")",
"out",
"=",
"tail",
"=",
"Erlang",
"::",
"Cons",
... | Return a new `List` with `sep` inserted between each of the existing elements.
@example
Erlang::List["one", "two", "three"].intersperse(" ")
# => Erlang::List["one", " ", "two", " ", "three"]
@return [List] | [
"Return",
"a",
"new",
"List",
"with",
"sep",
"inserted",
"between",
"each",
"of",
"the",
"existing",
"elements",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/list.rb#L645-L677 |
2,455 | potatosalad/ruby-erlang-terms | lib/erlang/list.rb | Erlang.List.union | def union(other)
raise Erlang::ImproperListError if improper?
other = Erlang.from(other)
raise ArgumentError, "other must be of Erlang::List type" if not Erlang.is_list(other)
raise Erlang::ImproperListError if other.improper?
items = ::Set.new
return _uniq(items).append(other._uniq(... | ruby | def union(other)
raise Erlang::ImproperListError if improper?
other = Erlang.from(other)
raise ArgumentError, "other must be of Erlang::List type" if not Erlang.is_list(other)
raise Erlang::ImproperListError if other.improper?
items = ::Set.new
return _uniq(items).append(other._uniq(... | [
"def",
"union",
"(",
"other",
")",
"raise",
"Erlang",
"::",
"ImproperListError",
"if",
"improper?",
"other",
"=",
"Erlang",
".",
"from",
"(",
"other",
")",
"raise",
"ArgumentError",
",",
"\"other must be of Erlang::List type\"",
"if",
"not",
"Erlang",
".",
"is_l... | Return a `List` with all the elements from both this list and `other`,
with all duplicates removed.
@example
Erlang::List[1, 2].union(Erlang::List[2, 3]) # => Erlang::List[1, 2, 3]
@param other [List] The list to merge with
@return [List] | [
"Return",
"a",
"List",
"with",
"all",
"the",
"elements",
"from",
"both",
"this",
"list",
"and",
"other",
"with",
"all",
"duplicates",
"removed",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/list.rb#L750-L757 |
2,456 | potatosalad/ruby-erlang-terms | lib/erlang/list.rb | Erlang.List.init | def init
raise Erlang::ImproperListError if improper?
return Erlang::Nil if tail.empty?
out = tail = Erlang::Cons.allocate
list = self
until list.tail.empty?
new_node = Erlang::Cons.allocate
new_node.instance_variable_set(:@head, list.head)
new_node.instance_variabl... | ruby | def init
raise Erlang::ImproperListError if improper?
return Erlang::Nil if tail.empty?
out = tail = Erlang::Cons.allocate
list = self
until list.tail.empty?
new_node = Erlang::Cons.allocate
new_node.instance_variable_set(:@head, list.head)
new_node.instance_variabl... | [
"def",
"init",
"raise",
"Erlang",
"::",
"ImproperListError",
"if",
"improper?",
"return",
"Erlang",
"::",
"Nil",
"if",
"tail",
".",
"empty?",
"out",
"=",
"tail",
"=",
"Erlang",
"::",
"Cons",
".",
"allocate",
"list",
"=",
"self",
"until",
"list",
".",
"ta... | Return a `List` with all elements except the last one.
@example
Erlang::List["a", "b", "c"].init # => Erlang::List["a", "b"]
@return [List] | [
"Return",
"a",
"List",
"with",
"all",
"elements",
"except",
"the",
"last",
"one",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/list.rb#L766-L786 |
2,457 | potatosalad/ruby-erlang-terms | lib/erlang/list.rb | Erlang.List.last | def last(allow_improper = false)
if allow_improper and improper?
list = self
list = list.tail while list.tail.kind_of?(Erlang::List)
return list.tail
else
raise Erlang::ImproperListError if improper?
list = self
list = list.tail until list.tail.empty?
... | ruby | def last(allow_improper = false)
if allow_improper and improper?
list = self
list = list.tail while list.tail.kind_of?(Erlang::List)
return list.tail
else
raise Erlang::ImproperListError if improper?
list = self
list = list.tail until list.tail.empty?
... | [
"def",
"last",
"(",
"allow_improper",
"=",
"false",
")",
"if",
"allow_improper",
"and",
"improper?",
"list",
"=",
"self",
"list",
"=",
"list",
".",
"tail",
"while",
"list",
".",
"tail",
".",
"kind_of?",
"(",
"Erlang",
"::",
"List",
")",
"return",
"list",... | Return the last item in this list.
@return [Object] | [
"Return",
"the",
"last",
"item",
"in",
"this",
"list",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/list.rb#L790-L801 |
2,458 | potatosalad/ruby-erlang-terms | lib/erlang/list.rb | Erlang.List.tails | def tails
raise Erlang::ImproperListError if improper?
return self if empty?
out = tail = Erlang::Cons.allocate
list = self
until list.empty?
new_node = Erlang::Cons.allocate
new_node.instance_variable_set(:@head, list)
new_node.instance_variable_set(:@improper, fal... | ruby | def tails
raise Erlang::ImproperListError if improper?
return self if empty?
out = tail = Erlang::Cons.allocate
list = self
until list.empty?
new_node = Erlang::Cons.allocate
new_node.instance_variable_set(:@head, list)
new_node.instance_variable_set(:@improper, fal... | [
"def",
"tails",
"raise",
"Erlang",
"::",
"ImproperListError",
"if",
"improper?",
"return",
"self",
"if",
"empty?",
"out",
"=",
"tail",
"=",
"Erlang",
"::",
"Cons",
".",
"allocate",
"list",
"=",
"self",
"until",
"list",
".",
"empty?",
"new_node",
"=",
"Erla... | Return a `List` of all suffixes of this list.
@example
Erlang::List[1,2,3].tails
# => Erlang::List[
# Erlang::List[1, 2, 3],
# Erlang::List[2, 3],
# Erlang::List[3]]
@return [List] | [
"Return",
"a",
"List",
"of",
"all",
"suffixes",
"of",
"this",
"list",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/list.rb#L813-L828 |
2,459 | potatosalad/ruby-erlang-terms | lib/erlang/list.rb | Erlang.List.inits | def inits
raise Erlang::ImproperListError if improper?
return self if empty?
prev = nil
return map do |head|
if prev.nil?
Erlang::List.from_enum(prev = [head])
else
Erlang::List.from_enum(prev.push(head))
end
end
end | ruby | def inits
raise Erlang::ImproperListError if improper?
return self if empty?
prev = nil
return map do |head|
if prev.nil?
Erlang::List.from_enum(prev = [head])
else
Erlang::List.from_enum(prev.push(head))
end
end
end | [
"def",
"inits",
"raise",
"Erlang",
"::",
"ImproperListError",
"if",
"improper?",
"return",
"self",
"if",
"empty?",
"prev",
"=",
"nil",
"return",
"map",
"do",
"|",
"head",
"|",
"if",
"prev",
".",
"nil?",
"Erlang",
"::",
"List",
".",
"from_enum",
"(",
"pre... | Return a `List` of all prefixes of this list.
@example
Erlang::List[1,2,3].inits
# => Erlang::List[
# Erlang::List[1],
# Erlang::List[1, 2],
# Erlang::List[1, 2, 3]]
@return [List] | [
"Return",
"a",
"List",
"of",
"all",
"prefixes",
"of",
"this",
"list",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/list.rb#L840-L851 |
2,460 | potatosalad/ruby-erlang-terms | lib/erlang/list.rb | Erlang.List.combination | def combination(n)
raise Erlang::ImproperListError if improper?
return Erlang::Cons.new(Erlang::Nil) if n == 0
return self if empty?
return tail.combination(n - 1).map { |list| list.cons(head) }.append(tail.combination(n))
end | ruby | def combination(n)
raise Erlang::ImproperListError if improper?
return Erlang::Cons.new(Erlang::Nil) if n == 0
return self if empty?
return tail.combination(n - 1).map { |list| list.cons(head) }.append(tail.combination(n))
end | [
"def",
"combination",
"(",
"n",
")",
"raise",
"Erlang",
"::",
"ImproperListError",
"if",
"improper?",
"return",
"Erlang",
"::",
"Cons",
".",
"new",
"(",
"Erlang",
"::",
"Nil",
")",
"if",
"n",
"==",
"0",
"return",
"self",
"if",
"empty?",
"return",
"tail",... | Return a `List` of all combinations of length `n` of items from this `List`.
@example
Erlang::List[1,2,3].combination(2)
# => Erlang::List[
# Erlang::List[1, 2],
# Erlang::List[1, 3],
# Erlang::List[2, 3]]
@return [List] | [
"Return",
"a",
"List",
"of",
"all",
"combinations",
"of",
"length",
"n",
"of",
"items",
"from",
"this",
"List",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/list.rb#L863-L868 |
2,461 | potatosalad/ruby-erlang-terms | lib/erlang/list.rb | Erlang.List.chunk | def chunk(number)
raise Erlang::ImproperListError if improper?
return self if empty?
out = tail = Erlang::Cons.allocate
list = self
until list.empty?
first, list = list.split_at(number)
new_node = Erlang::Cons.allocate
new_node.instance_variable_set(:@head, first)
... | ruby | def chunk(number)
raise Erlang::ImproperListError if improper?
return self if empty?
out = tail = Erlang::Cons.allocate
list = self
until list.empty?
first, list = list.split_at(number)
new_node = Erlang::Cons.allocate
new_node.instance_variable_set(:@head, first)
... | [
"def",
"chunk",
"(",
"number",
")",
"raise",
"Erlang",
"::",
"ImproperListError",
"if",
"improper?",
"return",
"self",
"if",
"empty?",
"out",
"=",
"tail",
"=",
"Erlang",
"::",
"Cons",
".",
"allocate",
"list",
"=",
"self",
"until",
"list",
".",
"empty?",
... | Split the items in this list in groups of `number`. Return a list of lists.
@example
("a".."o").to_list.chunk(5)
# => Erlang::List[
# Erlang::List["a", "b", "c", "d", "e"],
# Erlang::List["f", "g", "h", "i", "j"],
# Erlang::List["k", "l", "m", "n", "o"]]
@return [List] | [
"Split",
"the",
"items",
"in",
"this",
"list",
"in",
"groups",
"of",
"number",
".",
"Return",
"a",
"list",
"of",
"lists",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/list.rb#L880-L900 |
2,462 | potatosalad/ruby-erlang-terms | lib/erlang/list.rb | Erlang.List.flatten | def flatten
raise Erlang::ImproperListError if improper?
return self if empty?
out = tail = Erlang::Cons.allocate
list = self
until list.empty?
if list.head.is_a?(Erlang::Cons)
list = list.head.append(list.tail)
elsif Erlang::Nil.equal?(list.head)
list =... | ruby | def flatten
raise Erlang::ImproperListError if improper?
return self if empty?
out = tail = Erlang::Cons.allocate
list = self
until list.empty?
if list.head.is_a?(Erlang::Cons)
list = list.head.append(list.tail)
elsif Erlang::Nil.equal?(list.head)
list =... | [
"def",
"flatten",
"raise",
"Erlang",
"::",
"ImproperListError",
"if",
"improper?",
"return",
"self",
"if",
"empty?",
"out",
"=",
"tail",
"=",
"Erlang",
"::",
"Cons",
".",
"allocate",
"list",
"=",
"self",
"until",
"list",
".",
"empty?",
"if",
"list",
".",
... | Return a new `List` with all nested lists recursively "flattened out",
that is, their elements inserted into the new `List` in the place where
the nested list originally was.
@example
Erlang::List[Erlang::List[1, 2], Erlang::List[3, 4]].flatten
# => Erlang::List[1, 2, 3, 4]
@return [List] | [
"Return",
"a",
"new",
"List",
"with",
"all",
"nested",
"lists",
"recursively",
"flattened",
"out",
"that",
"is",
"their",
"elements",
"inserted",
"into",
"the",
"new",
"List",
"in",
"the",
"place",
"where",
"the",
"nested",
"list",
"originally",
"was",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/list.rb#L925-L950 |
2,463 | potatosalad/ruby-erlang-terms | lib/erlang/list.rb | Erlang.List.slice | def slice(arg, length = (missing_length = true))
raise Erlang::ImproperListError if improper?
if missing_length
if arg.is_a?(Range)
from, to = arg.begin, arg.end
from += size if from < 0
return nil if from < 0
to += size if to < 0
to += 1 if !... | ruby | def slice(arg, length = (missing_length = true))
raise Erlang::ImproperListError if improper?
if missing_length
if arg.is_a?(Range)
from, to = arg.begin, arg.end
from += size if from < 0
return nil if from < 0
to += size if to < 0
to += 1 if !... | [
"def",
"slice",
"(",
"arg",
",",
"length",
"=",
"(",
"missing_length",
"=",
"true",
")",
")",
"raise",
"Erlang",
"::",
"ImproperListError",
"if",
"improper?",
"if",
"missing_length",
"if",
"arg",
".",
"is_a?",
"(",
"Range",
")",
"from",
",",
"to",
"=",
... | Return specific objects from the `List`. All overloads return `nil` if
the starting index is out of range.
@overload list.slice(index)
Returns a single object at the given `index`. If `index` is negative,
count backwards from the end.
@param index [Integer] The index to retrieve. May be negative.
@retur... | [
"Return",
"specific",
"objects",
"from",
"the",
"List",
".",
"All",
"overloads",
"return",
"nil",
"if",
"the",
"starting",
"index",
"is",
"out",
"of",
"range",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/list.rb#L1027-L1060 |
2,464 | potatosalad/ruby-erlang-terms | lib/erlang/list.rb | Erlang.List.indices | def indices(object = Erlang::Undefined, i = 0, &block)
raise Erlang::ImproperListError if improper?
object = Erlang.from(object) if object != Erlang::Undefined
return indices { |item| item == object } if not block_given?
return Erlang::Nil if empty?
out = tail = Erlang::Cons.allocate
... | ruby | def indices(object = Erlang::Undefined, i = 0, &block)
raise Erlang::ImproperListError if improper?
object = Erlang.from(object) if object != Erlang::Undefined
return indices { |item| item == object } if not block_given?
return Erlang::Nil if empty?
out = tail = Erlang::Cons.allocate
... | [
"def",
"indices",
"(",
"object",
"=",
"Erlang",
"::",
"Undefined",
",",
"i",
"=",
"0",
",",
"&",
"block",
")",
"raise",
"Erlang",
"::",
"ImproperListError",
"if",
"improper?",
"object",
"=",
"Erlang",
".",
"from",
"(",
"object",
")",
"if",
"object",
"!... | Return a `List` of indices of matching objects.
@overload indices(object)
Return a `List` of indices where `object` is found. Use `#==` for
testing equality.
@example
Erlang::List[1, 2, 3, 4].indices(2)
# => Erlang::List[1]
@overload indices
Pass each item successively to the block. Return a ... | [
"Return",
"a",
"List",
"of",
"indices",
"of",
"matching",
"objects",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/list.rb#L1083-L1110 |
2,465 | potatosalad/ruby-erlang-terms | lib/erlang/list.rb | Erlang.List.merge | def merge(&comparator)
raise Erlang::ImproperListError if improper?
return merge_by unless block_given?
sorted = reject(&:empty?).sort do |a, b|
yield(a.head, b.head)
end
return Erlang::Nil if sorted.empty?
return Erlang::Cons.new(sorted.head.head, sorted.tail.cons(sorted.hea... | ruby | def merge(&comparator)
raise Erlang::ImproperListError if improper?
return merge_by unless block_given?
sorted = reject(&:empty?).sort do |a, b|
yield(a.head, b.head)
end
return Erlang::Nil if sorted.empty?
return Erlang::Cons.new(sorted.head.head, sorted.tail.cons(sorted.hea... | [
"def",
"merge",
"(",
"&",
"comparator",
")",
"raise",
"Erlang",
"::",
"ImproperListError",
"if",
"improper?",
"return",
"merge_by",
"unless",
"block_given?",
"sorted",
"=",
"reject",
"(",
":empty?",
")",
".",
"sort",
"do",
"|",
"a",
",",
"b",
"|",
"yield",... | Merge all the nested lists into a single list, using the given comparator
block to determine the order which items should be shifted out of the nested
lists and into the output list.
@example
list_1 = Erlang::List[1, -3, -5]
list_2 = Erlang::List[-2, 4, 6]
Erlang::List[list_1, list_2].merge { |a,b| a.abs <... | [
"Merge",
"all",
"the",
"nested",
"lists",
"into",
"a",
"single",
"list",
"using",
"the",
"given",
"comparator",
"block",
"to",
"determine",
"the",
"order",
"which",
"items",
"should",
"be",
"shifted",
"out",
"of",
"the",
"nested",
"lists",
"and",
"into",
"... | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/list.rb#L1127-L1135 |
2,466 | potatosalad/ruby-erlang-terms | lib/erlang/list.rb | Erlang.List.insert | def insert(index, *items)
raise Erlang::ImproperListError if improper?
if index == 0
return Erlang::List.from_enum(items).append(self)
elsif index > 0
out = tail = Erlang::Cons.allocate
list = self
while index > 0
new_node = Erlang::Cons.allocate
new... | ruby | def insert(index, *items)
raise Erlang::ImproperListError if improper?
if index == 0
return Erlang::List.from_enum(items).append(self)
elsif index > 0
out = tail = Erlang::Cons.allocate
list = self
while index > 0
new_node = Erlang::Cons.allocate
new... | [
"def",
"insert",
"(",
"index",
",",
"*",
"items",
")",
"raise",
"Erlang",
"::",
"ImproperListError",
"if",
"improper?",
"if",
"index",
"==",
"0",
"return",
"Erlang",
"::",
"List",
".",
"from_enum",
"(",
"items",
")",
".",
"append",
"(",
"self",
")",
"e... | Return a new `List` with the given items inserted before the item at `index`.
@example
Erlang::List["A", "D", "E"].insert(1, "B", "C") # => Erlang::List["A", "B", "C", "D", "E"]
@param index [Integer] The index where the new items should go
@param items [Array] The items to add
@return [List] | [
"Return",
"a",
"new",
"List",
"with",
"the",
"given",
"items",
"inserted",
"before",
"the",
"item",
"at",
"index",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/list.rb#L1176-L1203 |
2,467 | potatosalad/ruby-erlang-terms | lib/erlang/list.rb | Erlang.List.delete_at | def delete_at(index)
raise Erlang::ImproperListError if improper?
if index == 0
tail
elsif index < 0
index += size if index < 0
return self if index < 0
delete_at(index)
else
out = tail = Erlang::Cons.allocate
list = self
while index > 0
... | ruby | def delete_at(index)
raise Erlang::ImproperListError if improper?
if index == 0
tail
elsif index < 0
index += size if index < 0
return self if index < 0
delete_at(index)
else
out = tail = Erlang::Cons.allocate
list = self
while index > 0
... | [
"def",
"delete_at",
"(",
"index",
")",
"raise",
"Erlang",
"::",
"ImproperListError",
"if",
"improper?",
"if",
"index",
"==",
"0",
"tail",
"elsif",
"index",
"<",
"0",
"index",
"+=",
"size",
"if",
"index",
"<",
"0",
"return",
"self",
"if",
"index",
"<",
... | Return a `List` containing the same items, minus the one at `index`.
If `index` is negative, it counts back from the end of the list.
@example
Erlang::List[1, 2, 3].delete_at(1) # => Erlang::List[1, 3]
Erlang::List[1, 2, 3].delete_at(-1) # => Erlang::List[1, 2]
@param index [Integer] The index of the item t... | [
"Return",
"a",
"List",
"containing",
"the",
"same",
"items",
"minus",
"the",
"one",
"at",
"index",
".",
"If",
"index",
"is",
"negative",
"it",
"counts",
"back",
"from",
"the",
"end",
"of",
"the",
"list",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/list.rb#L1250-L1278 |
2,468 | potatosalad/ruby-erlang-terms | lib/erlang/list.rb | Erlang.List.permutation | def permutation(length = size, &block)
raise Erlang::ImproperListError if improper?
return enum_for(:permutation, length) if not block_given?
if length == 0
yield Erlang::Nil
elsif length == 1
each { |obj| yield Erlang::Cons.new(obj, Erlang::Nil) }
elsif not empty?
... | ruby | def permutation(length = size, &block)
raise Erlang::ImproperListError if improper?
return enum_for(:permutation, length) if not block_given?
if length == 0
yield Erlang::Nil
elsif length == 1
each { |obj| yield Erlang::Cons.new(obj, Erlang::Nil) }
elsif not empty?
... | [
"def",
"permutation",
"(",
"length",
"=",
"size",
",",
"&",
"block",
")",
"raise",
"Erlang",
"::",
"ImproperListError",
"if",
"improper?",
"return",
"enum_for",
"(",
":permutation",
",",
"length",
")",
"if",
"not",
"block_given?",
"if",
"length",
"==",
"0",
... | Yields all permutations of length `n` of the items in the list, and then
returns `self`. If no length `n` is specified, permutations of the entire
list will be yielded.
There is no guarantee about which order the permutations will be yielded in.
If no block is given, an `Enumerator` is returned instead.
@exampl... | [
"Yields",
"all",
"permutations",
"of",
"length",
"n",
"of",
"the",
"items",
"in",
"the",
"list",
"and",
"then",
"returns",
"self",
".",
"If",
"no",
"length",
"n",
"is",
"specified",
"permutations",
"of",
"the",
"entire",
"list",
"will",
"be",
"yielded",
... | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/list.rb#L1400-L1420 |
2,469 | potatosalad/ruby-erlang-terms | lib/erlang/list.rb | Erlang.List.partition | def partition(&block)
raise Erlang::ImproperListError if improper?
return enum_for(:partition) if not block_given?
left = left_tail = Erlang::Cons.allocate
right = right_tail = Erlang::Cons.allocate
list = self
while !list.empty?
if yield(list.head)
new_node = Erlan... | ruby | def partition(&block)
raise Erlang::ImproperListError if improper?
return enum_for(:partition) if not block_given?
left = left_tail = Erlang::Cons.allocate
right = right_tail = Erlang::Cons.allocate
list = self
while !list.empty?
if yield(list.head)
new_node = Erlan... | [
"def",
"partition",
"(",
"&",
"block",
")",
"raise",
"Erlang",
"::",
"ImproperListError",
"if",
"improper?",
"return",
"enum_for",
"(",
":partition",
")",
"if",
"not",
"block_given?",
"left",
"=",
"left_tail",
"=",
"Erlang",
"::",
"Cons",
".",
"allocate",
"r... | Return two `List`s, the first containing all the elements for which the
block evaluates to true, the second containing the rest.
@example
Erlang::List[1, 2, 3, 4, 5, 6].partition { |x| x.even? }
# => Erlang::Tuple[Erlang::List[2, 4, 6], Erlang::List[1, 3, 5]]
@return [Tuple]
@yield [item] Once for each item... | [
"Return",
"two",
"List",
"s",
"the",
"first",
"containing",
"all",
"the",
"elements",
"for",
"which",
"the",
"block",
"evaluates",
"to",
"true",
"the",
"second",
"containing",
"the",
"rest",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/list.rb#L1458-L1494 |
2,470 | potatosalad/ruby-erlang-terms | lib/erlang/list.rb | Erlang.List.inspect | def inspect
if improper?
result = 'Erlang::List['
list = to_proper_list
list.each_with_index { |obj, i| result << ', ' if i > 0; result << obj.inspect }
result << ']'
result << " + #{last(true).inspect}"
return result
else
result = '['
list = s... | ruby | def inspect
if improper?
result = 'Erlang::List['
list = to_proper_list
list.each_with_index { |obj, i| result << ', ' if i > 0; result << obj.inspect }
result << ']'
result << " + #{last(true).inspect}"
return result
else
result = '['
list = s... | [
"def",
"inspect",
"if",
"improper?",
"result",
"=",
"'Erlang::List['",
"list",
"=",
"to_proper_list",
"list",
".",
"each_with_index",
"{",
"|",
"obj",
",",
"i",
"|",
"result",
"<<",
"', '",
"if",
"i",
">",
"0",
";",
"result",
"<<",
"obj",
".",
"inspect",... | Return the contents of this `List` as a programmer-readable `String`. If all the
items in the list are serializable as Ruby literal strings, the returned string can
be passed to `eval` to reconstitute an equivalent `List`.
@return [::String] | [
"Return",
"the",
"contents",
"of",
"this",
"List",
"as",
"a",
"programmer",
"-",
"readable",
"String",
".",
"If",
"all",
"the",
"items",
"in",
"the",
"list",
"are",
"serializable",
"as",
"Ruby",
"literal",
"strings",
"the",
"returned",
"string",
"can",
"be... | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/list.rb#L1647-L1662 |
2,471 | potatosalad/ruby-erlang-terms | lib/erlang/binary.rb | Erlang.Binary.copy | def copy(n = 1)
raise ArgumentError, 'n must be a non-negative Integer' if not n.is_a?(::Integer) or n < 0
return self if n == 1
return Erlang::Binary[(@data * n)]
end | ruby | def copy(n = 1)
raise ArgumentError, 'n must be a non-negative Integer' if not n.is_a?(::Integer) or n < 0
return self if n == 1
return Erlang::Binary[(@data * n)]
end | [
"def",
"copy",
"(",
"n",
"=",
"1",
")",
"raise",
"ArgumentError",
",",
"'n must be a non-negative Integer'",
"if",
"not",
"n",
".",
"is_a?",
"(",
"::",
"Integer",
")",
"or",
"n",
"<",
"0",
"return",
"self",
"if",
"n",
"==",
"1",
"return",
"Erlang",
"::... | Returns a new `Binary` containing `n` copies of itself. `n` must be greater than or equal to 0.
@param n [Integer] The number of copies
@return [Binary]
@raise [ArgumentError] if `n` is less than 0 | [
"Returns",
"a",
"new",
"Binary",
"containing",
"n",
"copies",
"of",
"itself",
".",
"n",
"must",
"be",
"greater",
"than",
"or",
"equal",
"to",
"0",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/binary.rb#L225-L229 |
2,472 | potatosalad/ruby-erlang-terms | lib/erlang/binary.rb | Erlang.Binary.each_bit | def each_bit
return enum_for(:each_bit) unless block_given?
index = 0
bitsize = self.bitsize
@data.each_byte do |byte|
loop do
break if index == bitsize
bit = (byte >> (7 - (index & 7))) & 1
yield bit
index += 1
break if (index & 7) == 0
... | ruby | def each_bit
return enum_for(:each_bit) unless block_given?
index = 0
bitsize = self.bitsize
@data.each_byte do |byte|
loop do
break if index == bitsize
bit = (byte >> (7 - (index & 7))) & 1
yield bit
index += 1
break if (index & 7) == 0
... | [
"def",
"each_bit",
"return",
"enum_for",
"(",
":each_bit",
")",
"unless",
"block_given?",
"index",
"=",
"0",
"bitsize",
"=",
"self",
".",
"bitsize",
"@data",
".",
"each_byte",
"do",
"|",
"byte",
"|",
"loop",
"do",
"break",
"if",
"index",
"==",
"bitsize",
... | Call the given block once for each bit in the `Binary`, passing each
bit from first to last successively to the block. If no block is given,
returns an `Enumerator`.
@return [self]
@yield [Integer] | [
"Call",
"the",
"given",
"block",
"once",
"for",
"each",
"bit",
"in",
"the",
"Binary",
"passing",
"each",
"bit",
"from",
"first",
"to",
"last",
"successively",
"to",
"the",
"block",
".",
"If",
"no",
"block",
"is",
"given",
"returns",
"an",
"Enumerator",
"... | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/binary.rb#L245-L259 |
2,473 | potatosalad/ruby-erlang-terms | lib/erlang/binary.rb | Erlang.Binary.part | def part(position, length)
raise ArgumentError, 'position must be an Integer' if not position.is_a?(::Integer)
raise ArgumentError, 'length must be a non-negative Integer' if not length.is_a?(::Integer) or length < 0
return Erlang::Binary[@data.byteslice(position, length)]
end | ruby | def part(position, length)
raise ArgumentError, 'position must be an Integer' if not position.is_a?(::Integer)
raise ArgumentError, 'length must be a non-negative Integer' if not length.is_a?(::Integer) or length < 0
return Erlang::Binary[@data.byteslice(position, length)]
end | [
"def",
"part",
"(",
"position",
",",
"length",
")",
"raise",
"ArgumentError",
",",
"'position must be an Integer'",
"if",
"not",
"position",
".",
"is_a?",
"(",
"::",
"Integer",
")",
"raise",
"ArgumentError",
",",
"'length must be a non-negative Integer'",
"if",
"not... | Returns the section of this `Binary` starting at `position` of `length`.
@param position [Integer] The starting position
@param length [Integer] The non-negative length
@return [Binary]
@raise [ArgumentError] if `position` is not an `Integer` or `length` is not a non-negative `Integer` | [
"Returns",
"the",
"section",
"of",
"this",
"Binary",
"starting",
"at",
"position",
"of",
"length",
"."
] | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/binary.rb#L336-L340 |
2,474 | langalex/culerity | lib/culerity/remote_browser_proxy.rb | Culerity.RemoteBrowserProxy.wait_until | def wait_until time_to_wait=30, &block
time_limit = Time.now + time_to_wait
until block.call
if Time.now > time_limit
raise "wait_until timeout after #{time_to_wait} seconds"
end
sleep 0.1
end
true
end | ruby | def wait_until time_to_wait=30, &block
time_limit = Time.now + time_to_wait
until block.call
if Time.now > time_limit
raise "wait_until timeout after #{time_to_wait} seconds"
end
sleep 0.1
end
true
end | [
"def",
"wait_until",
"time_to_wait",
"=",
"30",
",",
"&",
"block",
"time_limit",
"=",
"Time",
".",
"now",
"+",
"time_to_wait",
"until",
"block",
".",
"call",
"if",
"Time",
".",
"now",
">",
"time_limit",
"raise",
"\"wait_until timeout after #{time_to_wait} seconds\... | Calls the block until it returns true or +time_to_wait+ is reached.
+time_to_wait+ is 30 seconds by default
Returns true upon success
Raises RuntimeError when +time_to_wait+ is reached. | [
"Calls",
"the",
"block",
"until",
"it",
"returns",
"true",
"or",
"+",
"time_to_wait",
"+",
"is",
"reached",
".",
"+",
"time_to_wait",
"+",
"is",
"30",
"seconds",
"by",
"default"
] | 8e330ce79e88d00a213ece7755a22f4e0ca4f042 | https://github.com/langalex/culerity/blob/8e330ce79e88d00a213ece7755a22f4e0ca4f042/lib/culerity/remote_browser_proxy.rb#L18-L27 |
2,475 | langalex/culerity | lib/culerity/remote_browser_proxy.rb | Culerity.RemoteBrowserProxy.confirm | def confirm(bool, &block)
blk = "lambda { #{bool} }"
self.send_remote(:add_listener, :confirm) { blk }
block.call
self.send_remote(:remove_listener, :confirm, lambda {blk})
end | ruby | def confirm(bool, &block)
blk = "lambda { #{bool} }"
self.send_remote(:add_listener, :confirm) { blk }
block.call
self.send_remote(:remove_listener, :confirm, lambda {blk})
end | [
"def",
"confirm",
"(",
"bool",
",",
"&",
"block",
")",
"blk",
"=",
"\"lambda { #{bool} }\"",
"self",
".",
"send_remote",
"(",
":add_listener",
",",
":confirm",
")",
"{",
"blk",
"}",
"block",
".",
"call",
"self",
".",
"send_remote",
"(",
":remove_listener",
... | Specify whether to accept or reject all confirm js dialogs
for the code in the block that's run. | [
"Specify",
"whether",
"to",
"accept",
"or",
"reject",
"all",
"confirm",
"js",
"dialogs",
"for",
"the",
"code",
"in",
"the",
"block",
"that",
"s",
"run",
"."
] | 8e330ce79e88d00a213ece7755a22f4e0ca4f042 | https://github.com/langalex/culerity/blob/8e330ce79e88d00a213ece7755a22f4e0ca4f042/lib/culerity/remote_browser_proxy.rb#L52-L58 |
2,476 | uasi/pixiv | lib/pixiv/page.rb | Pixiv.Page.bind | def bind(client)
if self.class.const_defined?(:WithClient)
mod = self.class.const_get(:WithClient)
else
mod = Page::WithClient
end
unless singleton_class.include?(mod)
extend(mod)
end
self.client = client
self
end | ruby | def bind(client)
if self.class.const_defined?(:WithClient)
mod = self.class.const_get(:WithClient)
else
mod = Page::WithClient
end
unless singleton_class.include?(mod)
extend(mod)
end
self.client = client
self
end | [
"def",
"bind",
"(",
"client",
")",
"if",
"self",
".",
"class",
".",
"const_defined?",
"(",
":WithClient",
")",
"mod",
"=",
"self",
".",
"class",
".",
"const_get",
"(",
":WithClient",
")",
"else",
"mod",
"=",
"Page",
"::",
"WithClient",
"end",
"unless",
... | Bind +self+ to +client+
@api private
@return self | [
"Bind",
"+",
"self",
"+",
"to",
"+",
"client",
"+"
] | 6750829692fa9c3f56605d3319616072756c9d7c | https://github.com/uasi/pixiv/blob/6750829692fa9c3f56605d3319616072756c9d7c/lib/pixiv/page.rb#L58-L69 |
2,477 | uasi/pixiv | lib/pixiv/client.rb | Pixiv.Client.login | def login(pixiv_id, password)
doc = agent.get("https://accounts.pixiv.net/login?lang=ja&source=pc&view_type=page")
return if doc && doc.body =~ /logout/
form = doc.forms_with(action: '/login').first
puts doc.body and raise Error::LoginFailed, 'login form is not available' unless form
form.... | ruby | def login(pixiv_id, password)
doc = agent.get("https://accounts.pixiv.net/login?lang=ja&source=pc&view_type=page")
return if doc && doc.body =~ /logout/
form = doc.forms_with(action: '/login').first
puts doc.body and raise Error::LoginFailed, 'login form is not available' unless form
form.... | [
"def",
"login",
"(",
"pixiv_id",
",",
"password",
")",
"doc",
"=",
"agent",
".",
"get",
"(",
"\"https://accounts.pixiv.net/login?lang=ja&source=pc&view_type=page\"",
")",
"return",
"if",
"doc",
"&&",
"doc",
".",
"body",
"=~",
"/",
"/",
"form",
"=",
"doc",
".",... | A new instance of Client, logged in with the given credentials
@overload initialize(pixiv_id, password)
@param [String] pixiv_id
@param [String] password
@yield [agent] (optional) gives a chance to customize the +agent+ before logging in
@overload initialize(agent)
@param [Mechanize::HTTP::Agent] agent
@... | [
"A",
"new",
"instance",
"of",
"Client",
"logged",
"in",
"with",
"the",
"given",
"credentials"
] | 6750829692fa9c3f56605d3319616072756c9d7c | https://github.com/uasi/pixiv/blob/6750829692fa9c3f56605d3319616072756c9d7c/lib/pixiv/client.rb#L43-L53 |
2,478 | uasi/pixiv | lib/pixiv/client.rb | Pixiv.Client.download_illust | def download_illust(illust, io_or_filename, size = :original)
size = {:s => :small, :m => :medium, :o => :original}[size] || size
url = illust.__send__("#{size}_image_url")
referer = case size
when :small then nil
when :medium then illust.url
when :origi... | ruby | def download_illust(illust, io_or_filename, size = :original)
size = {:s => :small, :m => :medium, :o => :original}[size] || size
url = illust.__send__("#{size}_image_url")
referer = case size
when :small then nil
when :medium then illust.url
when :origi... | [
"def",
"download_illust",
"(",
"illust",
",",
"io_or_filename",
",",
"size",
"=",
":original",
")",
"size",
"=",
"{",
":s",
"=>",
":small",
",",
":m",
"=>",
":medium",
",",
":o",
"=>",
":original",
"}",
"[",
"size",
"]",
"||",
"size",
"url",
"=",
"il... | Downloads the image to +io_or_filename+
@param [Pixiv::Illust] illust
@param [#write, String, Array<String, Symbol, #call>] io_or_filename io or filename or pattern for {#filename_from_pattern}
@param [Symbol] size image size (+:small+, +:medium+, or +:original+) | [
"Downloads",
"the",
"image",
"to",
"+",
"io_or_filename",
"+"
] | 6750829692fa9c3f56605d3319616072756c9d7c | https://github.com/uasi/pixiv/blob/6750829692fa9c3f56605d3319616072756c9d7c/lib/pixiv/client.rb#L141-L156 |
2,479 | uasi/pixiv | lib/pixiv/client.rb | Pixiv.Client.download_manga | def download_manga(illust, pattern, &block)
action = DownloadActionRegistry.new(&block)
illust.original_image_urls.each_with_index do |url, n|
begin
action.before_each.call(url, n) if action.before_each
filename = filename_from_pattern(pattern, illust, url)
FileUtils.mk... | ruby | def download_manga(illust, pattern, &block)
action = DownloadActionRegistry.new(&block)
illust.original_image_urls.each_with_index do |url, n|
begin
action.before_each.call(url, n) if action.before_each
filename = filename_from_pattern(pattern, illust, url)
FileUtils.mk... | [
"def",
"download_manga",
"(",
"illust",
",",
"pattern",
",",
"&",
"block",
")",
"action",
"=",
"DownloadActionRegistry",
".",
"new",
"(",
"block",
")",
"illust",
".",
"original_image_urls",
".",
"each_with_index",
"do",
"|",
"url",
",",
"n",
"|",
"begin",
... | Downloads the images to +pattern+
@param [Pixiv::Illust] illust the manga to download
@param [Array<String, Symbol, #call>] pattern pattern for {#filename_from_pattern}
@note +illust#manga?+ must be +true+
@todo Document +&block+ | [
"Downloads",
"the",
"images",
"to",
"+",
"pattern",
"+"
] | 6750829692fa9c3f56605d3319616072756c9d7c | https://github.com/uasi/pixiv/blob/6750829692fa9c3f56605d3319616072756c9d7c/lib/pixiv/client.rb#L163-L176 |
2,480 | uasi/pixiv | lib/pixiv/client.rb | Pixiv.Client.filename_from_pattern | def filename_from_pattern(pattern, illust, url)
pattern.map {|i|
if i == :image_name
name = File.basename(url)
if name =~ /\.(\w+)\?\d+$/
name += '.' + $1
end
name
elsif i.is_a?(Symbol) then illust.send(i)
elsif i.respond_to?(:call) then ... | ruby | def filename_from_pattern(pattern, illust, url)
pattern.map {|i|
if i == :image_name
name = File.basename(url)
if name =~ /\.(\w+)\?\d+$/
name += '.' + $1
end
name
elsif i.is_a?(Symbol) then illust.send(i)
elsif i.respond_to?(:call) then ... | [
"def",
"filename_from_pattern",
"(",
"pattern",
",",
"illust",
",",
"url",
")",
"pattern",
".",
"map",
"{",
"|",
"i",
"|",
"if",
"i",
"==",
":image_name",
"name",
"=",
"File",
".",
"basename",
"(",
"url",
")",
"if",
"name",
"=~",
"/",
"\\.",
"\\w",
... | Generate filename from +pattern+ in context of +illust+ and +url+
@api private
@param [Array<String, Symbol, #call>] pattern
@param [Pixiv::Illust] illust
@param [String] url
@return [String] filename
The +pattern+ is an array of string, symbol, or object that responds to +#call+.
Each component of the +patter... | [
"Generate",
"filename",
"from",
"+",
"pattern",
"+",
"in",
"context",
"of",
"+",
"illust",
"+",
"and",
"+",
"url",
"+"
] | 6750829692fa9c3f56605d3319616072756c9d7c | https://github.com/uasi/pixiv/blob/6750829692fa9c3f56605d3319616072756c9d7c/lib/pixiv/client.rb#L194-L207 |
2,481 | lantins/dns-zone | lib/dns/zone.rb | DNS.Zone.soa | def soa
# return the first SOA we find in the records array.
rr = @records.find { |rr| rr.type == "SOA" }
return rr if rr
# otherwise create a new SOA
rr = DNS::Zone::RR::SOA.new
rr.serial = Time.now.utc.strftime("%Y%m%d01")
rr.refresh_ttl = '3h'
rr.retry_ttl = '15m'
... | ruby | def soa
# return the first SOA we find in the records array.
rr = @records.find { |rr| rr.type == "SOA" }
return rr if rr
# otherwise create a new SOA
rr = DNS::Zone::RR::SOA.new
rr.serial = Time.now.utc.strftime("%Y%m%d01")
rr.refresh_ttl = '3h'
rr.retry_ttl = '15m'
... | [
"def",
"soa",
"# return the first SOA we find in the records array.",
"rr",
"=",
"@records",
".",
"find",
"{",
"|",
"rr",
"|",
"rr",
".",
"type",
"==",
"\"SOA\"",
"}",
"return",
"rr",
"if",
"rr",
"# otherwise create a new SOA",
"rr",
"=",
"DNS",
"::",
"Zone",
... | Create an empty instance of a DNS zone that you can drive programmatically.
@api public
Helper method to access the zones SOA RR.
@api public | [
"Create",
"an",
"empty",
"instance",
"of",
"a",
"DNS",
"zone",
"that",
"you",
"can",
"drive",
"programmatically",
"."
] | f60cbfd7ec72217288be6c6ece9a83c22350cb58 | https://github.com/lantins/dns-zone/blob/f60cbfd7ec72217288be6c6ece9a83c22350cb58/lib/dns/zone.rb#L36-L50 |
2,482 | lantins/dns-zone | lib/dns/zone.rb | DNS.Zone.dump_pretty | def dump_pretty
content = []
last_type = "SOA"
sorted_records.each do |rr|
content << '' if last_type != rr.type
content << rr.dump
last_type = rr.type
end
content.join("\n") << "\n"
end | ruby | def dump_pretty
content = []
last_type = "SOA"
sorted_records.each do |rr|
content << '' if last_type != rr.type
content << rr.dump
last_type = rr.type
end
content.join("\n") << "\n"
end | [
"def",
"dump_pretty",
"content",
"=",
"[",
"]",
"last_type",
"=",
"\"SOA\"",
"sorted_records",
".",
"each",
"do",
"|",
"rr",
"|",
"content",
"<<",
"''",
"if",
"last_type",
"!=",
"rr",
".",
"type",
"content",
"<<",
"rr",
".",
"dump",
"last_type",
"=",
"... | Generates pretty output of the zone and its records.
@api public | [
"Generates",
"pretty",
"output",
"of",
"the",
"zone",
"and",
"its",
"records",
"."
] | f60cbfd7ec72217288be6c6ece9a83c22350cb58 | https://github.com/lantins/dns-zone/blob/f60cbfd7ec72217288be6c6ece9a83c22350cb58/lib/dns/zone.rb#L68-L79 |
2,483 | lantins/dns-zone | lib/dns/zone.rb | DNS.Zone.sorted_records | def sorted_records
# pull out RRs we want to stick near the top
top_rrs = {}
top = %w{SOA NS MX SPF TXT}
top.each { |t| top_rrs[t] = @records.select { |rr| rr.type == t } }
remaining = @records.reject { |rr| top.include?(rr.type) }
# sort remaining RRs by type, alphabeticly
r... | ruby | def sorted_records
# pull out RRs we want to stick near the top
top_rrs = {}
top = %w{SOA NS MX SPF TXT}
top.each { |t| top_rrs[t] = @records.select { |rr| rr.type == t } }
remaining = @records.reject { |rr| top.include?(rr.type) }
# sort remaining RRs by type, alphabeticly
r... | [
"def",
"sorted_records",
"# pull out RRs we want to stick near the top",
"top_rrs",
"=",
"{",
"}",
"top",
"=",
"%w{",
"SOA",
"NS",
"MX",
"SPF",
"TXT",
"}",
"top",
".",
"each",
"{",
"|",
"t",
"|",
"top_rrs",
"[",
"t",
"]",
"=",
"@records",
".",
"select",
... | Records sorted with more important types being at the top.
@api private | [
"Records",
"sorted",
"with",
"more",
"important",
"types",
"being",
"at",
"the",
"top",
"."
] | f60cbfd7ec72217288be6c6ece9a83c22350cb58 | https://github.com/lantins/dns-zone/blob/f60cbfd7ec72217288be6c6ece9a83c22350cb58/lib/dns/zone.rb#L191-L203 |
2,484 | potatosalad/ruby-erlang-terms | lib/erlang/associable.rb | Erlang.Associable.update_in | def update_in(*key_path, &block)
if key_path.empty?
raise ArgumentError, "must have at least one key in path"
end
key = key_path[0]
if key_path.size == 1
new_value = block.call(fetch(key, nil))
else
value = fetch(key, EmptyMap)
new_value = value.update_in(*k... | ruby | def update_in(*key_path, &block)
if key_path.empty?
raise ArgumentError, "must have at least one key in path"
end
key = key_path[0]
if key_path.size == 1
new_value = block.call(fetch(key, nil))
else
value = fetch(key, EmptyMap)
new_value = value.update_in(*k... | [
"def",
"update_in",
"(",
"*",
"key_path",
",",
"&",
"block",
")",
"if",
"key_path",
".",
"empty?",
"raise",
"ArgumentError",
",",
"\"must have at least one key in path\"",
"end",
"key",
"=",
"key_path",
"[",
"0",
"]",
"if",
"key_path",
".",
"size",
"==",
"1"... | Return a new container with a deeply nested value modified to the result
of the given code block. When traversing the nested containers
non-existing keys are created with empty `Hash` values.
The code block receives the existing value of the deeply nested key/index
(or `nil` if it doesn't exist). This is useful f... | [
"Return",
"a",
"new",
"container",
"with",
"a",
"deeply",
"nested",
"value",
"modified",
"to",
"the",
"result",
"of",
"the",
"given",
"code",
"block",
".",
"When",
"traversing",
"the",
"nested",
"containers",
"non",
"-",
"existing",
"keys",
"are",
"created",... | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/associable.rb#L63-L75 |
2,485 | potatosalad/ruby-erlang-terms | lib/erlang/associable.rb | Erlang.Associable.dig | def dig(key, *rest)
value = get(key)
if rest.empty? || value.nil?
return value
elsif value.respond_to?(:dig)
return value.dig(*rest)
end
end | ruby | def dig(key, *rest)
value = get(key)
if rest.empty? || value.nil?
return value
elsif value.respond_to?(:dig)
return value.dig(*rest)
end
end | [
"def",
"dig",
"(",
"key",
",",
"*",
"rest",
")",
"value",
"=",
"get",
"(",
"key",
")",
"if",
"rest",
".",
"empty?",
"||",
"value",
".",
"nil?",
"return",
"value",
"elsif",
"value",
".",
"respond_to?",
"(",
":dig",
")",
"return",
"value",
".",
"dig"... | Return the value of successively indexing into a collection.
If any of the keys is not present in the collection, return `nil`.
keys that the Erlang type doesn't understand, raises an argument error
@example
m = Erlang::Map[:a => 9, :b => Erlang::Tuple['a', 'b'], :e => nil]
m.dig(:b, 0) # => "a"
m.dig(:... | [
"Return",
"the",
"value",
"of",
"successively",
"indexing",
"into",
"a",
"collection",
".",
"If",
"any",
"of",
"the",
"keys",
"is",
"not",
"present",
"in",
"the",
"collection",
"return",
"nil",
".",
"keys",
"that",
"the",
"Erlang",
"type",
"doesn",
"t",
... | a3eaa3d976610466a5f5da177109a1248dac020d | https://github.com/potatosalad/ruby-erlang-terms/blob/a3eaa3d976610466a5f5da177109a1248dac020d/lib/erlang/associable.rb#L89-L96 |
2,486 | ustasb/pandata | lib/pandata/scraper.rb | Pandata.Scraper.download_all_data | def download_all_data(url)
next_data_indices = {}
while next_data_indices
html = Downloader.read_page(url)
# Sometimes Pandora returns the same next_data_indices as the previous page.
# If we don't check for this, an infinite loop occurs.
# This problem occurs with tconrad.... | ruby | def download_all_data(url)
next_data_indices = {}
while next_data_indices
html = Downloader.read_page(url)
# Sometimes Pandora returns the same next_data_indices as the previous page.
# If we don't check for this, an infinite loop occurs.
# This problem occurs with tconrad.... | [
"def",
"download_all_data",
"(",
"url",
")",
"next_data_indices",
"=",
"{",
"}",
"while",
"next_data_indices",
"html",
"=",
"Downloader",
".",
"read_page",
"(",
"url",
")",
"# Sometimes Pandora returns the same next_data_indices as the previous page.",
"# If we don't check fo... | Downloads all data given a starting URL. Some Pandora feeds only return
5 - 10 items per page but contain a link to the next set of data. Threads
cannot be used because page A be must visited to know how to obtain page B.
@param url [String] | [
"Downloads",
"all",
"data",
"given",
"a",
"starting",
"URL",
".",
"Some",
"Pandora",
"feeds",
"only",
"return",
"5",
"-",
"10",
"items",
"per",
"page",
"but",
"contain",
"a",
"link",
"to",
"the",
"next",
"set",
"of",
"data",
".",
"Threads",
"cannot",
"... | c75f83813171bc6149eca53ff310dedca1a7a1cb | https://github.com/ustasb/pandata/blob/c75f83813171bc6149eca53ff310dedca1a7a1cb/lib/pandata/scraper.rb#L119-L134 |
2,487 | ustasb/pandata | lib/pandata/scraper.rb | Pandata.Scraper.get_url | def get_url(data_name, next_data_indices = {})
if next_data_indices.empty?
next_data_indices = { nextStartIndex: 0, nextLikeStartIndex: 0, nextThumbStartIndex: 0 }
else
next_data_indices = next_data_indices.dup
end
next_data_indices[:webname] = @webname
next_data_indices[:... | ruby | def get_url(data_name, next_data_indices = {})
if next_data_indices.empty?
next_data_indices = { nextStartIndex: 0, nextLikeStartIndex: 0, nextThumbStartIndex: 0 }
else
next_data_indices = next_data_indices.dup
end
next_data_indices[:webname] = @webname
next_data_indices[:... | [
"def",
"get_url",
"(",
"data_name",
",",
"next_data_indices",
"=",
"{",
"}",
")",
"if",
"next_data_indices",
".",
"empty?",
"next_data_indices",
"=",
"{",
"nextStartIndex",
":",
"0",
",",
"nextLikeStartIndex",
":",
"0",
",",
"nextThumbStartIndex",
":",
"0",
"}... | Grabs a URL from DATA_FEED_URLS and formats it appropriately.
@param data_name [Symbol]
@param next_data_indices [Symbol] query parameters to get the next set of data | [
"Grabs",
"a",
"URL",
"from",
"DATA_FEED_URLS",
"and",
"formats",
"it",
"appropriately",
"."
] | c75f83813171bc6149eca53ff310dedca1a7a1cb | https://github.com/ustasb/pandata/blob/c75f83813171bc6149eca53ff310dedca1a7a1cb/lib/pandata/scraper.rb#L139-L150 |
2,488 | dennisreimann/masq | app/models/masq/account.rb | Masq.Account.yubikey_authenticated? | def yubikey_authenticated?(otp)
if yubico_identity? && Account.verify_yubico_otp(otp)
(Account.extract_yubico_identity_from_otp(otp) == yubico_identity)
else
false
end
end | ruby | def yubikey_authenticated?(otp)
if yubico_identity? && Account.verify_yubico_otp(otp)
(Account.extract_yubico_identity_from_otp(otp) == yubico_identity)
else
false
end
end | [
"def",
"yubikey_authenticated?",
"(",
"otp",
")",
"if",
"yubico_identity?",
"&&",
"Account",
".",
"verify_yubico_otp",
"(",
"otp",
")",
"(",
"Account",
".",
"extract_yubico_identity_from_otp",
"(",
"otp",
")",
"==",
"yubico_identity",
")",
"else",
"false",
"end",
... | Is the Yubico OTP valid and belongs to this account? | [
"Is",
"the",
"Yubico",
"OTP",
"valid",
"and",
"belongs",
"to",
"this",
"account?"
] | bc6b6d84fe06811b9de19e7863c53c6bfad201fe | https://github.com/dennisreimann/masq/blob/bc6b6d84fe06811b9de19e7863c53c6bfad201fe/app/models/masq/account.rb#L127-L133 |
2,489 | qoobaa/vcard | lib/vcard/dirinfo.rb | Vcard.DirectoryInfo.[] | def [](name)
enum_by_name(name).each { |f| return f.value if f.value != ""}
enum_by_name(name).each { |f| return f.value }
nil
end | ruby | def [](name)
enum_by_name(name).each { |f| return f.value if f.value != ""}
enum_by_name(name).each { |f| return f.value }
nil
end | [
"def",
"[]",
"(",
"name",
")",
"enum_by_name",
"(",
"name",
")",
".",
"each",
"{",
"|",
"f",
"|",
"return",
"f",
".",
"value",
"if",
"f",
".",
"value",
"!=",
"\"\"",
"}",
"enum_by_name",
"(",
"name",
")",
".",
"each",
"{",
"|",
"f",
"|",
"retur... | The value of the first field named +name+, or nil if no
match is found. | [
"The",
"value",
"of",
"the",
"first",
"field",
"named",
"+",
"name",
"+",
"or",
"nil",
"if",
"no",
"match",
"is",
"found",
"."
] | 0cab080676df262555e3adadc9a82fedc128d337 | https://github.com/qoobaa/vcard/blob/0cab080676df262555e3adadc9a82fedc128d337/lib/vcard/dirinfo.rb#L113-L117 |
2,490 | qoobaa/vcard | lib/vcard/dirinfo.rb | Vcard.DirectoryInfo.push_unique | def push_unique(field)
push(field) unless @fields.detect { |f| f.name? field.name }
self
end | ruby | def push_unique(field)
push(field) unless @fields.detect { |f| f.name? field.name }
self
end | [
"def",
"push_unique",
"(",
"field",
")",
"push",
"(",
"field",
")",
"unless",
"@fields",
".",
"detect",
"{",
"|",
"f",
"|",
"f",
".",
"name?",
"field",
".",
"name",
"}",
"self",
"end"
] | Push +field+ onto the fields, unless there is already a field
with this name. | [
"Push",
"+",
"field",
"+",
"onto",
"the",
"fields",
"unless",
"there",
"is",
"already",
"a",
"field",
"with",
"this",
"name",
"."
] | 0cab080676df262555e3adadc9a82fedc128d337 | https://github.com/qoobaa/vcard/blob/0cab080676df262555e3adadc9a82fedc128d337/lib/vcard/dirinfo.rb#L212-L215 |
2,491 | qoobaa/vcard | lib/vcard/dirinfo.rb | Vcard.DirectoryInfo.delete | def delete(field)
case
when field.name?("BEGIN"), field.name?("END")
raise ArgumentError, "Cannot delete BEGIN or END fields."
else
@fields.delete field
end
self
end | ruby | def delete(field)
case
when field.name?("BEGIN"), field.name?("END")
raise ArgumentError, "Cannot delete BEGIN or END fields."
else
@fields.delete field
end
self
end | [
"def",
"delete",
"(",
"field",
")",
"case",
"when",
"field",
".",
"name?",
"(",
"\"BEGIN\"",
")",
",",
"field",
".",
"name?",
"(",
"\"END\"",
")",
"raise",
"ArgumentError",
",",
"\"Cannot delete BEGIN or END fields.\"",
"else",
"@fields",
".",
"delete",
"field... | Delete +field+.
Warning: You can't delete BEGIN: or END: fields, but other
profile-specific fields can be deleted, including mandatory ones. For
vCards in particular, in order to avoid destroying them, I suggest
creating a new Vcard, and copying over all the fields that you still
want, rather than using #delete. ... | [
"Delete",
"+",
"field",
"+",
"."
] | 0cab080676df262555e3adadc9a82fedc128d337 | https://github.com/qoobaa/vcard/blob/0cab080676df262555e3adadc9a82fedc128d337/lib/vcard/dirinfo.rb#L233-L242 |
2,492 | tomharris/random_data | lib/random_data/numbers.rb | RandomData.Numbers.number | def number(n)
n.is_a?(Range) ? n.to_a.rand : rand(n)
end | ruby | def number(n)
n.is_a?(Range) ? n.to_a.rand : rand(n)
end | [
"def",
"number",
"(",
"n",
")",
"n",
".",
"is_a?",
"(",
"Range",
")",
"?",
"n",
".",
"to_a",
".",
"rand",
":",
"rand",
"(",
"n",
")",
"end"
] | n can be an Integer or a Range. If it is an Integer, it just returns a random
number greater than or equal to 0 and less than n. If it is a Range, it
returns a random number within the range
Examples
>> Random.number(5)
=> 4
>> Random.number(5)
=> 2
>> Random.number(5)
=> 1 | [
"n",
"can",
"be",
"an",
"Integer",
"or",
"a",
"Range",
".",
"If",
"it",
"is",
"an",
"Integer",
"it",
"just",
"returns",
"a",
"random",
"number",
"greater",
"than",
"or",
"equal",
"to",
"0",
"and",
"less",
"than",
"n",
".",
"If",
"it",
"is",
"a",
... | 641271ea66e7837b2c4a9efa034d9ac75b4f487d | https://github.com/tomharris/random_data/blob/641271ea66e7837b2c4a9efa034d9ac75b4f487d/lib/random_data/numbers.rb#L14-L16 |
2,493 | rmosolgo/css_modules | lib/css_modules/rewrite.rb | CSSModules.Rewrite.rewrite_css | def rewrite_css(css_module_code)
# Parse incoming CSS into an AST
css_root = Sass::SCSS::CssParser.new(css_module_code, "(CSSModules)", 1).parse
Sass::Tree::Visitors::SetOptions.visit(css_root, {})
ModuleVisitor.visit(css_root)
css_root.render
end | ruby | def rewrite_css(css_module_code)
# Parse incoming CSS into an AST
css_root = Sass::SCSS::CssParser.new(css_module_code, "(CSSModules)", 1).parse
Sass::Tree::Visitors::SetOptions.visit(css_root, {})
ModuleVisitor.visit(css_root)
css_root.render
end | [
"def",
"rewrite_css",
"(",
"css_module_code",
")",
"# Parse incoming CSS into an AST",
"css_root",
"=",
"Sass",
"::",
"SCSS",
"::",
"CssParser",
".",
"new",
"(",
"css_module_code",
",",
"\"(CSSModules)\"",
",",
"1",
")",
".",
"parse",
"Sass",
"::",
"Tree",
"::",... | Take css module code as input, and rewrite it as
browser-friendly CSS code. Apply opaque transformations
so that selectors can only be accessed programatically,
not by class name literals. | [
"Take",
"css",
"module",
"code",
"as",
"input",
"and",
"rewrite",
"it",
"as",
"browser",
"-",
"friendly",
"CSS",
"code",
".",
"Apply",
"opaque",
"transformations",
"so",
"that",
"selectors",
"can",
"only",
"be",
"accessed",
"programatically",
"not",
"by",
"c... | c1a80f6b7b76193c7dda616877a75eec6bbe600d | https://github.com/rmosolgo/css_modules/blob/c1a80f6b7b76193c7dda616877a75eec6bbe600d/lib/css_modules/rewrite.rb#L15-L23 |
2,494 | tomharris/random_data | lib/random_data/grammar.rb | RandomData.Grammar.grammatical_construct | def grammatical_construct(grammar, what=nil)
output = ""
if what.nil?
case grammar
when Hash
a_key = grammar.keys.sort_by{rand}[0]
output += grammatical_construct(grammar, a_key)
when Array
grammar.each do |item|
output += grammatical_constru... | ruby | def grammatical_construct(grammar, what=nil)
output = ""
if what.nil?
case grammar
when Hash
a_key = grammar.keys.sort_by{rand}[0]
output += grammatical_construct(grammar, a_key)
when Array
grammar.each do |item|
output += grammatical_constru... | [
"def",
"grammatical_construct",
"(",
"grammar",
",",
"what",
"=",
"nil",
")",
"output",
"=",
"\"\"",
"if",
"what",
".",
"nil?",
"case",
"grammar",
"when",
"Hash",
"a_key",
"=",
"grammar",
".",
"keys",
".",
"sort_by",
"{",
"rand",
"}",
"[",
"0",
"]",
... | Returns simple sentences based on a supplied grammar, which must be a hash, the
keys of which are symbols. The values are either an array of successive values or a grammar
(i.e, hash with symbols as keys, and hashes or arrays as values. The arrays contain symbols
referencing the keys in the present grammar, or str... | [
"Returns",
"simple",
"sentences",
"based",
"on",
"a",
"supplied",
"grammar",
"which",
"must",
"be",
"a",
"hash",
"the",
"keys",
"of",
"which",
"are",
"symbols",
".",
"The",
"values",
"are",
"either",
"an",
"array",
"of",
"successive",
"values",
"or",
"a",
... | 641271ea66e7837b2c4a9efa034d9ac75b4f487d | https://github.com/tomharris/random_data/blob/641271ea66e7837b2c4a9efa034d9ac75b4f487d/lib/random_data/grammar.rb#L17-L58 |
2,495 | thhermansen/google_static_maps_helper | lib/google_static_maps_helper/location.rb | GoogleStaticMapsHelper.Location.endpoints_for_circle_with_radius | def endpoints_for_circle_with_radius(radius, steps = 30)
raise ArgumentError, "Number of points has to be in range of 1..360!" unless (1..360).include? steps
points = []
steps.times do |i|
points << endpoint(radius, i * 360 / steps)
end
points << points.first
points
en... | ruby | def endpoints_for_circle_with_radius(radius, steps = 30)
raise ArgumentError, "Number of points has to be in range of 1..360!" unless (1..360).include? steps
points = []
steps.times do |i|
points << endpoint(radius, i * 360 / steps)
end
points << points.first
points
en... | [
"def",
"endpoints_for_circle_with_radius",
"(",
"radius",
",",
"steps",
"=",
"30",
")",
"raise",
"ArgumentError",
",",
"\"Number of points has to be in range of 1..360!\"",
"unless",
"(",
"1",
"..",
"360",
")",
".",
"include?",
"steps",
"points",
"=",
"[",
"]",
"s... | Returns ends poionts which will make up a circle around current location and have given radius | [
"Returns",
"ends",
"poionts",
"which",
"will",
"make",
"up",
"a",
"circle",
"around",
"current",
"location",
"and",
"have",
"given",
"radius"
] | 31d2af983e17be736566bfac686b56c57385d64d | https://github.com/thhermansen/google_static_maps_helper/blob/31d2af983e17be736566bfac686b56c57385d64d/lib/google_static_maps_helper/location.rb#L81-L91 |
2,496 | tomharris/random_data | lib/random_data/names.rb | RandomData.Names.companyname | def companyname
num = rand(5)
if num == 0
num = 1
end
final = num.times.collect { @@lastnames.rand.capitalize }
if final.count == 1
"#{final.first} #{@@company_types.rand}, #{@@incorporation_types.rand}"
else
incorporation_type = rand(17) % 2 == 0 ? @@incorpo... | ruby | def companyname
num = rand(5)
if num == 0
num = 1
end
final = num.times.collect { @@lastnames.rand.capitalize }
if final.count == 1
"#{final.first} #{@@company_types.rand}, #{@@incorporation_types.rand}"
else
incorporation_type = rand(17) % 2 == 0 ? @@incorpo... | [
"def",
"companyname",
"num",
"=",
"rand",
"(",
"5",
")",
"if",
"num",
"==",
"0",
"num",
"=",
"1",
"end",
"final",
"=",
"num",
".",
"times",
".",
"collect",
"{",
"@@lastnames",
".",
"rand",
".",
"capitalize",
"}",
"if",
"final",
".",
"count",
"==",
... | Returns a random company name
>> Random.company_name
"Harris & Thomas" | [
"Returns",
"a",
"random",
"company",
"name"
] | 641271ea66e7837b2c4a9efa034d9ac75b4f487d | https://github.com/tomharris/random_data/blob/641271ea66e7837b2c4a9efa034d9ac75b4f487d/lib/random_data/names.rb#L26-L42 |
2,497 | jhass/open_graph_reader | lib/open_graph_reader/builder.rb | OpenGraphReader.Builder.base | def base
base = Base.new
type = @parser.graph.fetch("og:type", "website").downcase
validate_type type
@parser.graph.each do |property|
build_property base, property
end
synthesize_required_properties base
drop_empty_children base
validate base
base
... | ruby | def base
base = Base.new
type = @parser.graph.fetch("og:type", "website").downcase
validate_type type
@parser.graph.each do |property|
build_property base, property
end
synthesize_required_properties base
drop_empty_children base
validate base
base
... | [
"def",
"base",
"base",
"=",
"Base",
".",
"new",
"type",
"=",
"@parser",
".",
"graph",
".",
"fetch",
"(",
"\"og:type\"",
",",
"\"website\"",
")",
".",
"downcase",
"validate_type",
"type",
"@parser",
".",
"graph",
".",
"each",
"do",
"|",
"property",
"|",
... | Create a new builder.
@param [Parser] parser
@see Parser#graph
@see Parser#additional_namespaces
Build and return the base.
@return [Base] | [
"Create",
"a",
"new",
"builder",
"."
] | 5488354b7dd75b5411a881d734aa7176546e7cb4 | https://github.com/jhass/open_graph_reader/blob/5488354b7dd75b5411a881d734aa7176546e7cb4/lib/open_graph_reader/builder.rb#L24-L40 |
2,498 | dennisreimann/masq | app/helpers/masq/application_helper.rb | Masq.ApplicationHelper.nav | def nav(name, url, pages = nil, active = false)
content_tag :li, link_to(name, url), :class => (active || (pages && active_page?(pages)) ? 'act' : nil)
end | ruby | def nav(name, url, pages = nil, active = false)
content_tag :li, link_to(name, url), :class => (active || (pages && active_page?(pages)) ? 'act' : nil)
end | [
"def",
"nav",
"(",
"name",
",",
"url",
",",
"pages",
"=",
"nil",
",",
"active",
"=",
"false",
")",
"content_tag",
":li",
",",
"link_to",
"(",
"name",
",",
"url",
")",
",",
":class",
"=>",
"(",
"active",
"||",
"(",
"pages",
"&&",
"active_page?",
"("... | Renders a navigation element and marks it as active where
appropriate. See active_page? for details | [
"Renders",
"a",
"navigation",
"element",
"and",
"marks",
"it",
"as",
"active",
"where",
"appropriate",
".",
"See",
"active_page?",
"for",
"details"
] | bc6b6d84fe06811b9de19e7863c53c6bfad201fe | https://github.com/dennisreimann/masq/blob/bc6b6d84fe06811b9de19e7863c53c6bfad201fe/app/helpers/masq/application_helper.rb#L45-L47 |
2,499 | dennisreimann/masq | app/helpers/masq/application_helper.rb | Masq.ApplicationHelper.active_page? | def active_page?(pages = {})
is_active = pages.include?(params[:controller])
is_active = pages[params[:controller]].include?(params[:action]) if is_active && !pages[params[:controller]].empty?
is_active
end | ruby | def active_page?(pages = {})
is_active = pages.include?(params[:controller])
is_active = pages[params[:controller]].include?(params[:action]) if is_active && !pages[params[:controller]].empty?
is_active
end | [
"def",
"active_page?",
"(",
"pages",
"=",
"{",
"}",
")",
"is_active",
"=",
"pages",
".",
"include?",
"(",
"params",
"[",
":controller",
"]",
")",
"is_active",
"=",
"pages",
"[",
"params",
"[",
":controller",
"]",
"]",
".",
"include?",
"(",
"params",
"[... | Takes a hash with pages and tells whether the current page is among them.
The keys must be controller names and their value must be an array of
action names. If the array is empty, every action is supposed to be valid. | [
"Takes",
"a",
"hash",
"with",
"pages",
"and",
"tells",
"whether",
"the",
"current",
"page",
"is",
"among",
"them",
".",
"The",
"keys",
"must",
"be",
"controller",
"names",
"and",
"their",
"value",
"must",
"be",
"an",
"array",
"of",
"action",
"names",
"."... | bc6b6d84fe06811b9de19e7863c53c6bfad201fe | https://github.com/dennisreimann/masq/blob/bc6b6d84fe06811b9de19e7863c53c6bfad201fe/app/helpers/masq/application_helper.rb#L52-L56 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.