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
sequence | docstring
stringlengths 8
16k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 94
266
|
---|---|---|---|---|---|---|---|---|---|---|---|
2,800 | propublica/table-setter | lib/table_setter/table.rb | TableSetter.Table.web_modification_time | def web_modification_time(local_url)
resp = nil
Net::HTTP.start(local_url.host, 80) do |http|
resp = http.head(local_url.path)
end
resp['Last-Modified'].nil? ? Time.at(0) : Time.parse(resp['Last-Modified'])
end | ruby | def web_modification_time(local_url)
resp = nil
Net::HTTP.start(local_url.host, 80) do |http|
resp = http.head(local_url.path)
end
resp['Last-Modified'].nil? ? Time.at(0) : Time.parse(resp['Last-Modified'])
end | [
"def",
"web_modification_time",
"(",
"local_url",
")",
"resp",
"=",
"nil",
"Net",
"::",
"HTTP",
".",
"start",
"(",
"local_url",
".",
"host",
",",
"80",
")",
"do",
"|",
"http",
"|",
"resp",
"=",
"http",
".",
"head",
"(",
"local_url",
".",
"path",
")",
"end",
"resp",
"[",
"'Last-Modified'",
"]",
".",
"nil?",
"?",
"Time",
".",
"at",
"(",
"0",
")",
":",
"Time",
".",
"parse",
"(",
"resp",
"[",
"'Last-Modified'",
"]",
")",
"end"
] | Returns the last-modified time from the remote server. Assumes the remote server knows how to
do this. Returns the epoch if the remote is dense. | [
"Returns",
"the",
"last",
"-",
"modified",
"time",
"from",
"the",
"remote",
"server",
".",
"Assumes",
"the",
"remote",
"server",
"knows",
"how",
"to",
"do",
"this",
".",
"Returns",
"the",
"epoch",
"if",
"the",
"remote",
"is",
"dense",
"."
] | 11e14dc3359be7cb78400e8a70e0bb0a199daf72 | https://github.com/propublica/table-setter/blob/11e14dc3359be7cb78400e8a70e0bb0a199daf72/lib/table_setter/table.rb#L135-L141 |
2,801 | propublica/table-setter | lib/table_setter/table.rb | TableSetter.Table.modification_time | def modification_time(path)
is_uri = URI.parse(path)
if !is_uri.host.nil?
return web_modification_time is_uri
end
File.new(path).mtime
end | ruby | def modification_time(path)
is_uri = URI.parse(path)
if !is_uri.host.nil?
return web_modification_time is_uri
end
File.new(path).mtime
end | [
"def",
"modification_time",
"(",
"path",
")",
"is_uri",
"=",
"URI",
".",
"parse",
"(",
"path",
")",
"if",
"!",
"is_uri",
".",
"host",
".",
"nil?",
"return",
"web_modification_time",
"is_uri",
"end",
"File",
".",
"new",
"(",
"path",
")",
".",
"mtime",
"end"
] | Dispatches to web_modification_time if we're dealing with a url, otherwise just stats the
local file. | [
"Dispatches",
"to",
"web_modification_time",
"if",
"we",
"re",
"dealing",
"with",
"a",
"url",
"otherwise",
"just",
"stats",
"the",
"local",
"file",
"."
] | 11e14dc3359be7cb78400e8a70e0bb0a199daf72 | https://github.com/propublica/table-setter/blob/11e14dc3359be7cb78400e8a70e0bb0a199daf72/lib/table_setter/table.rb#L145-L151 |
2,802 | m247/epp-client | lib/epp-client/request.rb | EPP.Request.to_xml | def to_xml
doc = XML::Document.new('1.0')
doc.root = XML::Node.new('epp')
root = doc.root
epp_ns = XML::Namespace.new(root, nil, 'urn:ietf:params:xml:ns:epp-1.0')
root.namespaces.namespace = epp_ns
xsi_ns = XML::Namespace.new(root, 'xsi', 'http://www.w3.org/2001/XMLSchema-instance')
xsi_sL = XML::Attr.new(root, 'schemaLocation', 'urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd')
xsi_sL.namespaces.namespace = xsi_ns
@namespaces = {'epp' => epp_ns, 'xsi' => xsi_ns}
@request.set_namespaces(@namespaces) if @request.respond_to?(:set_namespaces)
root << @request.to_xml
doc
end | ruby | def to_xml
doc = XML::Document.new('1.0')
doc.root = XML::Node.new('epp')
root = doc.root
epp_ns = XML::Namespace.new(root, nil, 'urn:ietf:params:xml:ns:epp-1.0')
root.namespaces.namespace = epp_ns
xsi_ns = XML::Namespace.new(root, 'xsi', 'http://www.w3.org/2001/XMLSchema-instance')
xsi_sL = XML::Attr.new(root, 'schemaLocation', 'urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd')
xsi_sL.namespaces.namespace = xsi_ns
@namespaces = {'epp' => epp_ns, 'xsi' => xsi_ns}
@request.set_namespaces(@namespaces) if @request.respond_to?(:set_namespaces)
root << @request.to_xml
doc
end | [
"def",
"to_xml",
"doc",
"=",
"XML",
"::",
"Document",
".",
"new",
"(",
"'1.0'",
")",
"doc",
".",
"root",
"=",
"XML",
"::",
"Node",
".",
"new",
"(",
"'epp'",
")",
"root",
"=",
"doc",
".",
"root",
"epp_ns",
"=",
"XML",
"::",
"Namespace",
".",
"new",
"(",
"root",
",",
"nil",
",",
"'urn:ietf:params:xml:ns:epp-1.0'",
")",
"root",
".",
"namespaces",
".",
"namespace",
"=",
"epp_ns",
"xsi_ns",
"=",
"XML",
"::",
"Namespace",
".",
"new",
"(",
"root",
",",
"'xsi'",
",",
"'http://www.w3.org/2001/XMLSchema-instance'",
")",
"xsi_sL",
"=",
"XML",
"::",
"Attr",
".",
"new",
"(",
"root",
",",
"'schemaLocation'",
",",
"'urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd'",
")",
"xsi_sL",
".",
"namespaces",
".",
"namespace",
"=",
"xsi_ns",
"@namespaces",
"=",
"{",
"'epp'",
"=>",
"epp_ns",
",",
"'xsi'",
"=>",
"xsi_ns",
"}",
"@request",
".",
"set_namespaces",
"(",
"@namespaces",
")",
"if",
"@request",
".",
"respond_to?",
"(",
":set_namespaces",
")",
"root",
"<<",
"@request",
".",
"to_xml",
"doc",
"end"
] | Receiver in XML form
@return [XML::Document] XML of the receiver | [
"Receiver",
"in",
"XML",
"form"
] | 72227e57d248f215d842e3dd37e72432d2a79270 | https://github.com/m247/epp-client/blob/72227e57d248f215d842e3dd37e72432d2a79270/lib/epp-client/request.rb#L19-L37 |
2,803 | m247/epp-client | lib/epp-client/response.rb | EPP.Response.extension | def extension
@extension ||= begin
list = @xml.find('/e:epp/e:response/e:extension/node()').reject { |n| n.empty? }
list.size > 1 ? list : list[0]
end
end | ruby | def extension
@extension ||= begin
list = @xml.find('/e:epp/e:response/e:extension/node()').reject { |n| n.empty? }
list.size > 1 ? list : list[0]
end
end | [
"def",
"extension",
"@extension",
"||=",
"begin",
"list",
"=",
"@xml",
".",
"find",
"(",
"'/e:epp/e:response/e:extension/node()'",
")",
".",
"reject",
"{",
"|",
"n",
"|",
"n",
".",
"empty?",
"}",
"list",
".",
"size",
">",
"1",
"?",
"list",
":",
"list",
"[",
"0",
"]",
"end",
"end"
] | Response extension block
@return [XML::Node, Array<XML::Node>] extension | [
"Response",
"extension",
"block"
] | 72227e57d248f215d842e3dd37e72432d2a79270 | https://github.com/m247/epp-client/blob/72227e57d248f215d842e3dd37e72432d2a79270/lib/epp-client/response.rb#L68-L73 |
2,804 | imathis/jekyll-markdown-block | lib/jekyll-markdown-block.rb | Jekyll.MarkdownBlock.render | def render(context)
site = context.registers[:site]
converter = site.getConverterImpl(::Jekyll::Converters::Markdown)
converter.convert(render_block(context))
end | ruby | def render(context)
site = context.registers[:site]
converter = site.getConverterImpl(::Jekyll::Converters::Markdown)
converter.convert(render_block(context))
end | [
"def",
"render",
"(",
"context",
")",
"site",
"=",
"context",
".",
"registers",
"[",
":site",
"]",
"converter",
"=",
"site",
".",
"getConverterImpl",
"(",
"::",
"Jekyll",
"::",
"Converters",
"::",
"Markdown",
")",
"converter",
".",
"convert",
"(",
"render_block",
"(",
"context",
")",
")",
"end"
] | Uses the default Jekyll markdown parser to
parse the contents of this block | [
"Uses",
"the",
"default",
"Jekyll",
"markdown",
"parser",
"to",
"parse",
"the",
"contents",
"of",
"this",
"block"
] | 6f1a9fd20d684a1f0bcf87d634782f5dd8cc8670 | https://github.com/imathis/jekyll-markdown-block/blob/6f1a9fd20d684a1f0bcf87d634782f5dd8cc8670/lib/jekyll-markdown-block.rb#L12-L16 |
2,805 | mat813/rb-kqueue | lib/rb-kqueue/queue.rb | KQueue.Queue.watch_socket_for_read | def watch_socket_for_read(fd, low_water = nil, &callback)
Watcher::SocketReadWrite.new(self, fd, :read, low_water, callback)
end | ruby | def watch_socket_for_read(fd, low_water = nil, &callback)
Watcher::SocketReadWrite.new(self, fd, :read, low_water, callback)
end | [
"def",
"watch_socket_for_read",
"(",
"fd",
",",
"low_water",
"=",
"nil",
",",
"&",
"callback",
")",
"Watcher",
"::",
"SocketReadWrite",
".",
"new",
"(",
"self",
",",
"fd",
",",
":read",
",",
"low_water",
",",
"callback",
")",
"end"
] | Watches a socket and produces an event when there's data available to read.
Sockets which have previously had `Socket#listen` called fire events
when there is an incoming connection pending.
In this case, {Event#data} contains the size of the listen backlog.
Other sockets return when there is data to be read,
subject to the SO_RCVLOWAT value of the socket buffer.
This may be overridden via the `low_water` parameter,
which sets a new low-water mark.
In this case, {Event#data} contains the number of bytes
of protocol data available to read.
If the read direction of the socket has shut down,
then {Event#eof?} is set.
It's possible for {Event#eof?} to be set while there's still
data pending in the socket buffer.
Note that this isn't compatible with JRuby
unless a native-code file descriptor is passed in.
This means the file descriptor must be returned by an FFI-wrapped C function.
@param fd [Socket, Fixnum] A Ruby Socket, or the file descriptor
for a native Socket.
@param low_water [Fixnum] The low-water mark for new data.
@yield [event] A block that will be run when the specified socket
has data to read.
@yieldparam event [Event] The Event object containing information
about the event that occurred.
@return [Watcher] The Watcher for this event.
@raise [SystemCallError] If something goes wrong when registering the Watcher. | [
"Watches",
"a",
"socket",
"and",
"produces",
"an",
"event",
"when",
"there",
"s",
"data",
"available",
"to",
"read",
"."
] | f11c1a8552812bc0b635ef9751d6dc61d4beaa67 | https://github.com/mat813/rb-kqueue/blob/f11c1a8552812bc0b635ef9751d6dc61d4beaa67/lib/rb-kqueue/queue.rb#L123-L125 |
2,806 | mat813/rb-kqueue | lib/rb-kqueue/queue.rb | KQueue.Queue.watch_file | def watch_file(path, *flags, &callback)
Watcher::File.new(self, path, flags, callback)
end | ruby | def watch_file(path, *flags, &callback)
Watcher::File.new(self, path, flags, callback)
end | [
"def",
"watch_file",
"(",
"path",
",",
"*",
"flags",
",",
"&",
"callback",
")",
"Watcher",
"::",
"File",
".",
"new",
"(",
"self",
",",
"path",
",",
"flags",
",",
"callback",
")",
"end"
] | Watches a file or directory for changes.
The `flags` parameter specifies which changes
will fire events.
The {Event#flags} field contains the changes that caused the event to be fired.
{Event#data} and {Event#eof?} are unused.
Note that this only watches a single file.
If the file is a direcotry,
it will only report changes to the directory itself,
not to any files within the directory.
## Flags
`:delete`
: The file was deleted.
`:write`
: The file was modified.
`:extend`
: The size of the file increased.
`:attrib`
: Attributes of the file, such as timestamp or permissions, changed.
`:link`
: The link count of the file changed.
`:rename`
: The file was renamed.
`:revoke`
: Access to the file was revoked,
either via the `revoke(2)` system call
or because the underlying filesystem was unmounted.
@param path [String] The path to the file or directory.
@param flags [Array<Symbol>] Which events to watch for.
@yield [event] A block that will be run when the file changes.
@yieldparam event [Event] The Event object containing information
about the event that occurred.
@return [Watcher] The Watcher for this event.
@raise [SystemCallError] If something goes wrong when registering the Watcher. | [
"Watches",
"a",
"file",
"or",
"directory",
"for",
"changes",
".",
"The",
"flags",
"parameter",
"specifies",
"which",
"changes",
"will",
"fire",
"events",
"."
] | f11c1a8552812bc0b635ef9751d6dc61d4beaa67 | https://github.com/mat813/rb-kqueue/blob/f11c1a8552812bc0b635ef9751d6dc61d4beaa67/lib/rb-kqueue/queue.rb#L226-L228 |
2,807 | mat813/rb-kqueue | lib/rb-kqueue/queue.rb | KQueue.Queue.watch_process | def watch_process(pid, *flags, &callback)
Watcher::Process.new(self, pid, flags, callback)
end | ruby | def watch_process(pid, *flags, &callback)
Watcher::Process.new(self, pid, flags, callback)
end | [
"def",
"watch_process",
"(",
"pid",
",",
"*",
"flags",
",",
"&",
"callback",
")",
"Watcher",
"::",
"Process",
".",
"new",
"(",
"self",
",",
"pid",
",",
"flags",
",",
"callback",
")",
"end"
] | Watches a process for changes.
The `flags` parameter specifies which changes
will fire events.
The {Event#flags} field contains the changes that caused the event to be fired.
{Event#data} and {Event#eof?} are unused.
## Flags
`:exit`
: The process has exited.
`:fork`
: The process has created a child process via `fork(2)` or similar.
`:exec`
: The process has executed a new process via `exec(2)` or similar.
`:signal`
: The process was sent a signal.
This is only supported under Darwin/OS X.
`:reap`
: The process was reaped by the parent via `wait(2)` or similar.
This is only supported under Darwin/OS X.
`:track`
: Follow the process across `fork(2)` calls.
{Event#flags} for the parent process will contain `:fork`,
while {Event#flags} for the child process will contain `:child`.
If the system was unable to attach an event to the child process,
{Event#flags} will contain `:trackerr`.
This is not supported under Darwin/OS X.
@param pid [Fixnum] The id of the process.
@param flags [Array<Symbol>] Which events to watch for.
@yield [event] A block that will be run when the process changes.
@yieldparam event [Event] The Event object containing information
about the event that occurred.
@return [Watcher] The Watcher for this event.
@raise [SystemCallError] If something goes wrong when registering the Watcher. | [
"Watches",
"a",
"process",
"for",
"changes",
".",
"The",
"flags",
"parameter",
"specifies",
"which",
"changes",
"will",
"fire",
"events",
"."
] | f11c1a8552812bc0b635ef9751d6dc61d4beaa67 | https://github.com/mat813/rb-kqueue/blob/f11c1a8552812bc0b635ef9751d6dc61d4beaa67/lib/rb-kqueue/queue.rb#L271-L273 |
2,808 | dagrz/nba_stats | lib/nba_stats/stats/common_team_roster.rb | NbaStats.CommonTeamRoster.common_team_roster | def common_team_roster(
team_id,
season,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::CommonTeamRoster.new(
get(COMMON_TEAM_ROSTER_PATH, {
:Season => season,
:LeagueID => league_id,
:TeamID => team_id
})
)
end | ruby | def common_team_roster(
team_id,
season,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::CommonTeamRoster.new(
get(COMMON_TEAM_ROSTER_PATH, {
:Season => season,
:LeagueID => league_id,
:TeamID => team_id
})
)
end | [
"def",
"common_team_roster",
"(",
"team_id",
",",
"season",
",",
"league_id",
"=",
"NbaStats",
"::",
"Constants",
"::",
"LEAGUE_ID_NBA",
")",
"NbaStats",
"::",
"Resources",
"::",
"CommonTeamRoster",
".",
"new",
"(",
"get",
"(",
"COMMON_TEAM_ROSTER_PATH",
",",
"{",
":Season",
"=>",
"season",
",",
":LeagueID",
"=>",
"league_id",
",",
":TeamID",
"=>",
"team_id",
"}",
")",
")",
"end"
] | Calls the commonteamroster API and returns a CommonTeamRoster resource.
@param team_id [Integer]
@param season [String]
@param league_id [String]
@return [NbaStats::Resources::CommonTeamRoster] | [
"Calls",
"the",
"commonteamroster",
"API",
"and",
"returns",
"a",
"CommonTeamRoster",
"resource",
"."
] | d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa | https://github.com/dagrz/nba_stats/blob/d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa/lib/nba_stats/stats/common_team_roster.rb#L17-L29 |
2,809 | dcuddeback/rspec-tag_matchers | lib/rspec/tag_matchers/has_input.rb | RSpec::TagMatchers.HasInput.build_name | def build_name(*args)
args.extend(DeepFlattening)
args = args.deep_flatten
name = args.shift.to_s
name + args.map {|piece| "[#{piece}]"}.join
end | ruby | def build_name(*args)
args.extend(DeepFlattening)
args = args.deep_flatten
name = args.shift.to_s
name + args.map {|piece| "[#{piece}]"}.join
end | [
"def",
"build_name",
"(",
"*",
"args",
")",
"args",
".",
"extend",
"(",
"DeepFlattening",
")",
"args",
"=",
"args",
".",
"deep_flatten",
"name",
"=",
"args",
".",
"shift",
".",
"to_s",
"name",
"+",
"args",
".",
"map",
"{",
"|",
"piece",
"|",
"\"[#{piece}]\"",
"}",
".",
"join",
"end"
] | Converts an array or hash of names to a name for an input form.
@example
build_name(:foo => :bar) # => "foo[bar]"
build_name(:foo, :bar) # => "foo[bar]"
build_name(:foo => {:bar => :baz}) # => "foo[bar][baz]"
build_name(:foo, :bar => :baz) # => "foo[bar][baz]"
@param [Array, Hash] args A hierarchy of strings.
@return [String] The expected name of the form input. | [
"Converts",
"an",
"array",
"or",
"hash",
"of",
"names",
"to",
"a",
"name",
"for",
"an",
"input",
"form",
"."
] | 6396a833d99ea669699afb1b3dfc62c4512c8882 | https://github.com/dcuddeback/rspec-tag_matchers/blob/6396a833d99ea669699afb1b3dfc62c4512c8882/lib/rspec/tag_matchers/has_input.rb#L119-L124 |
2,810 | dagrz/nba_stats | lib/nba_stats/stats/box_score_advanced.rb | NbaStats.BoxScoreAdvanced.box_score_advanced | def box_score_advanced(
game_id,
range_type=0,
start_period=0,
end_period=0,
start_range=0,
end_range=0
)
NbaStats::Resources::BoxScoreAdvanced.new(
get(BOX_SCORE_ADVANCED_PATH, {
:GameID => game_id,
:RangeType => range_type,
:StartPeriod => start_period,
:EndPeriod => end_period,
:StartRange => start_range,
:EndRange => end_range
})
)
end | ruby | def box_score_advanced(
game_id,
range_type=0,
start_period=0,
end_period=0,
start_range=0,
end_range=0
)
NbaStats::Resources::BoxScoreAdvanced.new(
get(BOX_SCORE_ADVANCED_PATH, {
:GameID => game_id,
:RangeType => range_type,
:StartPeriod => start_period,
:EndPeriod => end_period,
:StartRange => start_range,
:EndRange => end_range
})
)
end | [
"def",
"box_score_advanced",
"(",
"game_id",
",",
"range_type",
"=",
"0",
",",
"start_period",
"=",
"0",
",",
"end_period",
"=",
"0",
",",
"start_range",
"=",
"0",
",",
"end_range",
"=",
"0",
")",
"NbaStats",
"::",
"Resources",
"::",
"BoxScoreAdvanced",
".",
"new",
"(",
"get",
"(",
"BOX_SCORE_ADVANCED_PATH",
",",
"{",
":GameID",
"=>",
"game_id",
",",
":RangeType",
"=>",
"range_type",
",",
":StartPeriod",
"=>",
"start_period",
",",
":EndPeriod",
"=>",
"end_period",
",",
":StartRange",
"=>",
"start_range",
",",
":EndRange",
"=>",
"end_range",
"}",
")",
")",
"end"
] | Calls the boxscoreadvanced API and returns a BoxScoreAdvanced resource.
@param game_id [String]
@param range_type [Integer]
@param start_period [Integer]
@param end_period [Integer]
@param start_range [Integer]
@param end_range [xxxxxxxxxx]
@return [NbaStats::Resources::BoxScoreAdvanced] | [
"Calls",
"the",
"boxscoreadvanced",
"API",
"and",
"returns",
"a",
"BoxScoreAdvanced",
"resource",
"."
] | d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa | https://github.com/dagrz/nba_stats/blob/d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa/lib/nba_stats/stats/box_score_advanced.rb#L19-L37 |
2,811 | dagrz/nba_stats | lib/nba_stats/stats/common_all_players.rb | NbaStats.CommonAllPlayers.common_all_players | def common_all_players(
season,
is_only_current_season=0,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::CommonAllPlayers.new(
get(COMMON_ALL_PLAYERS_PATH, {
:LeagueID => league_id,
:Season => season,
:IsOnlyCurrentSeason => is_only_current_season
})
)
end | ruby | def common_all_players(
season,
is_only_current_season=0,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::CommonAllPlayers.new(
get(COMMON_ALL_PLAYERS_PATH, {
:LeagueID => league_id,
:Season => season,
:IsOnlyCurrentSeason => is_only_current_season
})
)
end | [
"def",
"common_all_players",
"(",
"season",
",",
"is_only_current_season",
"=",
"0",
",",
"league_id",
"=",
"NbaStats",
"::",
"Constants",
"::",
"LEAGUE_ID_NBA",
")",
"NbaStats",
"::",
"Resources",
"::",
"CommonAllPlayers",
".",
"new",
"(",
"get",
"(",
"COMMON_ALL_PLAYERS_PATH",
",",
"{",
":LeagueID",
"=>",
"league_id",
",",
":Season",
"=>",
"season",
",",
":IsOnlyCurrentSeason",
"=>",
"is_only_current_season",
"}",
")",
")",
"end"
] | Calls the commonallplayers API and returns a CommonAllPlayers resource.
@param season [String]
@param is_only_current_season [Integer]
@param league_id [String]
@return [NbaStats::Resources::CommonAllPlayers] | [
"Calls",
"the",
"commonallplayers",
"API",
"and",
"returns",
"a",
"CommonAllPlayers",
"resource",
"."
] | d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa | https://github.com/dagrz/nba_stats/blob/d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa/lib/nba_stats/stats/common_all_players.rb#L17-L29 |
2,812 | dagrz/nba_stats | lib/nba_stats/stats/team_info_common.rb | NbaStats.TeamInfoCommon.team_info_common | def team_info_common(
team_id,
season,
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::TeamInfoCommon.new(
get(TEAM_INFO_COMMON_PATH, {
:Season => season,
:SeasonType => season_type,
:LeagueID => league_id,
:TeamID => team_id
})
)
end | ruby | def team_info_common(
team_id,
season,
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::TeamInfoCommon.new(
get(TEAM_INFO_COMMON_PATH, {
:Season => season,
:SeasonType => season_type,
:LeagueID => league_id,
:TeamID => team_id
})
)
end | [
"def",
"team_info_common",
"(",
"team_id",
",",
"season",
",",
"season_type",
"=",
"NbaStats",
"::",
"Constants",
"::",
"SEASON_TYPE_REGULAR",
",",
"league_id",
"=",
"NbaStats",
"::",
"Constants",
"::",
"LEAGUE_ID_NBA",
")",
"NbaStats",
"::",
"Resources",
"::",
"TeamInfoCommon",
".",
"new",
"(",
"get",
"(",
"TEAM_INFO_COMMON_PATH",
",",
"{",
":Season",
"=>",
"season",
",",
":SeasonType",
"=>",
"season_type",
",",
":LeagueID",
"=>",
"league_id",
",",
":TeamID",
"=>",
"team_id",
"}",
")",
")",
"end"
] | Calls the teaminfocommon API and returns a TeamInfoCommon resource.
@param team_id [Integer]
@param season [String]
@param season_type [String]
@param league_id [String]
@return [NbaStats::Resources::TeamInfoCommon] | [
"Calls",
"the",
"teaminfocommon",
"API",
"and",
"returns",
"a",
"TeamInfoCommon",
"resource",
"."
] | d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa | https://github.com/dagrz/nba_stats/blob/d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa/lib/nba_stats/stats/team_info_common.rb#L18-L32 |
2,813 | dagrz/nba_stats | lib/nba_stats/stats/team_year_by_year_stats.rb | NbaStats.TeamYearByYearStats.team_year_by_year_stats | def team_year_by_year_stats(
team_id,
season,
per_mode=NbaStats::Constants::PER_MODE_TOTALS,
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::TeamYearByYearStats.new(
get(TEAM_YEAR_BY_YEAR_STATS_PATH, {
:LeagueID => league_id,
:PerMode => per_mode,
:SeasonType => season_type,
:TeamID => team_id,
:Season => season
})
)
end | ruby | def team_year_by_year_stats(
team_id,
season,
per_mode=NbaStats::Constants::PER_MODE_TOTALS,
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::TeamYearByYearStats.new(
get(TEAM_YEAR_BY_YEAR_STATS_PATH, {
:LeagueID => league_id,
:PerMode => per_mode,
:SeasonType => season_type,
:TeamID => team_id,
:Season => season
})
)
end | [
"def",
"team_year_by_year_stats",
"(",
"team_id",
",",
"season",
",",
"per_mode",
"=",
"NbaStats",
"::",
"Constants",
"::",
"PER_MODE_TOTALS",
",",
"season_type",
"=",
"NbaStats",
"::",
"Constants",
"::",
"SEASON_TYPE_REGULAR",
",",
"league_id",
"=",
"NbaStats",
"::",
"Constants",
"::",
"LEAGUE_ID_NBA",
")",
"NbaStats",
"::",
"Resources",
"::",
"TeamYearByYearStats",
".",
"new",
"(",
"get",
"(",
"TEAM_YEAR_BY_YEAR_STATS_PATH",
",",
"{",
":LeagueID",
"=>",
"league_id",
",",
":PerMode",
"=>",
"per_mode",
",",
":SeasonType",
"=>",
"season_type",
",",
":TeamID",
"=>",
"team_id",
",",
":Season",
"=>",
"season",
"}",
")",
")",
"end"
] | Calls the teamyearbyyearstats API and returns a TeamYearByYearStats resource.
@param team_id [Integer]
@param season [String]
@param per_mode [String]
@param season_type [String]
@param league_id [String]
@return [NbaStats::Resources::TeamYearByYearStats] | [
"Calls",
"the",
"teamyearbyyearstats",
"API",
"and",
"returns",
"a",
"TeamYearByYearStats",
"resource",
"."
] | d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa | https://github.com/dagrz/nba_stats/blob/d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa/lib/nba_stats/stats/team_year_by_year_stats.rb#L18-L34 |
2,814 | dagrz/nba_stats | lib/nba_stats/stats/box_score_usage.rb | NbaStats.BoxScoreUsage.box_score_usage | def box_score_usage(
game_id,
range_type=0,
start_period=0,
end_period=0,
start_range=0,
end_range=0
)
NbaStats::Resources::BoxScoreUsage.new(
get(BOX_SCORE_USAGE_PATH, {
:GameID => game_id,
:RangeType => range_type,
:StartPeriod => start_period,
:EndPeriod => end_period,
:StartRange => start_range,
:EndRange => end_range
})
)
end | ruby | def box_score_usage(
game_id,
range_type=0,
start_period=0,
end_period=0,
start_range=0,
end_range=0
)
NbaStats::Resources::BoxScoreUsage.new(
get(BOX_SCORE_USAGE_PATH, {
:GameID => game_id,
:RangeType => range_type,
:StartPeriod => start_period,
:EndPeriod => end_period,
:StartRange => start_range,
:EndRange => end_range
})
)
end | [
"def",
"box_score_usage",
"(",
"game_id",
",",
"range_type",
"=",
"0",
",",
"start_period",
"=",
"0",
",",
"end_period",
"=",
"0",
",",
"start_range",
"=",
"0",
",",
"end_range",
"=",
"0",
")",
"NbaStats",
"::",
"Resources",
"::",
"BoxScoreUsage",
".",
"new",
"(",
"get",
"(",
"BOX_SCORE_USAGE_PATH",
",",
"{",
":GameID",
"=>",
"game_id",
",",
":RangeType",
"=>",
"range_type",
",",
":StartPeriod",
"=>",
"start_period",
",",
":EndPeriod",
"=>",
"end_period",
",",
":StartRange",
"=>",
"start_range",
",",
":EndRange",
"=>",
"end_range",
"}",
")",
")",
"end"
] | Calls the boxscoreusage API and returns a BoxScoreUsage resource.
@param game_id [String]
@param range_type [Integer]
@param start_period [Integer]
@param end_period [Integer]
@param start_range [Integer]
@param end_range [Integer]
@return [NbaStats::Resources::BoxScoreUsage] | [
"Calls",
"the",
"boxscoreusage",
"API",
"and",
"returns",
"a",
"BoxScoreUsage",
"resource",
"."
] | d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa | https://github.com/dagrz/nba_stats/blob/d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa/lib/nba_stats/stats/box_score_usage.rb#L19-L37 |
2,815 | dagrz/nba_stats | lib/nba_stats/stats/draft_combine_player_anthro.rb | NbaStats.DraftCombinePlayerAnthro.draft_combine_player_anthro | def draft_combine_player_anthro(
season_year,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::DraftCombinePlayerAnthro.new(
get(DRAFT_COMBINE_PLAYER_ANTHRO_PATH, {
:LeagueID => league_id,
:SeasonYear => season_year
})
)
end | ruby | def draft_combine_player_anthro(
season_year,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::DraftCombinePlayerAnthro.new(
get(DRAFT_COMBINE_PLAYER_ANTHRO_PATH, {
:LeagueID => league_id,
:SeasonYear => season_year
})
)
end | [
"def",
"draft_combine_player_anthro",
"(",
"season_year",
",",
"league_id",
"=",
"NbaStats",
"::",
"Constants",
"::",
"LEAGUE_ID_NBA",
")",
"NbaStats",
"::",
"Resources",
"::",
"DraftCombinePlayerAnthro",
".",
"new",
"(",
"get",
"(",
"DRAFT_COMBINE_PLAYER_ANTHRO_PATH",
",",
"{",
":LeagueID",
"=>",
"league_id",
",",
":SeasonYear",
"=>",
"season_year",
"}",
")",
")",
"end"
] | Calls the draftcombineplayeranthro API and returns a DraftCombinePlayerAnthro resource.
@param season_year [String]
@param league_id [String]
@return [NbaStats::Resources::DraftCombinePlayerAnthro] | [
"Calls",
"the",
"draftcombineplayeranthro",
"API",
"and",
"returns",
"a",
"DraftCombinePlayerAnthro",
"resource",
"."
] | d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa | https://github.com/dagrz/nba_stats/blob/d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa/lib/nba_stats/stats/draft_combine_player_anthro.rb#L15-L25 |
2,816 | codez/wagons | lib/wagons/installer.rb | Wagons.Installer.available | def available
return @available if defined?(@available)
# only keep most recent version in @available
@available = []
load_available_specs.each do |spec|
if prev = @available.find { |w| w.name == spec.name }
if prev.version < spec.version
@available.delete(prev)
@available << spec
end
else
@available << spec
end
end
@available
end | ruby | def available
return @available if defined?(@available)
# only keep most recent version in @available
@available = []
load_available_specs.each do |spec|
if prev = @available.find { |w| w.name == spec.name }
if prev.version < spec.version
@available.delete(prev)
@available << spec
end
else
@available << spec
end
end
@available
end | [
"def",
"available",
"return",
"@available",
"if",
"defined?",
"(",
"@available",
")",
"# only keep most recent version in @available",
"@available",
"=",
"[",
"]",
"load_available_specs",
".",
"each",
"do",
"|",
"spec",
"|",
"if",
"prev",
"=",
"@available",
".",
"find",
"{",
"|",
"w",
"|",
"w",
".",
"name",
"==",
"spec",
".",
"name",
"}",
"if",
"prev",
".",
"version",
"<",
"spec",
".",
"version",
"@available",
".",
"delete",
"(",
"prev",
")",
"@available",
"<<",
"spec",
"end",
"else",
"@available",
"<<",
"spec",
"end",
"end",
"@available",
"end"
] | Most recent gem specifications of all wagons available in GEM_HOME. | [
"Most",
"recent",
"gem",
"specifications",
"of",
"all",
"wagons",
"available",
"in",
"GEM_HOME",
"."
] | 91a6b687e08ceb8c3e054dd6ec36694d4babcd50 | https://github.com/codez/wagons/blob/91a6b687e08ceb8c3e054dd6ec36694d4babcd50/lib/wagons/installer.rb#L20-L36 |
2,817 | codez/wagons | lib/wagons/installer.rb | Wagons.Installer.wagonfile_update | def wagonfile_update(specs)
wagonfile_edit(specs) do |spec, content|
declaration = "gem '#{spec.name}'"
declaration += ", '#{spec.version}'" if include_version_in_wagonfile
unless content.sub!(gem_declaration_regexp(spec.name), declaration)
content += "\n#{declaration}"
end
content
end
end | ruby | def wagonfile_update(specs)
wagonfile_edit(specs) do |spec, content|
declaration = "gem '#{spec.name}'"
declaration += ", '#{spec.version}'" if include_version_in_wagonfile
unless content.sub!(gem_declaration_regexp(spec.name), declaration)
content += "\n#{declaration}"
end
content
end
end | [
"def",
"wagonfile_update",
"(",
"specs",
")",
"wagonfile_edit",
"(",
"specs",
")",
"do",
"|",
"spec",
",",
"content",
"|",
"declaration",
"=",
"\"gem '#{spec.name}'\"",
"declaration",
"+=",
"\", '#{spec.version}'\"",
"if",
"include_version_in_wagonfile",
"unless",
"content",
".",
"sub!",
"(",
"gem_declaration_regexp",
"(",
"spec",
".",
"name",
")",
",",
"declaration",
")",
"content",
"+=",
"\"\\n#{declaration}\"",
"end",
"content",
"end",
"end"
] | Update the Wagonfile with the given gem specifications. | [
"Update",
"the",
"Wagonfile",
"with",
"the",
"given",
"gem",
"specifications",
"."
] | 91a6b687e08ceb8c3e054dd6ec36694d4babcd50 | https://github.com/codez/wagons/blob/91a6b687e08ceb8c3e054dd6ec36694d4babcd50/lib/wagons/installer.rb#L95-L104 |
2,818 | codez/wagons | lib/wagons/installer.rb | Wagons.Installer.wagonfile_remove | def wagonfile_remove(specs)
wagonfile_edit(specs) do |spec, content|
content.sub(gem_declaration_regexp(spec.name), '')
end
end | ruby | def wagonfile_remove(specs)
wagonfile_edit(specs) do |spec, content|
content.sub(gem_declaration_regexp(spec.name), '')
end
end | [
"def",
"wagonfile_remove",
"(",
"specs",
")",
"wagonfile_edit",
"(",
"specs",
")",
"do",
"|",
"spec",
",",
"content",
"|",
"content",
".",
"sub",
"(",
"gem_declaration_regexp",
"(",
"spec",
".",
"name",
")",
",",
"''",
")",
"end",
"end"
] | Remove the given gem specifications from the Wagonfile. | [
"Remove",
"the",
"given",
"gem",
"specifications",
"from",
"the",
"Wagonfile",
"."
] | 91a6b687e08ceb8c3e054dd6ec36694d4babcd50 | https://github.com/codez/wagons/blob/91a6b687e08ceb8c3e054dd6ec36694d4babcd50/lib/wagons/installer.rb#L107-L111 |
2,819 | codez/wagons | lib/wagons/installer.rb | Wagons.Installer.check_dependencies | def check_dependencies(specs)
missing = check_app_requirement(specs)
present = exclude_specs(installed, specs)
future = present + specs
check_all_dependencies(specs, future, missing)
end | ruby | def check_dependencies(specs)
missing = check_app_requirement(specs)
present = exclude_specs(installed, specs)
future = present + specs
check_all_dependencies(specs, future, missing)
end | [
"def",
"check_dependencies",
"(",
"specs",
")",
"missing",
"=",
"check_app_requirement",
"(",
"specs",
")",
"present",
"=",
"exclude_specs",
"(",
"installed",
",",
"specs",
")",
"future",
"=",
"present",
"+",
"specs",
"check_all_dependencies",
"(",
"specs",
",",
"future",
",",
"missing",
")",
"end"
] | Check if all wagon dependencies of the given gem specifications
are met by the installed wagons.
Returns nil if everything is fine or a string with error messages. | [
"Check",
"if",
"all",
"wagon",
"dependencies",
"of",
"the",
"given",
"gem",
"specifications",
"are",
"met",
"by",
"the",
"installed",
"wagons",
".",
"Returns",
"nil",
"if",
"everything",
"is",
"fine",
"or",
"a",
"string",
"with",
"error",
"messages",
"."
] | 91a6b687e08ceb8c3e054dd6ec36694d4babcd50 | https://github.com/codez/wagons/blob/91a6b687e08ceb8c3e054dd6ec36694d4babcd50/lib/wagons/installer.rb#L116-L123 |
2,820 | codez/wagons | lib/wagons/installer.rb | Wagons.Installer.check_app_requirement | def check_app_requirement(specs)
missing = []
specs.each do |spec|
if wagon = wagon_class(spec)
unless wagon.app_requirement.satisfied_by?(Wagons.app_version)
missing << "#{spec} requires application version #{wagon.app_requirement}"
end
end
end
missing
end | ruby | def check_app_requirement(specs)
missing = []
specs.each do |spec|
if wagon = wagon_class(spec)
unless wagon.app_requirement.satisfied_by?(Wagons.app_version)
missing << "#{spec} requires application version #{wagon.app_requirement}"
end
end
end
missing
end | [
"def",
"check_app_requirement",
"(",
"specs",
")",
"missing",
"=",
"[",
"]",
"specs",
".",
"each",
"do",
"|",
"spec",
"|",
"if",
"wagon",
"=",
"wagon_class",
"(",
"spec",
")",
"unless",
"wagon",
".",
"app_requirement",
".",
"satisfied_by?",
"(",
"Wagons",
".",
"app_version",
")",
"missing",
"<<",
"\"#{spec} requires application version #{wagon.app_requirement}\"",
"end",
"end",
"end",
"missing",
"end"
] | Check if the app requirement of the given gem specifications
are met by the current app version.
Returns nil if everything is fine or a array with error messages. | [
"Check",
"if",
"the",
"app",
"requirement",
"of",
"the",
"given",
"gem",
"specifications",
"are",
"met",
"by",
"the",
"current",
"app",
"version",
".",
"Returns",
"nil",
"if",
"everything",
"is",
"fine",
"or",
"a",
"array",
"with",
"error",
"messages",
"."
] | 91a6b687e08ceb8c3e054dd6ec36694d4babcd50 | https://github.com/codez/wagons/blob/91a6b687e08ceb8c3e054dd6ec36694d4babcd50/lib/wagons/installer.rb#L128-L139 |
2,821 | codez/wagons | lib/wagons/installer.rb | Wagons.Installer.check_protected | def check_protected(specs)
protected = []
specs.each do |spec|
msg = Wagons.find(spec.name).protect?
protected << msg if msg.is_a?(String)
end
protected.join("\n").presence
end | ruby | def check_protected(specs)
protected = []
specs.each do |spec|
msg = Wagons.find(spec.name).protect?
protected << msg if msg.is_a?(String)
end
protected.join("\n").presence
end | [
"def",
"check_protected",
"(",
"specs",
")",
"protected",
"=",
"[",
"]",
"specs",
".",
"each",
"do",
"|",
"spec",
"|",
"msg",
"=",
"Wagons",
".",
"find",
"(",
"spec",
".",
"name",
")",
".",
"protect?",
"protected",
"<<",
"msg",
"if",
"msg",
".",
"is_a?",
"(",
"String",
")",
"end",
"protected",
".",
"join",
"(",
"\"\\n\"",
")",
".",
"presence",
"end"
] | Checks if the wagons for given gem specifications are protected.
Returns nil if everything is fine or a string with error messages. | [
"Checks",
"if",
"the",
"wagons",
"for",
"given",
"gem",
"specifications",
"are",
"protected",
".",
"Returns",
"nil",
"if",
"everything",
"is",
"fine",
"or",
"a",
"string",
"with",
"error",
"messages",
"."
] | 91a6b687e08ceb8c3e054dd6ec36694d4babcd50 | https://github.com/codez/wagons/blob/91a6b687e08ceb8c3e054dd6ec36694d4babcd50/lib/wagons/installer.rb#L151-L158 |
2,822 | codez/wagons | lib/wagons/installer.rb | Wagons.Installer.specs_from_names | def specs_from_names(names)
names.map do |name|
spec = available_spec(name)
fail "#{name} was not found" if spec.nil?
spec
end
end | ruby | def specs_from_names(names)
names.map do |name|
spec = available_spec(name)
fail "#{name} was not found" if spec.nil?
spec
end
end | [
"def",
"specs_from_names",
"(",
"names",
")",
"names",
".",
"map",
"do",
"|",
"name",
"|",
"spec",
"=",
"available_spec",
"(",
"name",
")",
"fail",
"\"#{name} was not found\"",
"if",
"spec",
".",
"nil?",
"spec",
"end",
"end"
] | List of available gem specifications with the given names.
Raises an error if a name cannot be found. | [
"List",
"of",
"available",
"gem",
"specifications",
"with",
"the",
"given",
"names",
".",
"Raises",
"an",
"error",
"if",
"a",
"name",
"cannot",
"be",
"found",
"."
] | 91a6b687e08ceb8c3e054dd6ec36694d4babcd50 | https://github.com/codez/wagons/blob/91a6b687e08ceb8c3e054dd6ec36694d4babcd50/lib/wagons/installer.rb#L162-L168 |
2,823 | codez/wagons | lib/wagons/installer.rb | Wagons.Installer.exclude_specs | def exclude_specs(full, to_be_excluded)
full.clone.delete_if { |s| to_be_excluded.find { |d| s.name == d.name } }
end | ruby | def exclude_specs(full, to_be_excluded)
full.clone.delete_if { |s| to_be_excluded.find { |d| s.name == d.name } }
end | [
"def",
"exclude_specs",
"(",
"full",
",",
"to_be_excluded",
")",
"full",
".",
"clone",
".",
"delete_if",
"{",
"|",
"s",
"|",
"to_be_excluded",
".",
"find",
"{",
"|",
"d",
"|",
"s",
".",
"name",
"==",
"d",
".",
"name",
"}",
"}",
"end"
] | Removes all gem specifications with the same name in to_be_excluded from full.
Versions are ignored. | [
"Removes",
"all",
"gem",
"specifications",
"with",
"the",
"same",
"name",
"in",
"to_be_excluded",
"from",
"full",
".",
"Versions",
"are",
"ignored",
"."
] | 91a6b687e08ceb8c3e054dd6ec36694d4babcd50 | https://github.com/codez/wagons/blob/91a6b687e08ceb8c3e054dd6ec36694d4babcd50/lib/wagons/installer.rb#L172-L174 |
2,824 | codez/wagons | lib/wagons/installer.rb | Wagons.Installer.wagon_class | def wagon_class(spec)
@wagon_classes ||= {}
return @wagon_classes[spec] if @wagon_classes.key?(spec)
clazz = nil
file = File.join(spec.gem_dir, 'lib', spec.name, 'wagon.rb')
if File.exist?(file)
require file
clazz = "#{spec.name.camelize}::Wagon".constantize
else
fail "#{spec.name} wagon class not found in #{file}"
end
@wagon_classes[spec] = clazz
end | ruby | def wagon_class(spec)
@wagon_classes ||= {}
return @wagon_classes[spec] if @wagon_classes.key?(spec)
clazz = nil
file = File.join(spec.gem_dir, 'lib', spec.name, 'wagon.rb')
if File.exist?(file)
require file
clazz = "#{spec.name.camelize}::Wagon".constantize
else
fail "#{spec.name} wagon class not found in #{file}"
end
@wagon_classes[spec] = clazz
end | [
"def",
"wagon_class",
"(",
"spec",
")",
"@wagon_classes",
"||=",
"{",
"}",
"return",
"@wagon_classes",
"[",
"spec",
"]",
"if",
"@wagon_classes",
".",
"key?",
"(",
"spec",
")",
"clazz",
"=",
"nil",
"file",
"=",
"File",
".",
"join",
"(",
"spec",
".",
"gem_dir",
",",
"'lib'",
",",
"spec",
".",
"name",
",",
"'wagon.rb'",
")",
"if",
"File",
".",
"exist?",
"(",
"file",
")",
"require",
"file",
"clazz",
"=",
"\"#{spec.name.camelize}::Wagon\"",
".",
"constantize",
"else",
"fail",
"\"#{spec.name} wagon class not found in #{file}\"",
"end",
"@wagon_classes",
"[",
"spec",
"]",
"=",
"clazz",
"end"
] | The wagon class of the given spec. | [
"The",
"wagon",
"class",
"of",
"the",
"given",
"spec",
"."
] | 91a6b687e08ceb8c3e054dd6ec36694d4babcd50 | https://github.com/codez/wagons/blob/91a6b687e08ceb8c3e054dd6ec36694d4babcd50/lib/wagons/installer.rb#L182-L195 |
2,825 | dagrz/nba_stats | lib/nba_stats/stats/common_player_info.rb | NbaStats.CommonPlayerInfo.common_player_info | def common_player_info(
player_id,
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::CommonPlayerInfo.new(
get(COMMON_PLAYER_INFO_PATH, {
:PlayerID => player_id,
:SeasonType => season_type,
:LeagueID => league_id
})
)
end | ruby | def common_player_info(
player_id,
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::CommonPlayerInfo.new(
get(COMMON_PLAYER_INFO_PATH, {
:PlayerID => player_id,
:SeasonType => season_type,
:LeagueID => league_id
})
)
end | [
"def",
"common_player_info",
"(",
"player_id",
",",
"season_type",
"=",
"NbaStats",
"::",
"Constants",
"::",
"SEASON_TYPE_REGULAR",
",",
"league_id",
"=",
"NbaStats",
"::",
"Constants",
"::",
"LEAGUE_ID_NBA",
")",
"NbaStats",
"::",
"Resources",
"::",
"CommonPlayerInfo",
".",
"new",
"(",
"get",
"(",
"COMMON_PLAYER_INFO_PATH",
",",
"{",
":PlayerID",
"=>",
"player_id",
",",
":SeasonType",
"=>",
"season_type",
",",
":LeagueID",
"=>",
"league_id",
"}",
")",
")",
"end"
] | Calls the commonplayerinfo API and returns a CommonPlayerInfo resource.
@param player_id [Integer]
@param season_type [String]
@param league_id [String]
@return [NbaStats::Resources::CommonPlayerInfo] | [
"Calls",
"the",
"commonplayerinfo",
"API",
"and",
"returns",
"a",
"CommonPlayerInfo",
"resource",
"."
] | d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa | https://github.com/dagrz/nba_stats/blob/d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa/lib/nba_stats/stats/common_player_info.rb#L17-L29 |
2,826 | dagrz/nba_stats | lib/nba_stats/stats/franchise_history.rb | NbaStats.FranchiseHistory.franchise_history | def franchise_history(
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::FranchiseHistory.new(
get(FRANCHISE_HISTORY_PATH, {
:LeagueID => league_id
})
)
end | ruby | def franchise_history(
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::FranchiseHistory.new(
get(FRANCHISE_HISTORY_PATH, {
:LeagueID => league_id
})
)
end | [
"def",
"franchise_history",
"(",
"league_id",
"=",
"NbaStats",
"::",
"Constants",
"::",
"LEAGUE_ID_NBA",
")",
"NbaStats",
"::",
"Resources",
"::",
"FranchiseHistory",
".",
"new",
"(",
"get",
"(",
"FRANCHISE_HISTORY_PATH",
",",
"{",
":LeagueID",
"=>",
"league_id",
"}",
")",
")",
"end"
] | Calls the franchisehistory API and returns a FranchiseHistory resource.
@param league_id [String]
@return [NbaStats::Resources::FranchiseHistory] | [
"Calls",
"the",
"franchisehistory",
"API",
"and",
"returns",
"a",
"FranchiseHistory",
"resource",
"."
] | d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa | https://github.com/dagrz/nba_stats/blob/d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa/lib/nba_stats/stats/franchise_history.rb#L14-L22 |
2,827 | dagrz/nba_stats | lib/nba_stats/stats/league_dash_lineups.rb | NbaStats.LeagueDashLineups.league_dash_lineups | def league_dash_lineups(
season,
group_quantity=5,
measure_type=NbaStats::Constants::MEASURE_TYPE_BASE,
per_mode=NbaStats::Constants::PER_MODE_GAME,
plus_minus=NbaStats::Constants::NO,
pace_adjust=NbaStats::Constants::NO,
rank=NbaStats::Constants::NO,
outcome='',
location='',
month=0,
season_segment='',
date_from='',
date_to='',
opponent_team_id=0,
vs_conference='',
vs_division='',
game_segment='',
period=0,
last_n_games=0,
game_id='',
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
unless date_from.nil? or date_from.empty?
date_from = date_from.strftime('%m-%d-%Y')
end
unless date_to.nil? or date_to.empty?
date_to = date_to.strftime('%m-%d-%Y')
end
NbaStats::Resources::LeagueDashLineups.new(
get(LEAGUE_DASH_LINEUPS_PATH, {
:DateFrom => date_from,
:DateTo => date_to,
:GameID => game_id,
:GameSegment => game_segment,
:GroupQuantity => group_quantity,
:LastNGames => last_n_games,
:LeagueID => league_id,
:Location => location,
:MeasureType => measure_type,
:Month => month,
:OpponentTeamID => opponent_team_id,
:Outcome => outcome,
:PaceAdjust => pace_adjust,
:PerMode => per_mode,
:Period => period,
:PlusMinus => plus_minus,
:Rank => rank,
:Season => season,
:SeasonSegment => season_segment,
:SeasonType => season_type,
:VsConference => vs_conference,
:VsDivision => vs_division
})
)
end | ruby | def league_dash_lineups(
season,
group_quantity=5,
measure_type=NbaStats::Constants::MEASURE_TYPE_BASE,
per_mode=NbaStats::Constants::PER_MODE_GAME,
plus_minus=NbaStats::Constants::NO,
pace_adjust=NbaStats::Constants::NO,
rank=NbaStats::Constants::NO,
outcome='',
location='',
month=0,
season_segment='',
date_from='',
date_to='',
opponent_team_id=0,
vs_conference='',
vs_division='',
game_segment='',
period=0,
last_n_games=0,
game_id='',
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
unless date_from.nil? or date_from.empty?
date_from = date_from.strftime('%m-%d-%Y')
end
unless date_to.nil? or date_to.empty?
date_to = date_to.strftime('%m-%d-%Y')
end
NbaStats::Resources::LeagueDashLineups.new(
get(LEAGUE_DASH_LINEUPS_PATH, {
:DateFrom => date_from,
:DateTo => date_to,
:GameID => game_id,
:GameSegment => game_segment,
:GroupQuantity => group_quantity,
:LastNGames => last_n_games,
:LeagueID => league_id,
:Location => location,
:MeasureType => measure_type,
:Month => month,
:OpponentTeamID => opponent_team_id,
:Outcome => outcome,
:PaceAdjust => pace_adjust,
:PerMode => per_mode,
:Period => period,
:PlusMinus => plus_minus,
:Rank => rank,
:Season => season,
:SeasonSegment => season_segment,
:SeasonType => season_type,
:VsConference => vs_conference,
:VsDivision => vs_division
})
)
end | [
"def",
"league_dash_lineups",
"(",
"season",
",",
"group_quantity",
"=",
"5",
",",
"measure_type",
"=",
"NbaStats",
"::",
"Constants",
"::",
"MEASURE_TYPE_BASE",
",",
"per_mode",
"=",
"NbaStats",
"::",
"Constants",
"::",
"PER_MODE_GAME",
",",
"plus_minus",
"=",
"NbaStats",
"::",
"Constants",
"::",
"NO",
",",
"pace_adjust",
"=",
"NbaStats",
"::",
"Constants",
"::",
"NO",
",",
"rank",
"=",
"NbaStats",
"::",
"Constants",
"::",
"NO",
",",
"outcome",
"=",
"''",
",",
"location",
"=",
"''",
",",
"month",
"=",
"0",
",",
"season_segment",
"=",
"''",
",",
"date_from",
"=",
"''",
",",
"date_to",
"=",
"''",
",",
"opponent_team_id",
"=",
"0",
",",
"vs_conference",
"=",
"''",
",",
"vs_division",
"=",
"''",
",",
"game_segment",
"=",
"''",
",",
"period",
"=",
"0",
",",
"last_n_games",
"=",
"0",
",",
"game_id",
"=",
"''",
",",
"season_type",
"=",
"NbaStats",
"::",
"Constants",
"::",
"SEASON_TYPE_REGULAR",
",",
"league_id",
"=",
"NbaStats",
"::",
"Constants",
"::",
"LEAGUE_ID_NBA",
")",
"unless",
"date_from",
".",
"nil?",
"or",
"date_from",
".",
"empty?",
"date_from",
"=",
"date_from",
".",
"strftime",
"(",
"'%m-%d-%Y'",
")",
"end",
"unless",
"date_to",
".",
"nil?",
"or",
"date_to",
".",
"empty?",
"date_to",
"=",
"date_to",
".",
"strftime",
"(",
"'%m-%d-%Y'",
")",
"end",
"NbaStats",
"::",
"Resources",
"::",
"LeagueDashLineups",
".",
"new",
"(",
"get",
"(",
"LEAGUE_DASH_LINEUPS_PATH",
",",
"{",
":DateFrom",
"=>",
"date_from",
",",
":DateTo",
"=>",
"date_to",
",",
":GameID",
"=>",
"game_id",
",",
":GameSegment",
"=>",
"game_segment",
",",
":GroupQuantity",
"=>",
"group_quantity",
",",
":LastNGames",
"=>",
"last_n_games",
",",
":LeagueID",
"=>",
"league_id",
",",
":Location",
"=>",
"location",
",",
":MeasureType",
"=>",
"measure_type",
",",
":Month",
"=>",
"month",
",",
":OpponentTeamID",
"=>",
"opponent_team_id",
",",
":Outcome",
"=>",
"outcome",
",",
":PaceAdjust",
"=>",
"pace_adjust",
",",
":PerMode",
"=>",
"per_mode",
",",
":Period",
"=>",
"period",
",",
":PlusMinus",
"=>",
"plus_minus",
",",
":Rank",
"=>",
"rank",
",",
":Season",
"=>",
"season",
",",
":SeasonSegment",
"=>",
"season_segment",
",",
":SeasonType",
"=>",
"season_type",
",",
":VsConference",
"=>",
"vs_conference",
",",
":VsDivision",
"=>",
"vs_division",
"}",
")",
")",
"end"
] | Calls the leaguedashlineups API and returns a LeagueDashLineups resource.
@param season [String]
@param group_quantity [Integer]
@param measure_type [String]
@param per_mode [String]
@param plus_minus [String]
@param pace_adjust [String]
@param rank [String]
@param outcome [String]
@param location [String]
@param month [Integer]
@param season_segment [String]
@param date_from [Date]
@param date_to [Date]
@param opponent_team_id [Integer]
@param vs_conference [String]
@param vs_division [String]
@param game_segment [String]
@param period [Integer]
@param last_n_games [Integer]
@param game_id [String]
@param season_type [String]
@param league_id [String]
@return [NbaStats::Resources::LeagueDashLineups] | [
"Calls",
"the",
"leaguedashlineups",
"API",
"and",
"returns",
"a",
"LeagueDashLineups",
"resource",
"."
] | d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa | https://github.com/dagrz/nba_stats/blob/d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa/lib/nba_stats/stats/league_dash_lineups.rb#L35-L91 |
2,828 | codez/wagons | lib/wagons/extensions/application.rb | Rails.Application.ordered_railties_with_wagons | def ordered_railties_with_wagons
@ordered_railties ||= ordered_railties_without_wagons.tap do |ordered|
flat = Gem::Version.new(Rails::VERSION::STRING) < Gem::Version.new('4.1.6')
Wagons.all.each do |w|
if flat
ordered.push(ordered.delete(w))
else
ordered.unshift(array_deep_delete(ordered, w))
end
end
end
end | ruby | def ordered_railties_with_wagons
@ordered_railties ||= ordered_railties_without_wagons.tap do |ordered|
flat = Gem::Version.new(Rails::VERSION::STRING) < Gem::Version.new('4.1.6')
Wagons.all.each do |w|
if flat
ordered.push(ordered.delete(w))
else
ordered.unshift(array_deep_delete(ordered, w))
end
end
end
end | [
"def",
"ordered_railties_with_wagons",
"@ordered_railties",
"||=",
"ordered_railties_without_wagons",
".",
"tap",
"do",
"|",
"ordered",
"|",
"flat",
"=",
"Gem",
"::",
"Version",
".",
"new",
"(",
"Rails",
"::",
"VERSION",
"::",
"STRING",
")",
"<",
"Gem",
"::",
"Version",
".",
"new",
"(",
"'4.1.6'",
")",
"Wagons",
".",
"all",
".",
"each",
"do",
"|",
"w",
"|",
"if",
"flat",
"ordered",
".",
"push",
"(",
"ordered",
".",
"delete",
"(",
"w",
")",
")",
"else",
"ordered",
".",
"unshift",
"(",
"array_deep_delete",
"(",
"ordered",
",",
"w",
")",
")",
"end",
"end",
"end",
"end"
] | Append wagons at the end of all railties, even after the application. | [
"Append",
"wagons",
"at",
"the",
"end",
"of",
"all",
"railties",
"even",
"after",
"the",
"application",
"."
] | 91a6b687e08ceb8c3e054dd6ec36694d4babcd50 | https://github.com/codez/wagons/blob/91a6b687e08ceb8c3e054dd6ec36694d4babcd50/lib/wagons/extensions/application.rb#L6-L17 |
2,829 | dagrz/nba_stats | lib/nba_stats/stats/home_page_leaders.rb | NbaStats.HomePageLeaders.home_page_leaders | def home_page_leaders(
season,
game_scope=NbaStats::Constants::GAME_SCOPE_SEASON,
stat_category=NbaStats::Constants::STAT_CATEGORY_POINTS,
player_scope=NbaStats::Constants::PLAYER_SCOPE_ALL_PLAYERS,
player_or_team=NbaStats::Constants::PLAYER_OR_TEAM_PLAYER,
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::HomePageLeaders.new(
get(HOME_PAGE_LEADERS_PATH, {
:Season => season,
:SeasonType => season_type,
:LeagueID => league_id,
:GameScope => game_scope,
:StatCategory => stat_category,
:PlayerScope => player_scope,
:PlayerOrTeam => player_or_team
})
)
end | ruby | def home_page_leaders(
season,
game_scope=NbaStats::Constants::GAME_SCOPE_SEASON,
stat_category=NbaStats::Constants::STAT_CATEGORY_POINTS,
player_scope=NbaStats::Constants::PLAYER_SCOPE_ALL_PLAYERS,
player_or_team=NbaStats::Constants::PLAYER_OR_TEAM_PLAYER,
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::HomePageLeaders.new(
get(HOME_PAGE_LEADERS_PATH, {
:Season => season,
:SeasonType => season_type,
:LeagueID => league_id,
:GameScope => game_scope,
:StatCategory => stat_category,
:PlayerScope => player_scope,
:PlayerOrTeam => player_or_team
})
)
end | [
"def",
"home_page_leaders",
"(",
"season",
",",
"game_scope",
"=",
"NbaStats",
"::",
"Constants",
"::",
"GAME_SCOPE_SEASON",
",",
"stat_category",
"=",
"NbaStats",
"::",
"Constants",
"::",
"STAT_CATEGORY_POINTS",
",",
"player_scope",
"=",
"NbaStats",
"::",
"Constants",
"::",
"PLAYER_SCOPE_ALL_PLAYERS",
",",
"player_or_team",
"=",
"NbaStats",
"::",
"Constants",
"::",
"PLAYER_OR_TEAM_PLAYER",
",",
"season_type",
"=",
"NbaStats",
"::",
"Constants",
"::",
"SEASON_TYPE_REGULAR",
",",
"league_id",
"=",
"NbaStats",
"::",
"Constants",
"::",
"LEAGUE_ID_NBA",
")",
"NbaStats",
"::",
"Resources",
"::",
"HomePageLeaders",
".",
"new",
"(",
"get",
"(",
"HOME_PAGE_LEADERS_PATH",
",",
"{",
":Season",
"=>",
"season",
",",
":SeasonType",
"=>",
"season_type",
",",
":LeagueID",
"=>",
"league_id",
",",
":GameScope",
"=>",
"game_scope",
",",
":StatCategory",
"=>",
"stat_category",
",",
":PlayerScope",
"=>",
"player_scope",
",",
":PlayerOrTeam",
"=>",
"player_or_team",
"}",
")",
")",
"end"
] | Calls the homepageleaders API and returns a HomePageLeaders resource.
@param season [String]
@param season_type [String]
@param league_id [String]
@param game_scope [String]
@param stat_category [String]
@param player_scope [String]
@param player_or_team [String]
@return [NbaStats::Resources::HomePageLeaders] | [
"Calls",
"the",
"homepageleaders",
"API",
"and",
"returns",
"a",
"HomePageLeaders",
"resource",
"."
] | d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa | https://github.com/dagrz/nba_stats/blob/d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa/lib/nba_stats/stats/home_page_leaders.rb#L20-L40 |
2,830 | dagrz/nba_stats | lib/nba_stats/stats/team_game_log.rb | NbaStats.TeamGameLog.team_game_log | def team_game_log(
team_id,
season,
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::TeamGameLog.new(
get(TEAM_GAME_LOG_PATH, {
:Season => season,
:SeasonType => season_type,
:LeagueID => league_id,
:TeamID => team_id
})
)
end | ruby | def team_game_log(
team_id,
season,
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::TeamGameLog.new(
get(TEAM_GAME_LOG_PATH, {
:Season => season,
:SeasonType => season_type,
:LeagueID => league_id,
:TeamID => team_id
})
)
end | [
"def",
"team_game_log",
"(",
"team_id",
",",
"season",
",",
"season_type",
"=",
"NbaStats",
"::",
"Constants",
"::",
"SEASON_TYPE_REGULAR",
",",
"league_id",
"=",
"NbaStats",
"::",
"Constants",
"::",
"LEAGUE_ID_NBA",
")",
"NbaStats",
"::",
"Resources",
"::",
"TeamGameLog",
".",
"new",
"(",
"get",
"(",
"TEAM_GAME_LOG_PATH",
",",
"{",
":Season",
"=>",
"season",
",",
":SeasonType",
"=>",
"season_type",
",",
":LeagueID",
"=>",
"league_id",
",",
":TeamID",
"=>",
"team_id",
"}",
")",
")",
"end"
] | Calls the teamgamelog API and returns a TeamGameLog resource.
@param team_id [Integer]
@param season [String]
@param season_type [String]
@param league_id [String]
@return [NbaStats::Resources::TeamGameLog] | [
"Calls",
"the",
"teamgamelog",
"API",
"and",
"returns",
"a",
"TeamGameLog",
"resource",
"."
] | d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa | https://github.com/dagrz/nba_stats/blob/d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa/lib/nba_stats/stats/team_game_log.rb#L18-L32 |
2,831 | dagrz/nba_stats | lib/nba_stats/stats/box_score_scoring.rb | NbaStats.BoxScoreScoring.box_score_scoring | def box_score_scoring(
game_id,
range_type=0,
start_period=0,
end_period=0,
start_range=0,
end_range=0
)
NbaStats::Resources::BoxScoreScoring.new(
get(BOX_SCORE_SCORING_PATH, {
:GameID => game_id,
:RangeType => range_type,
:StartPeriod => start_period,
:EndPeriod => end_period,
:StartRange => start_range,
:EndRange => end_range
})
)
end | ruby | def box_score_scoring(
game_id,
range_type=0,
start_period=0,
end_period=0,
start_range=0,
end_range=0
)
NbaStats::Resources::BoxScoreScoring.new(
get(BOX_SCORE_SCORING_PATH, {
:GameID => game_id,
:RangeType => range_type,
:StartPeriod => start_period,
:EndPeriod => end_period,
:StartRange => start_range,
:EndRange => end_range
})
)
end | [
"def",
"box_score_scoring",
"(",
"game_id",
",",
"range_type",
"=",
"0",
",",
"start_period",
"=",
"0",
",",
"end_period",
"=",
"0",
",",
"start_range",
"=",
"0",
",",
"end_range",
"=",
"0",
")",
"NbaStats",
"::",
"Resources",
"::",
"BoxScoreScoring",
".",
"new",
"(",
"get",
"(",
"BOX_SCORE_SCORING_PATH",
",",
"{",
":GameID",
"=>",
"game_id",
",",
":RangeType",
"=>",
"range_type",
",",
":StartPeriod",
"=>",
"start_period",
",",
":EndPeriod",
"=>",
"end_period",
",",
":StartRange",
"=>",
"start_range",
",",
":EndRange",
"=>",
"end_range",
"}",
")",
")",
"end"
] | Calls the boxscorescoring API and returns a BoxScoreScoring resource.
@param game_id [String]
@param range_type [Integer]
@param start_period [Integer]
@param end_period [Integer]
@param start_range [Integer]
@param end_range [Integer]
@return [NbaStats::Resources::BoxScoreScoring] | [
"Calls",
"the",
"boxscorescoring",
"API",
"and",
"returns",
"a",
"BoxScoreScoring",
"resource",
"."
] | d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa | https://github.com/dagrz/nba_stats/blob/d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa/lib/nba_stats/stats/box_score_scoring.rb#L19-L37 |
2,832 | dagrz/nba_stats | lib/nba_stats/stats/draft_combine_spot_shooting.rb | NbaStats.DraftCombineSpotShooting.draft_combine_spot_shooting | def draft_combine_spot_shooting(
season_year,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::DraftCombineSpotShooting.new(
get(DRAFT_COMBINE_SPOT_SHOOTING_PATH, {
:LeagueID => league_id,
:SeasonYear => season_year
})
)
end | ruby | def draft_combine_spot_shooting(
season_year,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::DraftCombineSpotShooting.new(
get(DRAFT_COMBINE_SPOT_SHOOTING_PATH, {
:LeagueID => league_id,
:SeasonYear => season_year
})
)
end | [
"def",
"draft_combine_spot_shooting",
"(",
"season_year",
",",
"league_id",
"=",
"NbaStats",
"::",
"Constants",
"::",
"LEAGUE_ID_NBA",
")",
"NbaStats",
"::",
"Resources",
"::",
"DraftCombineSpotShooting",
".",
"new",
"(",
"get",
"(",
"DRAFT_COMBINE_SPOT_SHOOTING_PATH",
",",
"{",
":LeagueID",
"=>",
"league_id",
",",
":SeasonYear",
"=>",
"season_year",
"}",
")",
")",
"end"
] | Calls the draftcombinespotshooting API and returns a DraftCombineSpotShooting resource.
@param season_year [String]
@param league_id [String]
@return [NbaStats::Resources::DraftCombineSpotShooting] | [
"Calls",
"the",
"draftcombinespotshooting",
"API",
"and",
"returns",
"a",
"DraftCombineSpotShooting",
"resource",
"."
] | d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa | https://github.com/dagrz/nba_stats/blob/d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa/lib/nba_stats/stats/draft_combine_spot_shooting.rb#L15-L25 |
2,833 | dagrz/nba_stats | lib/nba_stats/stats/common_team_years.rb | NbaStats.CommonTeamYears.common_team_years | def common_team_years(
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::CommonTeamYears.new(
get(COMMON_TEAM_YEARS_PATH, {
:LeagueID => league_id
})
)
end | ruby | def common_team_years(
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::CommonTeamYears.new(
get(COMMON_TEAM_YEARS_PATH, {
:LeagueID => league_id
})
)
end | [
"def",
"common_team_years",
"(",
"league_id",
"=",
"NbaStats",
"::",
"Constants",
"::",
"LEAGUE_ID_NBA",
")",
"NbaStats",
"::",
"Resources",
"::",
"CommonTeamYears",
".",
"new",
"(",
"get",
"(",
"COMMON_TEAM_YEARS_PATH",
",",
"{",
":LeagueID",
"=>",
"league_id",
"}",
")",
")",
"end"
] | Calls the commonteamyears API and returns a CommonTeamYears resource.
@param league_id [String]
@return [NbaStats::Resources::CommonTeamYears] | [
"Calls",
"the",
"commonteamyears",
"API",
"and",
"returns",
"a",
"CommonTeamYears",
"resource",
"."
] | d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa | https://github.com/dagrz/nba_stats/blob/d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa/lib/nba_stats/stats/common_team_years.rb#L14-L22 |
2,834 | forcedotcom/salesforce-deskcom-api | lib/desk_api/client.rb | DeskApi.Client.request | def request(method, path, params = {}, &block)
connection.send(method, path, params, &block)
rescue Faraday::Error::ClientError => err
raise DeskApi::Error::ClientError.new(err)
rescue JSON::ParserError => err
raise DeskApi::Error::ParserError.new(err)
end | ruby | def request(method, path, params = {}, &block)
connection.send(method, path, params, &block)
rescue Faraday::Error::ClientError => err
raise DeskApi::Error::ClientError.new(err)
rescue JSON::ParserError => err
raise DeskApi::Error::ParserError.new(err)
end | [
"def",
"request",
"(",
"method",
",",
"path",
",",
"params",
"=",
"{",
"}",
",",
"&",
"block",
")",
"connection",
".",
"send",
"(",
"method",
",",
"path",
",",
"params",
",",
"block",
")",
"rescue",
"Faraday",
"::",
"Error",
"::",
"ClientError",
"=>",
"err",
"raise",
"DeskApi",
"::",
"Error",
"::",
"ClientError",
".",
"new",
"(",
"err",
")",
"rescue",
"JSON",
"::",
"ParserError",
"=>",
"err",
"raise",
"DeskApi",
"::",
"Error",
"::",
"ParserError",
".",
"new",
"(",
"err",
")",
"end"
] | Hands off the request to Faraday for further processing
@param method [Symbol] the http method to call
@param path [String] the url path to the resource
@param params [Hash] optional additional url params
@yield [Faraday::Response] for further request customizations.
@return [Faraday::Response]
@raises [DeskApi::Error::ClientError]
@raises [DeskApi::Error::ParserError] | [
"Hands",
"off",
"the",
"request",
"to",
"Faraday",
"for",
"further",
"processing"
] | af1080459215d4cb769e785656bcee1d56696f95 | https://github.com/forcedotcom/salesforce-deskcom-api/blob/af1080459215d4cb769e785656bcee1d56696f95/lib/desk_api/client.rb#L104-L110 |
2,835 | dagrz/nba_stats | lib/nba_stats/stats/shot_chart_detail.rb | NbaStats.ShotChartDetail.shot_chart_detail | def shot_chart_detail(
season,
team_id,
player_id,
game_id=nil,
outcome=nil,
location=nil,
month=0,
season_segment=nil,
date_from=nil,
date_to=nil,
opponent_team_id=0,
vs_conference=nil,
vs_division=nil,
position=nil,
rookie_year=nil,
game_segment=nil,
period=0,
last_n_games=0,
context_filter=nil,
context_measure=NbaStats::Constants::CONTEXT_MEASURE_FG_PCT,
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
unless date_from.nil?
date_from = date_from.strftime('%m-%d-%Y')
end
unless date_to.nil?
date_to = date_to.strftime('%m-%d-%Y')
end
NbaStats::Resources::ShotChartDetail.new(
get(SHOT_CHART_DETAIL_PATH, {
:Season => season,
:SeasonType => season_type,
:LeagueID => league_id,
:TeamID => team_id,
:PlayerID => player_id,
:GameID => game_id,
:Outcome => outcome,
:Location => location,
:Month => month,
:SeasonSegment => season_segment,
:DateFrom => date_from,
:DateTo => date_to,
:OpponentTeamID => opponent_team_id,
:VsConference => vs_conference,
:VsDivision => vs_division,
:Position => position,
:RookieYear => rookie_year,
:GameSegment => game_segment,
:Period => period,
:LastNGames => last_n_games,
:ContextFilter => context_filter,
:ContextMeasure => context_measure
})
)
end | ruby | def shot_chart_detail(
season,
team_id,
player_id,
game_id=nil,
outcome=nil,
location=nil,
month=0,
season_segment=nil,
date_from=nil,
date_to=nil,
opponent_team_id=0,
vs_conference=nil,
vs_division=nil,
position=nil,
rookie_year=nil,
game_segment=nil,
period=0,
last_n_games=0,
context_filter=nil,
context_measure=NbaStats::Constants::CONTEXT_MEASURE_FG_PCT,
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
unless date_from.nil?
date_from = date_from.strftime('%m-%d-%Y')
end
unless date_to.nil?
date_to = date_to.strftime('%m-%d-%Y')
end
NbaStats::Resources::ShotChartDetail.new(
get(SHOT_CHART_DETAIL_PATH, {
:Season => season,
:SeasonType => season_type,
:LeagueID => league_id,
:TeamID => team_id,
:PlayerID => player_id,
:GameID => game_id,
:Outcome => outcome,
:Location => location,
:Month => month,
:SeasonSegment => season_segment,
:DateFrom => date_from,
:DateTo => date_to,
:OpponentTeamID => opponent_team_id,
:VsConference => vs_conference,
:VsDivision => vs_division,
:Position => position,
:RookieYear => rookie_year,
:GameSegment => game_segment,
:Period => period,
:LastNGames => last_n_games,
:ContextFilter => context_filter,
:ContextMeasure => context_measure
})
)
end | [
"def",
"shot_chart_detail",
"(",
"season",
",",
"team_id",
",",
"player_id",
",",
"game_id",
"=",
"nil",
",",
"outcome",
"=",
"nil",
",",
"location",
"=",
"nil",
",",
"month",
"=",
"0",
",",
"season_segment",
"=",
"nil",
",",
"date_from",
"=",
"nil",
",",
"date_to",
"=",
"nil",
",",
"opponent_team_id",
"=",
"0",
",",
"vs_conference",
"=",
"nil",
",",
"vs_division",
"=",
"nil",
",",
"position",
"=",
"nil",
",",
"rookie_year",
"=",
"nil",
",",
"game_segment",
"=",
"nil",
",",
"period",
"=",
"0",
",",
"last_n_games",
"=",
"0",
",",
"context_filter",
"=",
"nil",
",",
"context_measure",
"=",
"NbaStats",
"::",
"Constants",
"::",
"CONTEXT_MEASURE_FG_PCT",
",",
"season_type",
"=",
"NbaStats",
"::",
"Constants",
"::",
"SEASON_TYPE_REGULAR",
",",
"league_id",
"=",
"NbaStats",
"::",
"Constants",
"::",
"LEAGUE_ID_NBA",
")",
"unless",
"date_from",
".",
"nil?",
"date_from",
"=",
"date_from",
".",
"strftime",
"(",
"'%m-%d-%Y'",
")",
"end",
"unless",
"date_to",
".",
"nil?",
"date_to",
"=",
"date_to",
".",
"strftime",
"(",
"'%m-%d-%Y'",
")",
"end",
"NbaStats",
"::",
"Resources",
"::",
"ShotChartDetail",
".",
"new",
"(",
"get",
"(",
"SHOT_CHART_DETAIL_PATH",
",",
"{",
":Season",
"=>",
"season",
",",
":SeasonType",
"=>",
"season_type",
",",
":LeagueID",
"=>",
"league_id",
",",
":TeamID",
"=>",
"team_id",
",",
":PlayerID",
"=>",
"player_id",
",",
":GameID",
"=>",
"game_id",
",",
":Outcome",
"=>",
"outcome",
",",
":Location",
"=>",
"location",
",",
":Month",
"=>",
"month",
",",
":SeasonSegment",
"=>",
"season_segment",
",",
":DateFrom",
"=>",
"date_from",
",",
":DateTo",
"=>",
"date_to",
",",
":OpponentTeamID",
"=>",
"opponent_team_id",
",",
":VsConference",
"=>",
"vs_conference",
",",
":VsDivision",
"=>",
"vs_division",
",",
":Position",
"=>",
"position",
",",
":RookieYear",
"=>",
"rookie_year",
",",
":GameSegment",
"=>",
"game_segment",
",",
":Period",
"=>",
"period",
",",
":LastNGames",
"=>",
"last_n_games",
",",
":ContextFilter",
"=>",
"context_filter",
",",
":ContextMeasure",
"=>",
"context_measure",
"}",
")",
")",
"end"
] | Calls the shotchartdetail API and returns a ShotChartDetail resource.
@param season [String]
@param team_id [Integer]
@param player_id [Integer]
@param game_id [String]
@param outcome [String]
@param location [String]
@param month [Integer]
@param season_segment [String]
@param date_from [Date]
@param date_to [Date]
@param opponent_team_id [Integer]
@param vs_conference [String]
@param vs_division [String]
@param position [String]
@param rookie_year [String]
@param game_segment [String]
@param period [Integer]
@param last_n_games [Integer]
@param context_filter [String]
@param context_measure [String]
@param season_type [String]
@param league_id [String]
@return [NbaStats::Resources::ShotChartDetail] | [
"Calls",
"the",
"shotchartdetail",
"API",
"and",
"returns",
"a",
"ShotChartDetail",
"resource",
"."
] | d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa | https://github.com/dagrz/nba_stats/blob/d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa/lib/nba_stats/stats/shot_chart_detail.rb#L35-L91 |
2,836 | forcedotcom/salesforce-deskcom-api | lib/desk_api/configuration.rb | DeskApi.Configuration.middleware | def middleware
@middleware ||= proc do |builder|
builder.request(:desk_encode_dates)
builder.request(:desk_encode_json)
builder.request(*authorize_request)
builder.request(:desk_retry)
builder.response(:desk_parse_dates)
builder.response(:desk_follow_redirects)
builder.response(:desk_raise_error, DeskApi::Error::ClientError)
builder.response(:desk_raise_error, DeskApi::Error::ServerError)
builder.response(:desk_parse_json)
builder.adapter(Faraday.default_adapter)
end
end | ruby | def middleware
@middleware ||= proc do |builder|
builder.request(:desk_encode_dates)
builder.request(:desk_encode_json)
builder.request(*authorize_request)
builder.request(:desk_retry)
builder.response(:desk_parse_dates)
builder.response(:desk_follow_redirects)
builder.response(:desk_raise_error, DeskApi::Error::ClientError)
builder.response(:desk_raise_error, DeskApi::Error::ServerError)
builder.response(:desk_parse_json)
builder.adapter(Faraday.default_adapter)
end
end | [
"def",
"middleware",
"@middleware",
"||=",
"proc",
"do",
"|",
"builder",
"|",
"builder",
".",
"request",
"(",
":desk_encode_dates",
")",
"builder",
".",
"request",
"(",
":desk_encode_json",
")",
"builder",
".",
"request",
"(",
"authorize_request",
")",
"builder",
".",
"request",
"(",
":desk_retry",
")",
"builder",
".",
"response",
"(",
":desk_parse_dates",
")",
"builder",
".",
"response",
"(",
":desk_follow_redirects",
")",
"builder",
".",
"response",
"(",
":desk_raise_error",
",",
"DeskApi",
"::",
"Error",
"::",
"ClientError",
")",
"builder",
".",
"response",
"(",
":desk_raise_error",
",",
"DeskApi",
"::",
"Error",
"::",
"ServerError",
")",
"builder",
".",
"response",
"(",
":desk_parse_json",
")",
"builder",
".",
"adapter",
"(",
"Faraday",
".",
"default_adapter",
")",
"end",
"end"
] | Returns the middleware proc to be used by Faraday
@return [Proc] | [
"Returns",
"the",
"middleware",
"proc",
"to",
"be",
"used",
"by",
"Faraday"
] | af1080459215d4cb769e785656bcee1d56696f95 | https://github.com/forcedotcom/salesforce-deskcom-api/blob/af1080459215d4cb769e785656bcee1d56696f95/lib/desk_api/configuration.rb#L109-L124 |
2,837 | forcedotcom/salesforce-deskcom-api | lib/desk_api/configuration.rb | DeskApi.Configuration.reset! | def reset!
DeskApi::Configuration.keys.each do |key|
send("#{key}=", DeskApi::Default.options[key])
end
self
end | ruby | def reset!
DeskApi::Configuration.keys.each do |key|
send("#{key}=", DeskApi::Default.options[key])
end
self
end | [
"def",
"reset!",
"DeskApi",
"::",
"Configuration",
".",
"keys",
".",
"each",
"do",
"|",
"key",
"|",
"send",
"(",
"\"#{key}=\"",
",",
"DeskApi",
"::",
"Default",
".",
"options",
"[",
"key",
"]",
")",
"end",
"self",
"end"
] | Resets the client to the default settings.
@return [DeskApi::Client] | [
"Resets",
"the",
"client",
"to",
"the",
"default",
"settings",
"."
] | af1080459215d4cb769e785656bcee1d56696f95 | https://github.com/forcedotcom/salesforce-deskcom-api/blob/af1080459215d4cb769e785656bcee1d56696f95/lib/desk_api/configuration.rb#L140-L145 |
2,838 | forcedotcom/salesforce-deskcom-api | lib/desk_api/configuration.rb | DeskApi.Configuration.validate_credentials! | def validate_credentials!
fail(
DeskApi::Error::ConfigurationError, 'Invalid credentials: ' \
'Either username/password or OAuth credentials must be specified.'
) unless credentials?
validate_oauth! if oauth.values.all?
validate_basic_auth! if basic_auth.values.all?
end | ruby | def validate_credentials!
fail(
DeskApi::Error::ConfigurationError, 'Invalid credentials: ' \
'Either username/password or OAuth credentials must be specified.'
) unless credentials?
validate_oauth! if oauth.values.all?
validate_basic_auth! if basic_auth.values.all?
end | [
"def",
"validate_credentials!",
"fail",
"(",
"DeskApi",
"::",
"Error",
"::",
"ConfigurationError",
",",
"'Invalid credentials: '",
"'Either username/password or OAuth credentials must be specified.'",
")",
"unless",
"credentials?",
"validate_oauth!",
"if",
"oauth",
".",
"values",
".",
"all?",
"validate_basic_auth!",
"if",
"basic_auth",
".",
"values",
".",
"all?",
"end"
] | Raises an error if credentials are not set or of
the wrong type.
@raise [DeskApi::Error::ConfigurationError] | [
"Raises",
"an",
"error",
"if",
"credentials",
"are",
"not",
"set",
"or",
"of",
"the",
"wrong",
"type",
"."
] | af1080459215d4cb769e785656bcee1d56696f95 | https://github.com/forcedotcom/salesforce-deskcom-api/blob/af1080459215d4cb769e785656bcee1d56696f95/lib/desk_api/configuration.rb#L207-L215 |
2,839 | domitry/mikon | lib/mikon/pivot.rb | Mikon.DataFrame.pivot | def pivot(args={})
args = {
column: nil,
row: nil,
value: nil,
fill_value: Float::NAN
}.merge(args)
raise ArgumentError unless [:column, :row, :value].all?{|sym| args[sym].is_a?(Symbol)}
column = self[args[:column]].factors
index = self[args[:row]].factors
source = column.reduce({}) do |memo, label|
arr = []
df = self.select{|row| row[args[:column]] == label}
index.each do |i|
unless df.any?{|row| row[args[:row]] == i}
arr.push(args[:fill_value])
else
column = df.select{|row| row[args[:row]] == i}[args[:value]]
arr.push(column.to_a[0])
end
end
memo[label] = arr
memo
end
Mikon::DataFrame.new(source, index: index)
end | ruby | def pivot(args={})
args = {
column: nil,
row: nil,
value: nil,
fill_value: Float::NAN
}.merge(args)
raise ArgumentError unless [:column, :row, :value].all?{|sym| args[sym].is_a?(Symbol)}
column = self[args[:column]].factors
index = self[args[:row]].factors
source = column.reduce({}) do |memo, label|
arr = []
df = self.select{|row| row[args[:column]] == label}
index.each do |i|
unless df.any?{|row| row[args[:row]] == i}
arr.push(args[:fill_value])
else
column = df.select{|row| row[args[:row]] == i}[args[:value]]
arr.push(column.to_a[0])
end
end
memo[label] = arr
memo
end
Mikon::DataFrame.new(source, index: index)
end | [
"def",
"pivot",
"(",
"args",
"=",
"{",
"}",
")",
"args",
"=",
"{",
"column",
":",
"nil",
",",
"row",
":",
"nil",
",",
"value",
":",
"nil",
",",
"fill_value",
":",
"Float",
"::",
"NAN",
"}",
".",
"merge",
"(",
"args",
")",
"raise",
"ArgumentError",
"unless",
"[",
":column",
",",
":row",
",",
":value",
"]",
".",
"all?",
"{",
"|",
"sym",
"|",
"args",
"[",
"sym",
"]",
".",
"is_a?",
"(",
"Symbol",
")",
"}",
"column",
"=",
"self",
"[",
"args",
"[",
":column",
"]",
"]",
".",
"factors",
"index",
"=",
"self",
"[",
"args",
"[",
":row",
"]",
"]",
".",
"factors",
"source",
"=",
"column",
".",
"reduce",
"(",
"{",
"}",
")",
"do",
"|",
"memo",
",",
"label",
"|",
"arr",
"=",
"[",
"]",
"df",
"=",
"self",
".",
"select",
"{",
"|",
"row",
"|",
"row",
"[",
"args",
"[",
":column",
"]",
"]",
"==",
"label",
"}",
"index",
".",
"each",
"do",
"|",
"i",
"|",
"unless",
"df",
".",
"any?",
"{",
"|",
"row",
"|",
"row",
"[",
"args",
"[",
":row",
"]",
"]",
"==",
"i",
"}",
"arr",
".",
"push",
"(",
"args",
"[",
":fill_value",
"]",
")",
"else",
"column",
"=",
"df",
".",
"select",
"{",
"|",
"row",
"|",
"row",
"[",
"args",
"[",
":row",
"]",
"]",
"==",
"i",
"}",
"[",
"args",
"[",
":value",
"]",
"]",
"arr",
".",
"push",
"(",
"column",
".",
"to_a",
"[",
"0",
"]",
")",
"end",
"end",
"memo",
"[",
"label",
"]",
"=",
"arr",
"memo",
"end",
"Mikon",
"::",
"DataFrame",
".",
"new",
"(",
"source",
",",
"index",
":",
"index",
")",
"end"
] | Experimental Implementation.
DO NOT USE THIS METHOD | [
"Experimental",
"Implementation",
".",
"DO",
"NOT",
"USE",
"THIS",
"METHOD"
] | 69886f5b6767d141e0a5624f0de2f34743909537 | https://github.com/domitry/mikon/blob/69886f5b6767d141e0a5624f0de2f34743909537/lib/mikon/pivot.rb#L5-L34 |
2,840 | jasonl/eden | lib/eden/tokenizers/basic_tokenizer.rb | Eden.BasicTokenizer.translate_keyword_tokens | def translate_keyword_tokens( token )
keywords = ["__LINE__", "__ENCODING__", "__FILE__", "BEGIN",
"END", "alias", "and", "begin", "break", "case",
"class", "def", "defined?", "do", "else", "elsif",
"end", "ensure", "false", "for", "if", "in",
"module", "next", "nil", "not", "or", "redo",
"rescue", "retry", "return", "self", "super",
"then", "true", "undef", "unless", "until",
"when", "while", "yield"]
if keywords.include?( token.content )
token.type = token.content.downcase.to_sym
# Change the state if we match a keyword
@expr_state = :beg
end
# A couple of exceptions
if token.content == "BEGIN"
token.type = :begin_global
@expr_state = :beg
elsif token.content == "END"
token.type = :end_global
@expr_state = :beg
end
token
end | ruby | def translate_keyword_tokens( token )
keywords = ["__LINE__", "__ENCODING__", "__FILE__", "BEGIN",
"END", "alias", "and", "begin", "break", "case",
"class", "def", "defined?", "do", "else", "elsif",
"end", "ensure", "false", "for", "if", "in",
"module", "next", "nil", "not", "or", "redo",
"rescue", "retry", "return", "self", "super",
"then", "true", "undef", "unless", "until",
"when", "while", "yield"]
if keywords.include?( token.content )
token.type = token.content.downcase.to_sym
# Change the state if we match a keyword
@expr_state = :beg
end
# A couple of exceptions
if token.content == "BEGIN"
token.type = :begin_global
@expr_state = :beg
elsif token.content == "END"
token.type = :end_global
@expr_state = :beg
end
token
end | [
"def",
"translate_keyword_tokens",
"(",
"token",
")",
"keywords",
"=",
"[",
"\"__LINE__\"",
",",
"\"__ENCODING__\"",
",",
"\"__FILE__\"",
",",
"\"BEGIN\"",
",",
"\"END\"",
",",
"\"alias\"",
",",
"\"and\"",
",",
"\"begin\"",
",",
"\"break\"",
",",
"\"case\"",
",",
"\"class\"",
",",
"\"def\"",
",",
"\"defined?\"",
",",
"\"do\"",
",",
"\"else\"",
",",
"\"elsif\"",
",",
"\"end\"",
",",
"\"ensure\"",
",",
"\"false\"",
",",
"\"for\"",
",",
"\"if\"",
",",
"\"in\"",
",",
"\"module\"",
",",
"\"next\"",
",",
"\"nil\"",
",",
"\"not\"",
",",
"\"or\"",
",",
"\"redo\"",
",",
"\"rescue\"",
",",
"\"retry\"",
",",
"\"return\"",
",",
"\"self\"",
",",
"\"super\"",
",",
"\"then\"",
",",
"\"true\"",
",",
"\"undef\"",
",",
"\"unless\"",
",",
"\"until\"",
",",
"\"when\"",
",",
"\"while\"",
",",
"\"yield\"",
"]",
"if",
"keywords",
".",
"include?",
"(",
"token",
".",
"content",
")",
"token",
".",
"type",
"=",
"token",
".",
"content",
".",
"downcase",
".",
"to_sym",
"# Change the state if we match a keyword",
"@expr_state",
"=",
":beg",
"end",
"# A couple of exceptions ",
"if",
"token",
".",
"content",
"==",
"\"BEGIN\"",
"token",
".",
"type",
"=",
":begin_global",
"@expr_state",
"=",
":beg",
"elsif",
"token",
".",
"content",
"==",
"\"END\"",
"token",
".",
"type",
"=",
":end_global",
"@expr_state",
"=",
":beg",
"end",
"token",
"end"
] | Takes an identifier token, and tranforms its type to
match Ruby keywords where the identifier is actually a keyword.
Reserved words are defined in S.8.5.1 of the Ruby spec. | [
"Takes",
"an",
"identifier",
"token",
"and",
"tranforms",
"its",
"type",
"to",
"match",
"Ruby",
"keywords",
"where",
"the",
"identifier",
"is",
"actually",
"a",
"keyword",
".",
"Reserved",
"words",
"are",
"defined",
"in",
"S",
".",
"8",
".",
"5",
".",
"1",
"of",
"the",
"Ruby",
"spec",
"."
] | 8a08a4000c63a6b20c07a872cca2dcb0d263baf9 | https://github.com/jasonl/eden/blob/8a08a4000c63a6b20c07a872cca2dcb0d263baf9/lib/eden/tokenizers/basic_tokenizer.rb#L140-L165 |
2,841 | dagrz/nba_stats | lib/nba_stats/client.rb | NbaStats.Client.get | def get(path='/', params={})
uri = Addressable::URI.new
uri.query_values = params
# Build the path with + instead of %20 because nba.com is flaky
full_path = "#{path}?#{uri.query.gsub(/%20/,'+')}"
request(:get, full_path)
end | ruby | def get(path='/', params={})
uri = Addressable::URI.new
uri.query_values = params
# Build the path with + instead of %20 because nba.com is flaky
full_path = "#{path}?#{uri.query.gsub(/%20/,'+')}"
request(:get, full_path)
end | [
"def",
"get",
"(",
"path",
"=",
"'/'",
",",
"params",
"=",
"{",
"}",
")",
"uri",
"=",
"Addressable",
"::",
"URI",
".",
"new",
"uri",
".",
"query_values",
"=",
"params",
"# Build the path with + instead of %20 because nba.com is flaky",
"full_path",
"=",
"\"#{path}?#{uri.query.gsub(/%20/,'+')}\"",
"request",
"(",
":get",
",",
"full_path",
")",
"end"
] | Perform a HTTP GET request
@param path [String]
@param params [Hash]
@return [Hash] | [
"Perform",
"a",
"HTTP",
"GET",
"request"
] | d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa | https://github.com/dagrz/nba_stats/blob/d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa/lib/nba_stats/client.rb#L103-L109 |
2,842 | dagrz/nba_stats | lib/nba_stats/client.rb | NbaStats.Client.request | def request(method, path)
resource[path].send(method.to_sym, request_headers) { |response, request, result, &block|
case response.code
when 200
response
when 400
if response.include? ' is required'
raise ArgumentError.new(response)
else
raise BadRequestError.new(response)
end
else
response.return!(request, result, &block)
end
}
end | ruby | def request(method, path)
resource[path].send(method.to_sym, request_headers) { |response, request, result, &block|
case response.code
when 200
response
when 400
if response.include? ' is required'
raise ArgumentError.new(response)
else
raise BadRequestError.new(response)
end
else
response.return!(request, result, &block)
end
}
end | [
"def",
"request",
"(",
"method",
",",
"path",
")",
"resource",
"[",
"path",
"]",
".",
"send",
"(",
"method",
".",
"to_sym",
",",
"request_headers",
")",
"{",
"|",
"response",
",",
"request",
",",
"result",
",",
"&",
"block",
"|",
"case",
"response",
".",
"code",
"when",
"200",
"response",
"when",
"400",
"if",
"response",
".",
"include?",
"' is required'",
"raise",
"ArgumentError",
".",
"new",
"(",
"response",
")",
"else",
"raise",
"BadRequestError",
".",
"new",
"(",
"response",
")",
"end",
"else",
"response",
".",
"return!",
"(",
"request",
",",
"result",
",",
"block",
")",
"end",
"}",
"end"
] | Send the HTTP request
@param method [String]
@param path [String]
@return [RestClient::Response] | [
"Send",
"the",
"HTTP",
"request"
] | d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa | https://github.com/dagrz/nba_stats/blob/d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa/lib/nba_stats/client.rb#L123-L138 |
2,843 | dagrz/nba_stats | lib/nba_stats/stats/draft_combine_stats.rb | NbaStats.DraftCombineStats.draft_combine_stats | def draft_combine_stats(
season_year,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::DraftCombineStats.new(
get(DRAFT_COMBINE_STATS_PATH, {
:LeagueID => league_id,
:SeasonYear => season_year
})
)
end | ruby | def draft_combine_stats(
season_year,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::DraftCombineStats.new(
get(DRAFT_COMBINE_STATS_PATH, {
:LeagueID => league_id,
:SeasonYear => season_year
})
)
end | [
"def",
"draft_combine_stats",
"(",
"season_year",
",",
"league_id",
"=",
"NbaStats",
"::",
"Constants",
"::",
"LEAGUE_ID_NBA",
")",
"NbaStats",
"::",
"Resources",
"::",
"DraftCombineStats",
".",
"new",
"(",
"get",
"(",
"DRAFT_COMBINE_STATS_PATH",
",",
"{",
":LeagueID",
"=>",
"league_id",
",",
":SeasonYear",
"=>",
"season_year",
"}",
")",
")",
"end"
] | Calls the draftcombinestats API and returns a DraftCombineStats resource.
@param season_year [String]
@param league_id [String]
@return [NbaStats::Resources::DraftCombineStats] | [
"Calls",
"the",
"draftcombinestats",
"API",
"and",
"returns",
"a",
"DraftCombineStats",
"resource",
"."
] | d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa | https://github.com/dagrz/nba_stats/blob/d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa/lib/nba_stats/stats/draft_combine_stats.rb#L15-L25 |
2,844 | dagrz/nba_stats | lib/nba_stats/stats/player_dashboard_by_general_splits.rb | NbaStats.PlayerDashboardByGeneralSplits.player_dashboard_by_general_splits | def player_dashboard_by_general_splits(
season,
player_id,
date_from=nil,
date_to=nil,
game_segment=nil,
last_n_games=0,
league_id=NbaStats::Constants::LEAGUE_ID_NBA,
location=nil,
measure_type=NbaStats::Constants::MEASURE_TYPE_USAGE,
month=0,
opponent_team_id=0,
outcome=nil,
pace_adjust=NbaStats::Constants::NO,
per_mode=NbaStats::Constants::PER_MODE_GAME,
period=0,
plus_minus=NbaStats::Constants::NO,
rank=NbaStats::Constants::NO,
season_segment=nil,
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
vs_conference=nil,
vs_division=nil
)
unless date_from.nil?
date_from = date_from.strftime('%m-%d-%Y')
end
unless date_to.nil?
date_to = date_to.strftime('%m-%d-%Y')
end
NbaStats::Resources::PlayerDashboardByGeneralSplits.new(
get(PLAYER_DASHBOARD_BY_GENERAL_SPLITS_PATH, {
:DateFrom => date_from,
:DateTo => date_to,
:GameSegment => game_segment,
:LastNGames => last_n_games,
:LeagueID => league_id,
:Location => location,
:MeasureType => measure_type,
:Month => month,
:OpponentTeamID => opponent_team_id,
:Outcome => outcome,
:PaceAdjust => pace_adjust,
:PerMode => per_mode,
:Period => period,
:PlayerID => player_id,
:PlusMinus => plus_minus,
:Rank => rank,
:Season => season,
:SeasonSegment => season_segment,
:SeasonType => season_type,
:VsConference => vs_conference,
:VsDivision => vs_division
})
)
end | ruby | def player_dashboard_by_general_splits(
season,
player_id,
date_from=nil,
date_to=nil,
game_segment=nil,
last_n_games=0,
league_id=NbaStats::Constants::LEAGUE_ID_NBA,
location=nil,
measure_type=NbaStats::Constants::MEASURE_TYPE_USAGE,
month=0,
opponent_team_id=0,
outcome=nil,
pace_adjust=NbaStats::Constants::NO,
per_mode=NbaStats::Constants::PER_MODE_GAME,
period=0,
plus_minus=NbaStats::Constants::NO,
rank=NbaStats::Constants::NO,
season_segment=nil,
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
vs_conference=nil,
vs_division=nil
)
unless date_from.nil?
date_from = date_from.strftime('%m-%d-%Y')
end
unless date_to.nil?
date_to = date_to.strftime('%m-%d-%Y')
end
NbaStats::Resources::PlayerDashboardByGeneralSplits.new(
get(PLAYER_DASHBOARD_BY_GENERAL_SPLITS_PATH, {
:DateFrom => date_from,
:DateTo => date_to,
:GameSegment => game_segment,
:LastNGames => last_n_games,
:LeagueID => league_id,
:Location => location,
:MeasureType => measure_type,
:Month => month,
:OpponentTeamID => opponent_team_id,
:Outcome => outcome,
:PaceAdjust => pace_adjust,
:PerMode => per_mode,
:Period => period,
:PlayerID => player_id,
:PlusMinus => plus_minus,
:Rank => rank,
:Season => season,
:SeasonSegment => season_segment,
:SeasonType => season_type,
:VsConference => vs_conference,
:VsDivision => vs_division
})
)
end | [
"def",
"player_dashboard_by_general_splits",
"(",
"season",
",",
"player_id",
",",
"date_from",
"=",
"nil",
",",
"date_to",
"=",
"nil",
",",
"game_segment",
"=",
"nil",
",",
"last_n_games",
"=",
"0",
",",
"league_id",
"=",
"NbaStats",
"::",
"Constants",
"::",
"LEAGUE_ID_NBA",
",",
"location",
"=",
"nil",
",",
"measure_type",
"=",
"NbaStats",
"::",
"Constants",
"::",
"MEASURE_TYPE_USAGE",
",",
"month",
"=",
"0",
",",
"opponent_team_id",
"=",
"0",
",",
"outcome",
"=",
"nil",
",",
"pace_adjust",
"=",
"NbaStats",
"::",
"Constants",
"::",
"NO",
",",
"per_mode",
"=",
"NbaStats",
"::",
"Constants",
"::",
"PER_MODE_GAME",
",",
"period",
"=",
"0",
",",
"plus_minus",
"=",
"NbaStats",
"::",
"Constants",
"::",
"NO",
",",
"rank",
"=",
"NbaStats",
"::",
"Constants",
"::",
"NO",
",",
"season_segment",
"=",
"nil",
",",
"season_type",
"=",
"NbaStats",
"::",
"Constants",
"::",
"SEASON_TYPE_REGULAR",
",",
"vs_conference",
"=",
"nil",
",",
"vs_division",
"=",
"nil",
")",
"unless",
"date_from",
".",
"nil?",
"date_from",
"=",
"date_from",
".",
"strftime",
"(",
"'%m-%d-%Y'",
")",
"end",
"unless",
"date_to",
".",
"nil?",
"date_to",
"=",
"date_to",
".",
"strftime",
"(",
"'%m-%d-%Y'",
")",
"end",
"NbaStats",
"::",
"Resources",
"::",
"PlayerDashboardByGeneralSplits",
".",
"new",
"(",
"get",
"(",
"PLAYER_DASHBOARD_BY_GENERAL_SPLITS_PATH",
",",
"{",
":DateFrom",
"=>",
"date_from",
",",
":DateTo",
"=>",
"date_to",
",",
":GameSegment",
"=>",
"game_segment",
",",
":LastNGames",
"=>",
"last_n_games",
",",
":LeagueID",
"=>",
"league_id",
",",
":Location",
"=>",
"location",
",",
":MeasureType",
"=>",
"measure_type",
",",
":Month",
"=>",
"month",
",",
":OpponentTeamID",
"=>",
"opponent_team_id",
",",
":Outcome",
"=>",
"outcome",
",",
":PaceAdjust",
"=>",
"pace_adjust",
",",
":PerMode",
"=>",
"per_mode",
",",
":Period",
"=>",
"period",
",",
":PlayerID",
"=>",
"player_id",
",",
":PlusMinus",
"=>",
"plus_minus",
",",
":Rank",
"=>",
"rank",
",",
":Season",
"=>",
"season",
",",
":SeasonSegment",
"=>",
"season_segment",
",",
":SeasonType",
"=>",
"season_type",
",",
":VsConference",
"=>",
"vs_conference",
",",
":VsDivision",
"=>",
"vs_division",
"}",
")",
")",
"end"
] | Calls the playerdashboardbygeneralsplits API and returns a PlayerDashboardByGeneralSplits resource.
@param season [String]
@param player_id [Integer]
@param date_from [Date]
@param date_to [Date]
@param game_segment [String]
@param last_n_games [Integer]
@param league_id [String]
@param location [String]
@param measure_type [String]
@param month [Integer]
@param opponent_team_id [Integer]
@param outcome [String]
@param pace_adjust [String]
@param per_mode [String]
@param period [Integer]
@param plus_minus [String]
@param rank [String]
@param season_segment [String]
@param season_type [String]
@param vs_conference [String]
@param vs_division [String]
@return [NbaStats::Resources::PlayerDashboardByGeneralSplits] | [
"Calls",
"the",
"playerdashboardbygeneralsplits",
"API",
"and",
"returns",
"a",
"PlayerDashboardByGeneralSplits",
"resource",
"."
] | d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa | https://github.com/dagrz/nba_stats/blob/d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa/lib/nba_stats/stats/player_dashboard_by_general_splits.rb#L34-L88 |
2,845 | dcuddeback/rspec-tag_matchers | lib/rspec/tag_matchers/helpers/sentence_helper.rb | RSpec::TagMatchers::Helpers.SentenceHelper.make_sentence | def make_sentence(*strings)
options = strings.last.is_a?(Hash) ? strings.pop : {}
strings = strings.flatten.map(&:to_s).reject(&:empty?)
conjunction = options[:conjunction] || "and"
case strings.count
when 0
""
when 1
strings.first
else
last = strings.pop
puncuation = strings.count > 1 ? ", " : " "
[strings, "#{conjunction} #{last}"].flatten.join(puncuation)
end
end | ruby | def make_sentence(*strings)
options = strings.last.is_a?(Hash) ? strings.pop : {}
strings = strings.flatten.map(&:to_s).reject(&:empty?)
conjunction = options[:conjunction] || "and"
case strings.count
when 0
""
when 1
strings.first
else
last = strings.pop
puncuation = strings.count > 1 ? ", " : " "
[strings, "#{conjunction} #{last}"].flatten.join(puncuation)
end
end | [
"def",
"make_sentence",
"(",
"*",
"strings",
")",
"options",
"=",
"strings",
".",
"last",
".",
"is_a?",
"(",
"Hash",
")",
"?",
"strings",
".",
"pop",
":",
"{",
"}",
"strings",
"=",
"strings",
".",
"flatten",
".",
"map",
"(",
":to_s",
")",
".",
"reject",
"(",
":empty?",
")",
"conjunction",
"=",
"options",
"[",
":conjunction",
"]",
"||",
"\"and\"",
"case",
"strings",
".",
"count",
"when",
"0",
"\"\"",
"when",
"1",
"strings",
".",
"first",
"else",
"last",
"=",
"strings",
".",
"pop",
"puncuation",
"=",
"strings",
".",
"count",
">",
"1",
"?",
"\", \"",
":",
"\" \"",
"[",
"strings",
",",
"\"#{conjunction} #{last}\"",
"]",
".",
"flatten",
".",
"join",
"(",
"puncuation",
")",
"end",
"end"
] | Joins multiple strings into a sentence with punctuation and conjunctions.
@example Forming sentences
make_sentence("foo") # => "foo"
make_sentence("foo", "bar") # => "foo and bar"
make_sentence("foo", "bar", "baz") # => "foo, bar, and baz"
@example Overriding the conjunction
make_sentence("foo", "bar", "baz", :conjunction => "or") # => "foo, bar, or baz"
@param [Strings] *strings A list of strings to be combined into a sentence. The last item
can be an options hash.
@option *strings.last [String] :conjunction ("and") The conjunction to use to join sentence
fragments.
@return [String] | [
"Joins",
"multiple",
"strings",
"into",
"a",
"sentence",
"with",
"punctuation",
"and",
"conjunctions",
"."
] | 6396a833d99ea669699afb1b3dfc62c4512c8882 | https://github.com/dcuddeback/rspec-tag_matchers/blob/6396a833d99ea669699afb1b3dfc62c4512c8882/lib/rspec/tag_matchers/helpers/sentence_helper.rb#L20-L36 |
2,846 | MrEmelianenko/drape | lib/drape/automatic_delegation.rb | Drape.AutomaticDelegation.method_missing | def method_missing(method, *args, &block)
return super unless delegatable?(method)
self.class.delegate method
send(method, *args, &block)
end | ruby | def method_missing(method, *args, &block)
return super unless delegatable?(method)
self.class.delegate method
send(method, *args, &block)
end | [
"def",
"method_missing",
"(",
"method",
",",
"*",
"args",
",",
"&",
"block",
")",
"return",
"super",
"unless",
"delegatable?",
"(",
"method",
")",
"self",
".",
"class",
".",
"delegate",
"method",
"send",
"(",
"method",
",",
"args",
",",
"block",
")",
"end"
] | Delegates missing instance methods to the source object. | [
"Delegates",
"missing",
"instance",
"methods",
"to",
"the",
"source",
"object",
"."
] | cc9e8d55341d3145317d425031f5cb46f9cba552 | https://github.com/MrEmelianenko/drape/blob/cc9e8d55341d3145317d425031f5cb46f9cba552/lib/drape/automatic_delegation.rb#L6-L11 |
2,847 | dagrz/nba_stats | lib/nba_stats/stats/box_score_four_factors.rb | NbaStats.BoxScoreFourFactors.box_score_four_factors | def box_score_four_factors(
game_id,
range_type=0,
start_period=0,
end_period=0,
start_range=0,
end_range=0
)
NbaStats::Resources::BoxScoreFourFactors.new(
get(BOX_SCORE_FOUR_FACTORS_PATH, {
:GameID => game_id,
:RangeType => range_type,
:StartPeriod => start_period,
:EndPeriod => end_period,
:StartRange => start_range,
:EndRange => end_range
})
)
end | ruby | def box_score_four_factors(
game_id,
range_type=0,
start_period=0,
end_period=0,
start_range=0,
end_range=0
)
NbaStats::Resources::BoxScoreFourFactors.new(
get(BOX_SCORE_FOUR_FACTORS_PATH, {
:GameID => game_id,
:RangeType => range_type,
:StartPeriod => start_period,
:EndPeriod => end_period,
:StartRange => start_range,
:EndRange => end_range
})
)
end | [
"def",
"box_score_four_factors",
"(",
"game_id",
",",
"range_type",
"=",
"0",
",",
"start_period",
"=",
"0",
",",
"end_period",
"=",
"0",
",",
"start_range",
"=",
"0",
",",
"end_range",
"=",
"0",
")",
"NbaStats",
"::",
"Resources",
"::",
"BoxScoreFourFactors",
".",
"new",
"(",
"get",
"(",
"BOX_SCORE_FOUR_FACTORS_PATH",
",",
"{",
":GameID",
"=>",
"game_id",
",",
":RangeType",
"=>",
"range_type",
",",
":StartPeriod",
"=>",
"start_period",
",",
":EndPeriod",
"=>",
"end_period",
",",
":StartRange",
"=>",
"start_range",
",",
":EndRange",
"=>",
"end_range",
"}",
")",
")",
"end"
] | Calls the boxscorefourfactors API and returns a BoxScoreFourFactors resource.
@param game_id [String]
@param range_type [Integer]
@param start_period [Integer]
@param end_period [Integer]
@param start_range [Integer]
@param end_range [Integer]
@return [NbaStats::Resources::BoxScoreFourFactors] | [
"Calls",
"the",
"boxscorefourfactors",
"API",
"and",
"returns",
"a",
"BoxScoreFourFactors",
"resource",
"."
] | d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa | https://github.com/dagrz/nba_stats/blob/d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa/lib/nba_stats/stats/box_score_four_factors.rb#L19-L37 |
2,848 | dcuddeback/rspec-tag_matchers | lib/rspec/tag_matchers/has_tag.rb | RSpec::TagMatchers.HasTag.matches? | def matches?(rendered)
@rendered = rendered
matches = Nokogiri::HTML::Document.parse(@rendered.to_s).css(@name).select do |element|
matches_attributes?(element) && matches_content?(element) && matches_criteria?(element)
end
matches_count?(matches)
end | ruby | def matches?(rendered)
@rendered = rendered
matches = Nokogiri::HTML::Document.parse(@rendered.to_s).css(@name).select do |element|
matches_attributes?(element) && matches_content?(element) && matches_criteria?(element)
end
matches_count?(matches)
end | [
"def",
"matches?",
"(",
"rendered",
")",
"@rendered",
"=",
"rendered",
"matches",
"=",
"Nokogiri",
"::",
"HTML",
"::",
"Document",
".",
"parse",
"(",
"@rendered",
".",
"to_s",
")",
".",
"css",
"(",
"@name",
")",
".",
"select",
"do",
"|",
"element",
"|",
"matches_attributes?",
"(",
"element",
")",
"&&",
"matches_content?",
"(",
"element",
")",
"&&",
"matches_criteria?",
"(",
"element",
")",
"end",
"matches_count?",
"(",
"matches",
")",
"end"
] | Answers whether or not the matcher matches any elements within +rendered+.
@param [String] rendered A string of HTML or an Object whose +to_s+ method returns HTML.
(That includes Nokogiri classes.)
@return [Boolean] | [
"Answers",
"whether",
"or",
"not",
"the",
"matcher",
"matches",
"any",
"elements",
"within",
"+",
"rendered",
"+",
"."
] | 6396a833d99ea669699afb1b3dfc62c4512c8882 | https://github.com/dcuddeback/rspec-tag_matchers/blob/6396a833d99ea669699afb1b3dfc62c4512c8882/lib/rspec/tag_matchers/has_tag.rb#L140-L146 |
2,849 | dcuddeback/rspec-tag_matchers | lib/rspec/tag_matchers/has_tag.rb | RSpec::TagMatchers.HasTag.grouped_attributes_description | def grouped_attributes_description(attributes)
make_sentence(
attributes.sort_by{ |key, value| key.to_s }.map do |key, value|
attribute_description(key, value)
end
)
end | ruby | def grouped_attributes_description(attributes)
make_sentence(
attributes.sort_by{ |key, value| key.to_s }.map do |key, value|
attribute_description(key, value)
end
)
end | [
"def",
"grouped_attributes_description",
"(",
"attributes",
")",
"make_sentence",
"(",
"attributes",
".",
"sort_by",
"{",
"|",
"key",
",",
"value",
"|",
"key",
".",
"to_s",
"}",
".",
"map",
"do",
"|",
"key",
",",
"value",
"|",
"attribute_description",
"(",
"key",
",",
"value",
")",
"end",
")",
"end"
] | Describes a group of attribute criteria, combining them into a sentence fragment, with
punctuation and conjunctions if necessary.
@param [Array] attributes A list of <tt>[key, value]</tt> pairs that describe the attribute
criteria.
@return [String] | [
"Describes",
"a",
"group",
"of",
"attribute",
"criteria",
"combining",
"them",
"into",
"a",
"sentence",
"fragment",
"with",
"punctuation",
"and",
"conjunctions",
"if",
"necessary",
"."
] | 6396a833d99ea669699afb1b3dfc62c4512c8882 | https://github.com/dcuddeback/rspec-tag_matchers/blob/6396a833d99ea669699afb1b3dfc62c4512c8882/lib/rspec/tag_matchers/has_tag.rb#L358-L364 |
2,850 | dagrz/nba_stats | lib/nba_stats/stats/player_profile.rb | NbaStats.PlayerProfile.player_profile | def player_profile(
player_id,
season,
graph_start_season,
graph_end_season,
graph_stat=NbaStats::Constants::GRAPH_STAT_POINTS,
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::PlayerProfile.new(
get(PLAYER_PROFILE_PATH, {
:Season => season,
:SeasonType => season_type,
:LeagueID => league_id,
:PlayerID => player_id,
:GraphStartSeason => graph_start_season,
:GraphEndSeason => graph_end_season,
:GraphStat => graph_stat
})
)
end | ruby | def player_profile(
player_id,
season,
graph_start_season,
graph_end_season,
graph_stat=NbaStats::Constants::GRAPH_STAT_POINTS,
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::PlayerProfile.new(
get(PLAYER_PROFILE_PATH, {
:Season => season,
:SeasonType => season_type,
:LeagueID => league_id,
:PlayerID => player_id,
:GraphStartSeason => graph_start_season,
:GraphEndSeason => graph_end_season,
:GraphStat => graph_stat
})
)
end | [
"def",
"player_profile",
"(",
"player_id",
",",
"season",
",",
"graph_start_season",
",",
"graph_end_season",
",",
"graph_stat",
"=",
"NbaStats",
"::",
"Constants",
"::",
"GRAPH_STAT_POINTS",
",",
"season_type",
"=",
"NbaStats",
"::",
"Constants",
"::",
"SEASON_TYPE_REGULAR",
",",
"league_id",
"=",
"NbaStats",
"::",
"Constants",
"::",
"LEAGUE_ID_NBA",
")",
"NbaStats",
"::",
"Resources",
"::",
"PlayerProfile",
".",
"new",
"(",
"get",
"(",
"PLAYER_PROFILE_PATH",
",",
"{",
":Season",
"=>",
"season",
",",
":SeasonType",
"=>",
"season_type",
",",
":LeagueID",
"=>",
"league_id",
",",
":PlayerID",
"=>",
"player_id",
",",
":GraphStartSeason",
"=>",
"graph_start_season",
",",
":GraphEndSeason",
"=>",
"graph_end_season",
",",
":GraphStat",
"=>",
"graph_stat",
"}",
")",
")",
"end"
] | Calls the playerprofile API and returns a PlayerProfile resource.
@param player_id [Integer]
@param season [String]
@param graph_start_season [String]
@param graph_end_season [String]
@param graph_stat [String]
@param season_type [String]
@param league_id [String]
@return [NbaStats::Resources::PlayerProfile] | [
"Calls",
"the",
"playerprofile",
"API",
"and",
"returns",
"a",
"PlayerProfile",
"resource",
"."
] | d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa | https://github.com/dagrz/nba_stats/blob/d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa/lib/nba_stats/stats/player_profile.rb#L21-L41 |
2,851 | dagrz/nba_stats | lib/nba_stats/stats/player_career_stats.rb | NbaStats.PlayerCareerStats.player_career_stats | def player_career_stats(
player_id,
per_mode=NbaStats::Constants::PER_MODE_TOTALS,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::PlayerCareerStats.new(
get(PLAYER_CAREER_STATS_PATH, {
:PlayerID => player_id,
:LeagueID => league_id,
:PerMode => per_mode
})
)
end | ruby | def player_career_stats(
player_id,
per_mode=NbaStats::Constants::PER_MODE_TOTALS,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::PlayerCareerStats.new(
get(PLAYER_CAREER_STATS_PATH, {
:PlayerID => player_id,
:LeagueID => league_id,
:PerMode => per_mode
})
)
end | [
"def",
"player_career_stats",
"(",
"player_id",
",",
"per_mode",
"=",
"NbaStats",
"::",
"Constants",
"::",
"PER_MODE_TOTALS",
",",
"league_id",
"=",
"NbaStats",
"::",
"Constants",
"::",
"LEAGUE_ID_NBA",
")",
"NbaStats",
"::",
"Resources",
"::",
"PlayerCareerStats",
".",
"new",
"(",
"get",
"(",
"PLAYER_CAREER_STATS_PATH",
",",
"{",
":PlayerID",
"=>",
"player_id",
",",
":LeagueID",
"=>",
"league_id",
",",
":PerMode",
"=>",
"per_mode",
"}",
")",
")",
"end"
] | Calls the playercareerstats API and returns a PlayerCareerStats resource.
@param player_id [Integer]
@param per_mode [String]
@param league_id [String]
@return [NbaStats::Resources::PlayerCareerStats] | [
"Calls",
"the",
"playercareerstats",
"API",
"and",
"returns",
"a",
"PlayerCareerStats",
"resource",
"."
] | d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa | https://github.com/dagrz/nba_stats/blob/d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa/lib/nba_stats/stats/player_career_stats.rb#L16-L28 |
2,852 | jasonl/eden | lib/eden/tokenizers/string_tokenizer.rb | Eden.StringTokenizer.tokenize_non_expanded_string | def tokenize_non_expanded_string( start_delimiter )
delimiter_depth = 0
matched_delimiter = is_matched_delimiter?( start_delimiter )
end_delimiter = find_matching_delimiter( start_delimiter )
advance # Pass the opening delimiter
until((cchar == end_delimiter && delimiter_depth == 0) || @i >= @length)
if matched_delimiter
delimiter_depth += 1 if cchar == start_delimiter
delimiter_depth -= 1 if cchar == end_delimiter
end
if cchar == '\\'
advance(2) # Pass the escaped character
else
advance
end
end
advance # Pass the closing quote
if @state == :regex
advance if ['i', 'm'].include?( cchar )
end
@expr_state = :end
capture_token( @state )
end | ruby | def tokenize_non_expanded_string( start_delimiter )
delimiter_depth = 0
matched_delimiter = is_matched_delimiter?( start_delimiter )
end_delimiter = find_matching_delimiter( start_delimiter )
advance # Pass the opening delimiter
until((cchar == end_delimiter && delimiter_depth == 0) || @i >= @length)
if matched_delimiter
delimiter_depth += 1 if cchar == start_delimiter
delimiter_depth -= 1 if cchar == end_delimiter
end
if cchar == '\\'
advance(2) # Pass the escaped character
else
advance
end
end
advance # Pass the closing quote
if @state == :regex
advance if ['i', 'm'].include?( cchar )
end
@expr_state = :end
capture_token( @state )
end | [
"def",
"tokenize_non_expanded_string",
"(",
"start_delimiter",
")",
"delimiter_depth",
"=",
"0",
"matched_delimiter",
"=",
"is_matched_delimiter?",
"(",
"start_delimiter",
")",
"end_delimiter",
"=",
"find_matching_delimiter",
"(",
"start_delimiter",
")",
"advance",
"# Pass the opening delimiter",
"until",
"(",
"(",
"cchar",
"==",
"end_delimiter",
"&&",
"delimiter_depth",
"==",
"0",
")",
"||",
"@i",
">=",
"@length",
")",
"if",
"matched_delimiter",
"delimiter_depth",
"+=",
"1",
"if",
"cchar",
"==",
"start_delimiter",
"delimiter_depth",
"-=",
"1",
"if",
"cchar",
"==",
"end_delimiter",
"end",
"if",
"cchar",
"==",
"'\\\\'",
"advance",
"(",
"2",
")",
"# Pass the escaped character",
"else",
"advance",
"end",
"end",
"advance",
"# Pass the closing quote",
"if",
"@state",
"==",
":regex",
"advance",
"if",
"[",
"'i'",
",",
"'m'",
"]",
".",
"include?",
"(",
"cchar",
")",
"end",
"@expr_state",
"=",
":end",
"capture_token",
"(",
"@state",
")",
"end"
] | If a block is given, it gets run after the final delimiter is detected. The
primary purpose for this is to allow the capture of regex modifiers | [
"If",
"a",
"block",
"is",
"given",
"it",
"gets",
"run",
"after",
"the",
"final",
"delimiter",
"is",
"detected",
".",
"The",
"primary",
"purpose",
"for",
"this",
"is",
"to",
"allow",
"the",
"capture",
"of",
"regex",
"modifiers"
] | 8a08a4000c63a6b20c07a872cca2dcb0d263baf9 | https://github.com/jasonl/eden/blob/8a08a4000c63a6b20c07a872cca2dcb0d263baf9/lib/eden/tokenizers/string_tokenizer.rb#L9-L37 |
2,853 | jasonl/eden | lib/eden/tokenizers/string_tokenizer.rb | Eden.StringTokenizer.tokenize_heredoc_delimiter | def tokenize_heredoc_delimiter
offset = 2
if cchar == '-'
advance
offset = 3
end
if cchar =~ /[A-Za-z_]/
advance
advance until /[A-Za-z0-9_]/.match( cchar ).nil?
elsif /['"`]/.match(cchar)
advance_through_quoted_delimiter(cchar)
else
return nil
end
@heredoc_delimiter = thunk[offset..-1]
capture_token( :heredoc_delimiter )
end | ruby | def tokenize_heredoc_delimiter
offset = 2
if cchar == '-'
advance
offset = 3
end
if cchar =~ /[A-Za-z_]/
advance
advance until /[A-Za-z0-9_]/.match( cchar ).nil?
elsif /['"`]/.match(cchar)
advance_through_quoted_delimiter(cchar)
else
return nil
end
@heredoc_delimiter = thunk[offset..-1]
capture_token( :heredoc_delimiter )
end | [
"def",
"tokenize_heredoc_delimiter",
"offset",
"=",
"2",
"if",
"cchar",
"==",
"'-'",
"advance",
"offset",
"=",
"3",
"end",
"if",
"cchar",
"=~",
"/",
"/",
"advance",
"advance",
"until",
"/",
"/",
".",
"match",
"(",
"cchar",
")",
".",
"nil?",
"elsif",
"/",
"/",
".",
"match",
"(",
"cchar",
")",
"advance_through_quoted_delimiter",
"(",
"cchar",
")",
"else",
"return",
"nil",
"end",
"@heredoc_delimiter",
"=",
"thunk",
"[",
"offset",
"..",
"-",
"1",
"]",
"capture_token",
"(",
":heredoc_delimiter",
")",
"end"
] | Called from tokenize_lt_operators when it identifies that
<< is a heredoc delimiter. Expects that '<<' will already
be included in the current thunk. | [
"Called",
"from",
"tokenize_lt_operators",
"when",
"it",
"identifies",
"that",
"<<",
"is",
"a",
"heredoc",
"delimiter",
".",
"Expects",
"that",
"<<",
"will",
"already",
"be",
"included",
"in",
"the",
"current",
"thunk",
"."
] | 8a08a4000c63a6b20c07a872cca2dcb0d263baf9 | https://github.com/jasonl/eden/blob/8a08a4000c63a6b20c07a872cca2dcb0d263baf9/lib/eden/tokenizers/string_tokenizer.rb#L95-L112 |
2,854 | forcedotcom/salesforce-deskcom-api | lib/desk_api/resource.rb | DeskApi.Resource.to_hash | def to_hash
load
{}.tap do |hash|
@_definition.each do |k, v|
hash[k] = v
end
end
end | ruby | def to_hash
load
{}.tap do |hash|
@_definition.each do |k, v|
hash[k] = v
end
end
end | [
"def",
"to_hash",
"load",
"{",
"}",
".",
"tap",
"do",
"|",
"hash",
"|",
"@_definition",
".",
"each",
"do",
"|",
"k",
",",
"v",
"|",
"hash",
"[",
"k",
"]",
"=",
"v",
"end",
"end",
"end"
] | Returns a hash based on the current definition of the resource
@return [Hash] definition hash | [
"Returns",
"a",
"hash",
"based",
"on",
"the",
"current",
"definition",
"of",
"the",
"resource"
] | af1080459215d4cb769e785656bcee1d56696f95 | https://github.com/forcedotcom/salesforce-deskcom-api/blob/af1080459215d4cb769e785656bcee1d56696f95/lib/desk_api/resource.rb#L117-L125 |
2,855 | forcedotcom/salesforce-deskcom-api | lib/desk_api/resource.rb | DeskApi.Resource.respond_to? | def respond_to?(method)
load
meth = method.to_s
return true if is_embedded?(meth)
return true if is_link?(meth)
return true if meth.end_with?('=') and is_field?(meth[0...-1])
return true if is_field?(meth)
super
end | ruby | def respond_to?(method)
load
meth = method.to_s
return true if is_embedded?(meth)
return true if is_link?(meth)
return true if meth.end_with?('=') and is_field?(meth[0...-1])
return true if is_field?(meth)
super
end | [
"def",
"respond_to?",
"(",
"method",
")",
"load",
"meth",
"=",
"method",
".",
"to_s",
"return",
"true",
"if",
"is_embedded?",
"(",
"meth",
")",
"return",
"true",
"if",
"is_link?",
"(",
"meth",
")",
"return",
"true",
"if",
"meth",
".",
"end_with?",
"(",
"'='",
")",
"and",
"is_field?",
"(",
"meth",
"[",
"0",
"...",
"-",
"1",
"]",
")",
"return",
"true",
"if",
"is_field?",
"(",
"meth",
")",
"super",
"end"
] | Checks if this resource responds to a specific method
@param method [String/Symbol]
@return [Boolean] | [
"Checks",
"if",
"this",
"resource",
"responds",
"to",
"a",
"specific",
"method"
] | af1080459215d4cb769e785656bcee1d56696f95 | https://github.com/forcedotcom/salesforce-deskcom-api/blob/af1080459215d4cb769e785656bcee1d56696f95/lib/desk_api/resource.rb#L138-L148 |
2,856 | forcedotcom/salesforce-deskcom-api | lib/desk_api/resource.rb | DeskApi.Resource.get_embedded_resource | def get_embedded_resource(method)
return @_embedded[method] if @_embedded.key?(method)
@_embedded[method] = @_definition['_embedded'][method]
if @_embedded[method].kind_of?(Array)
@_embedded[method].tap do |ary|
ary.map!{ |definition| new_resource(definition, true) } unless ary.first.kind_of?(self.class)
end
else
@_embedded[method] = new_resource(@_embedded[method], true)
end
end | ruby | def get_embedded_resource(method)
return @_embedded[method] if @_embedded.key?(method)
@_embedded[method] = @_definition['_embedded'][method]
if @_embedded[method].kind_of?(Array)
@_embedded[method].tap do |ary|
ary.map!{ |definition| new_resource(definition, true) } unless ary.first.kind_of?(self.class)
end
else
@_embedded[method] = new_resource(@_embedded[method], true)
end
end | [
"def",
"get_embedded_resource",
"(",
"method",
")",
"return",
"@_embedded",
"[",
"method",
"]",
"if",
"@_embedded",
".",
"key?",
"(",
"method",
")",
"@_embedded",
"[",
"method",
"]",
"=",
"@_definition",
"[",
"'_embedded'",
"]",
"[",
"method",
"]",
"if",
"@_embedded",
"[",
"method",
"]",
".",
"kind_of?",
"(",
"Array",
")",
"@_embedded",
"[",
"method",
"]",
".",
"tap",
"do",
"|",
"ary",
"|",
"ary",
".",
"map!",
"{",
"|",
"definition",
"|",
"new_resource",
"(",
"definition",
",",
"true",
")",
"}",
"unless",
"ary",
".",
"first",
".",
"kind_of?",
"(",
"self",
".",
"class",
")",
"end",
"else",
"@_embedded",
"[",
"method",
"]",
"=",
"new_resource",
"(",
"@_embedded",
"[",
"method",
"]",
",",
"true",
")",
"end",
"end"
] | Returns the embedded resource
@param method [String/Symbol]
@return [DeskApi::Resource] | [
"Returns",
"the",
"embedded",
"resource"
] | af1080459215d4cb769e785656bcee1d56696f95 | https://github.com/forcedotcom/salesforce-deskcom-api/blob/af1080459215d4cb769e785656bcee1d56696f95/lib/desk_api/resource.rb#L233-L244 |
2,857 | forcedotcom/salesforce-deskcom-api | lib/desk_api/resource.rb | DeskApi.Resource.get_linked_resource | def get_linked_resource(method)
return @_links[method] if @_links.key?(method)
@_links[method] = @_definition['_links'][method]
if @_links[method] and not @_links[method].kind_of?(self.class)
@_links[method] = new_resource(self.class.build_self_link(@_links[method]))
end
end | ruby | def get_linked_resource(method)
return @_links[method] if @_links.key?(method)
@_links[method] = @_definition['_links'][method]
if @_links[method] and not @_links[method].kind_of?(self.class)
@_links[method] = new_resource(self.class.build_self_link(@_links[method]))
end
end | [
"def",
"get_linked_resource",
"(",
"method",
")",
"return",
"@_links",
"[",
"method",
"]",
"if",
"@_links",
".",
"key?",
"(",
"method",
")",
"@_links",
"[",
"method",
"]",
"=",
"@_definition",
"[",
"'_links'",
"]",
"[",
"method",
"]",
"if",
"@_links",
"[",
"method",
"]",
"and",
"not",
"@_links",
"[",
"method",
"]",
".",
"kind_of?",
"(",
"self",
".",
"class",
")",
"@_links",
"[",
"method",
"]",
"=",
"new_resource",
"(",
"self",
".",
"class",
".",
"build_self_link",
"(",
"@_links",
"[",
"method",
"]",
")",
")",
"end",
"end"
] | Returns the linked resource
@param method [String/Symbol]
@return [DeskApi::Resource] | [
"Returns",
"the",
"linked",
"resource"
] | af1080459215d4cb769e785656bcee1d56696f95 | https://github.com/forcedotcom/salesforce-deskcom-api/blob/af1080459215d4cb769e785656bcee1d56696f95/lib/desk_api/resource.rb#L250-L257 |
2,858 | forcedotcom/salesforce-deskcom-api | lib/desk_api/resource.rb | DeskApi.Resource.method_missing | def method_missing(method, *args, &block)
load
meth = method.to_s
return get_embedded_resource(meth) if is_embedded?(meth)
return get_linked_resource(meth) if is_link?(meth)
return @_changed[meth[0...-1]] = args.first if meth.end_with?('=') and is_field?(meth[0...-1])
return get_field_value(meth) if is_field?(meth)
super(method, *args, &block)
end | ruby | def method_missing(method, *args, &block)
load
meth = method.to_s
return get_embedded_resource(meth) if is_embedded?(meth)
return get_linked_resource(meth) if is_link?(meth)
return @_changed[meth[0...-1]] = args.first if meth.end_with?('=') and is_field?(meth[0...-1])
return get_field_value(meth) if is_field?(meth)
super(method, *args, &block)
end | [
"def",
"method_missing",
"(",
"method",
",",
"*",
"args",
",",
"&",
"block",
")",
"load",
"meth",
"=",
"method",
".",
"to_s",
"return",
"get_embedded_resource",
"(",
"meth",
")",
"if",
"is_embedded?",
"(",
"meth",
")",
"return",
"get_linked_resource",
"(",
"meth",
")",
"if",
"is_link?",
"(",
"meth",
")",
"return",
"@_changed",
"[",
"meth",
"[",
"0",
"...",
"-",
"1",
"]",
"]",
"=",
"args",
".",
"first",
"if",
"meth",
".",
"end_with?",
"(",
"'='",
")",
"and",
"is_field?",
"(",
"meth",
"[",
"0",
"...",
"-",
"1",
"]",
")",
"return",
"get_field_value",
"(",
"meth",
")",
"if",
"is_field?",
"(",
"meth",
")",
"super",
"(",
"method",
",",
"args",
",",
"block",
")",
"end"
] | Returns the requested embedded resource, linked resource or field value,
also allows to set a new field value
@param method [String/Symbol]
@param args [Mixed]
@param block [Proc]
@return [Mixed] | [
"Returns",
"the",
"requested",
"embedded",
"resource",
"linked",
"resource",
"or",
"field",
"value",
"also",
"allows",
"to",
"set",
"a",
"new",
"field",
"value"
] | af1080459215d4cb769e785656bcee1d56696f95 | https://github.com/forcedotcom/salesforce-deskcom-api/blob/af1080459215d4cb769e785656bcee1d56696f95/lib/desk_api/resource.rb#L275-L286 |
2,859 | dagrz/nba_stats | lib/nba_stats/stats/league_dash_player_stats.rb | NbaStats.LeagueDashPlayerStats.league_dash_player_stats | def league_dash_player_stats(
season,
measure_type=NbaStats::Constants::MEASURE_TYPE_BASE,
per_mode=NbaStats::Constants::PER_MODE_GAME,
plus_minus=NbaStats::Constants::NO,
pace_adjust=NbaStats::Constants::NO,
rank=NbaStats::Constants::NO,
outcome=nil,
location=nil,
month=0,
season_segment=nil,
date_from=nil,
date_to=nil,
opponent_team_id=0,
vs_conference=nil,
vs_division=nil,
game_segment=nil,
period=0,
last_n_games=0,
game_scope=nil,
player_experience=nil,
player_position=nil,
starter_bench=nil,
conf=NbaStats::Constants::CONF_BOTH,
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
unless date_from.nil?
date_from = date_from.strftime('%m-%d-%Y')
end
unless date_to.nil?
date_to = date_to.strftime('%m-%d-%Y')
end
NbaStats::Resources::LeagueDashPlayerStats.new(
get(LEAGUE_DASH_PLAYER_STATS_PATH, {
:Season => season,
:SeasonType => season_type,
:LeagueID => league_id,
:MeasureType => measure_type,
:PerMode => per_mode,
:PlusMinus => plus_minus,
:PaceAdjust => pace_adjust,
:Rank => rank,
:Outcome => outcome,
:Location => location,
:Month => month,
:SeasonSegment => season_segment,
:DateFrom => date_from,
:DateTo => date_to,
:OpponentTeamID => opponent_team_id,
:VsConference => vs_conference,
:VsDivision => vs_division,
:GameSegment => game_segment,
:Period => period,
:LastNGames => last_n_games,
:GameScope => game_scope,
:PlayerExperience => player_experience,
:PlayerPosition => player_position,
:StarterBench => starter_bench,
:Conf => conf
})
)
end | ruby | def league_dash_player_stats(
season,
measure_type=NbaStats::Constants::MEASURE_TYPE_BASE,
per_mode=NbaStats::Constants::PER_MODE_GAME,
plus_minus=NbaStats::Constants::NO,
pace_adjust=NbaStats::Constants::NO,
rank=NbaStats::Constants::NO,
outcome=nil,
location=nil,
month=0,
season_segment=nil,
date_from=nil,
date_to=nil,
opponent_team_id=0,
vs_conference=nil,
vs_division=nil,
game_segment=nil,
period=0,
last_n_games=0,
game_scope=nil,
player_experience=nil,
player_position=nil,
starter_bench=nil,
conf=NbaStats::Constants::CONF_BOTH,
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
unless date_from.nil?
date_from = date_from.strftime('%m-%d-%Y')
end
unless date_to.nil?
date_to = date_to.strftime('%m-%d-%Y')
end
NbaStats::Resources::LeagueDashPlayerStats.new(
get(LEAGUE_DASH_PLAYER_STATS_PATH, {
:Season => season,
:SeasonType => season_type,
:LeagueID => league_id,
:MeasureType => measure_type,
:PerMode => per_mode,
:PlusMinus => plus_minus,
:PaceAdjust => pace_adjust,
:Rank => rank,
:Outcome => outcome,
:Location => location,
:Month => month,
:SeasonSegment => season_segment,
:DateFrom => date_from,
:DateTo => date_to,
:OpponentTeamID => opponent_team_id,
:VsConference => vs_conference,
:VsDivision => vs_division,
:GameSegment => game_segment,
:Period => period,
:LastNGames => last_n_games,
:GameScope => game_scope,
:PlayerExperience => player_experience,
:PlayerPosition => player_position,
:StarterBench => starter_bench,
:Conf => conf
})
)
end | [
"def",
"league_dash_player_stats",
"(",
"season",
",",
"measure_type",
"=",
"NbaStats",
"::",
"Constants",
"::",
"MEASURE_TYPE_BASE",
",",
"per_mode",
"=",
"NbaStats",
"::",
"Constants",
"::",
"PER_MODE_GAME",
",",
"plus_minus",
"=",
"NbaStats",
"::",
"Constants",
"::",
"NO",
",",
"pace_adjust",
"=",
"NbaStats",
"::",
"Constants",
"::",
"NO",
",",
"rank",
"=",
"NbaStats",
"::",
"Constants",
"::",
"NO",
",",
"outcome",
"=",
"nil",
",",
"location",
"=",
"nil",
",",
"month",
"=",
"0",
",",
"season_segment",
"=",
"nil",
",",
"date_from",
"=",
"nil",
",",
"date_to",
"=",
"nil",
",",
"opponent_team_id",
"=",
"0",
",",
"vs_conference",
"=",
"nil",
",",
"vs_division",
"=",
"nil",
",",
"game_segment",
"=",
"nil",
",",
"period",
"=",
"0",
",",
"last_n_games",
"=",
"0",
",",
"game_scope",
"=",
"nil",
",",
"player_experience",
"=",
"nil",
",",
"player_position",
"=",
"nil",
",",
"starter_bench",
"=",
"nil",
",",
"conf",
"=",
"NbaStats",
"::",
"Constants",
"::",
"CONF_BOTH",
",",
"season_type",
"=",
"NbaStats",
"::",
"Constants",
"::",
"SEASON_TYPE_REGULAR",
",",
"league_id",
"=",
"NbaStats",
"::",
"Constants",
"::",
"LEAGUE_ID_NBA",
")",
"unless",
"date_from",
".",
"nil?",
"date_from",
"=",
"date_from",
".",
"strftime",
"(",
"'%m-%d-%Y'",
")",
"end",
"unless",
"date_to",
".",
"nil?",
"date_to",
"=",
"date_to",
".",
"strftime",
"(",
"'%m-%d-%Y'",
")",
"end",
"NbaStats",
"::",
"Resources",
"::",
"LeagueDashPlayerStats",
".",
"new",
"(",
"get",
"(",
"LEAGUE_DASH_PLAYER_STATS_PATH",
",",
"{",
":Season",
"=>",
"season",
",",
":SeasonType",
"=>",
"season_type",
",",
":LeagueID",
"=>",
"league_id",
",",
":MeasureType",
"=>",
"measure_type",
",",
":PerMode",
"=>",
"per_mode",
",",
":PlusMinus",
"=>",
"plus_minus",
",",
":PaceAdjust",
"=>",
"pace_adjust",
",",
":Rank",
"=>",
"rank",
",",
":Outcome",
"=>",
"outcome",
",",
":Location",
"=>",
"location",
",",
":Month",
"=>",
"month",
",",
":SeasonSegment",
"=>",
"season_segment",
",",
":DateFrom",
"=>",
"date_from",
",",
":DateTo",
"=>",
"date_to",
",",
":OpponentTeamID",
"=>",
"opponent_team_id",
",",
":VsConference",
"=>",
"vs_conference",
",",
":VsDivision",
"=>",
"vs_division",
",",
":GameSegment",
"=>",
"game_segment",
",",
":Period",
"=>",
"period",
",",
":LastNGames",
"=>",
"last_n_games",
",",
":GameScope",
"=>",
"game_scope",
",",
":PlayerExperience",
"=>",
"player_experience",
",",
":PlayerPosition",
"=>",
"player_position",
",",
":StarterBench",
"=>",
"starter_bench",
",",
":Conf",
"=>",
"conf",
"}",
")",
")",
"end"
] | Calls the leaguedashplayerstats API and returns a LeagueDashPlayerStats resource.
@param season [String]
@param measure_type [String]
@param per_mode [String]
@param plus_minus [String]
@param pace_adjust [String]
@param rank [String]
@param outcome [String]
@param location [String]
@param month [Integer]
@param season_segment [xxxxxxxxxx]
@param date_from [Date]
@param date_to [Date]
@param opponent_team_id [Integer]
@param vs_conference [String]
@param vs_division [String]
@param game_segment [String]
@param period [Integer]
@param last_n_games [Integer]
@param game_scope [String]
@param player_experience [String]
@param player_position [String]
@param starter_bench [String]
@param conf [String]
@param season_type [String]
@param league_id [String]
@return [NbaStats::Resources::LeagueDashPlayerStats] | [
"Calls",
"the",
"leaguedashplayerstats",
"API",
"and",
"returns",
"a",
"LeagueDashPlayerStats",
"resource",
"."
] | d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa | https://github.com/dagrz/nba_stats/blob/d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa/lib/nba_stats/stats/league_dash_player_stats.rb#L38-L100 |
2,860 | dagrz/nba_stats | lib/nba_stats/stats/box_score.rb | NbaStats.BoxScore.box_score | def box_score(
game_id,
range_type=0,
start_period=0,
end_period=0,
start_range=0,
end_range=0
)
NbaStats::Resources::BoxScore.new(
get(BOX_SCORE_PATH, {
:GameID => game_id,
:RangeType => range_type,
:StartPeriod => start_period,
:EndPeriod => end_period,
:StartRange => start_range,
:EndRange => end_range
})
)
end | ruby | def box_score(
game_id,
range_type=0,
start_period=0,
end_period=0,
start_range=0,
end_range=0
)
NbaStats::Resources::BoxScore.new(
get(BOX_SCORE_PATH, {
:GameID => game_id,
:RangeType => range_type,
:StartPeriod => start_period,
:EndPeriod => end_period,
:StartRange => start_range,
:EndRange => end_range
})
)
end | [
"def",
"box_score",
"(",
"game_id",
",",
"range_type",
"=",
"0",
",",
"start_period",
"=",
"0",
",",
"end_period",
"=",
"0",
",",
"start_range",
"=",
"0",
",",
"end_range",
"=",
"0",
")",
"NbaStats",
"::",
"Resources",
"::",
"BoxScore",
".",
"new",
"(",
"get",
"(",
"BOX_SCORE_PATH",
",",
"{",
":GameID",
"=>",
"game_id",
",",
":RangeType",
"=>",
"range_type",
",",
":StartPeriod",
"=>",
"start_period",
",",
":EndPeriod",
"=>",
"end_period",
",",
":StartRange",
"=>",
"start_range",
",",
":EndRange",
"=>",
"end_range",
"}",
")",
")",
"end"
] | Calls the boxscore API and returns a BoxScore resource.
@param game_id [String]
@param range_type [Integer]
@param start_period [Integer]
@param end_period [Integer]
@param start_range [Integer]
@param end_range [Integer]
@return [NbaStats::Resources::BoxScore] | [
"Calls",
"the",
"boxscore",
"API",
"and",
"returns",
"a",
"BoxScore",
"resource",
"."
] | d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa | https://github.com/dagrz/nba_stats/blob/d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa/lib/nba_stats/stats/box_score.rb#L20-L38 |
2,861 | kolorahl/rarbac | app/helpers/rarbac/user_helper.rb | Rarbac.UserHelper.has_roles? | def has_roles?(*args)
throw Exception.new("Must supply at least one role.") if args.empty?
roles.where(name: args).count == args.count
end | ruby | def has_roles?(*args)
throw Exception.new("Must supply at least one role.") if args.empty?
roles.where(name: args).count == args.count
end | [
"def",
"has_roles?",
"(",
"*",
"args",
")",
"throw",
"Exception",
".",
"new",
"(",
"\"Must supply at least one role.\"",
")",
"if",
"args",
".",
"empty?",
"roles",
".",
"where",
"(",
"name",
":",
"args",
")",
".",
"count",
"==",
"args",
".",
"count",
"end"
] | Determines if the user has all of the given roles linked to it.
@param [String] args an argument list of one or more roles to check for.
@return [true|false] true if the user is linked to all of the given roles. | [
"Determines",
"if",
"the",
"user",
"has",
"all",
"of",
"the",
"given",
"roles",
"linked",
"to",
"it",
"."
] | 9bb2654da1cec74766ae6a6aa5e46821bb478f47 | https://github.com/kolorahl/rarbac/blob/9bb2654da1cec74766ae6a6aa5e46821bb478f47/app/helpers/rarbac/user_helper.rb#L22-L25 |
2,862 | kolorahl/rarbac | app/helpers/rarbac/user_helper.rb | Rarbac.UserHelper.has_permission? | def has_permission?(action)
return true if Action.where(name: action).count == 0
actions.where(name: action).count > 0
end | ruby | def has_permission?(action)
return true if Action.where(name: action).count == 0
actions.where(name: action).count > 0
end | [
"def",
"has_permission?",
"(",
"action",
")",
"return",
"true",
"if",
"Action",
".",
"where",
"(",
"name",
":",
"action",
")",
".",
"count",
"==",
"0",
"actions",
".",
"where",
"(",
"name",
":",
"action",
")",
".",
"count",
">",
"0",
"end"
] | Determines if the user has permission to a given action. If the action
does not exist at all, it is assumed the action is publicly available.
@param [String] action name of the action to check permission for.
@return [true|false] true if the user has at least one role linked to it
with permission to the given action. | [
"Determines",
"if",
"the",
"user",
"has",
"permission",
"to",
"a",
"given",
"action",
".",
"If",
"the",
"action",
"does",
"not",
"exist",
"at",
"all",
"it",
"is",
"assumed",
"the",
"action",
"is",
"publicly",
"available",
"."
] | 9bb2654da1cec74766ae6a6aa5e46821bb478f47 | https://github.com/kolorahl/rarbac/blob/9bb2654da1cec74766ae6a6aa5e46821bb478f47/app/helpers/rarbac/user_helper.rb#L33-L36 |
2,863 | dagrz/nba_stats | lib/nba_stats/stats/scoreboard.rb | NbaStats.Scoreboard.scoreboard | def scoreboard(
game_date=Date.today,
day_offset=0,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::Scoreboard.new(
get(SCOREBOARD_PATH, {
:LeagueID => league_id,
:GameDate => game_date.strftime('%m-%d-%Y'),
:DayOffset => day_offset
})
)
end | ruby | def scoreboard(
game_date=Date.today,
day_offset=0,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::Scoreboard.new(
get(SCOREBOARD_PATH, {
:LeagueID => league_id,
:GameDate => game_date.strftime('%m-%d-%Y'),
:DayOffset => day_offset
})
)
end | [
"def",
"scoreboard",
"(",
"game_date",
"=",
"Date",
".",
"today",
",",
"day_offset",
"=",
"0",
",",
"league_id",
"=",
"NbaStats",
"::",
"Constants",
"::",
"LEAGUE_ID_NBA",
")",
"NbaStats",
"::",
"Resources",
"::",
"Scoreboard",
".",
"new",
"(",
"get",
"(",
"SCOREBOARD_PATH",
",",
"{",
":LeagueID",
"=>",
"league_id",
",",
":GameDate",
"=>",
"game_date",
".",
"strftime",
"(",
"'%m-%d-%Y'",
")",
",",
":DayOffset",
"=>",
"day_offset",
"}",
")",
")",
"end"
] | Calls the scoreboard API and returns a Scoreboard resource.
@param game_date [Date]
@param day_offset [Integer]
@param league_id [String]
@return [NbaStats::Resources::Scoreboard] | [
"Calls",
"the",
"scoreboard",
"API",
"and",
"returns",
"a",
"Scoreboard",
"resource",
"."
] | d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa | https://github.com/dagrz/nba_stats/blob/d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa/lib/nba_stats/stats/scoreboard.rb#L17-L29 |
2,864 | kudelabs/ad_man | app/helpers/ad_man/application_helper.rb | AdMan.ApplicationHelper.get_keyword_from_url | def get_keyword_from_url
if request.env["REQUEST_PATH"]
req_url = request.env["REQUEST_PATH"].split("/")
keyword_names = Keyword.all.map(&:name)
keyword = req_url & keyword_names
end
end | ruby | def get_keyword_from_url
if request.env["REQUEST_PATH"]
req_url = request.env["REQUEST_PATH"].split("/")
keyword_names = Keyword.all.map(&:name)
keyword = req_url & keyword_names
end
end | [
"def",
"get_keyword_from_url",
"if",
"request",
".",
"env",
"[",
"\"REQUEST_PATH\"",
"]",
"req_url",
"=",
"request",
".",
"env",
"[",
"\"REQUEST_PATH\"",
"]",
".",
"split",
"(",
"\"/\"",
")",
"keyword_names",
"=",
"Keyword",
".",
"all",
".",
"map",
"(",
":name",
")",
"keyword",
"=",
"req_url",
"&",
"keyword_names",
"end",
"end"
] | grab the keyword form request url | [
"grab",
"the",
"keyword",
"form",
"request",
"url"
] | 9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4 | https://github.com/kudelabs/ad_man/blob/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/app/helpers/ad_man/application_helper.rb#L20-L26 |
2,865 | weltschmerz1/entangled | lib/entangled/helpers.rb | Entangled.Helpers.redis | def redis
if defined?($redis) && $redis
Redis.new($redis.client.options)
elsif defined?(REDIS) && REDIS
Redis.new(REDIS.client.options)
else
Redis.new
end
end | ruby | def redis
if defined?($redis) && $redis
Redis.new($redis.client.options)
elsif defined?(REDIS) && REDIS
Redis.new(REDIS.client.options)
else
Redis.new
end
end | [
"def",
"redis",
"if",
"defined?",
"(",
"$redis",
")",
"&&",
"$redis",
"Redis",
".",
"new",
"(",
"$redis",
".",
"client",
".",
"options",
")",
"elsif",
"defined?",
"(",
"REDIS",
")",
"&&",
"REDIS",
"Redis",
".",
"new",
"(",
"REDIS",
".",
"client",
".",
"options",
")",
"else",
"Redis",
".",
"new",
"end",
"end"
] | Get Redis that user might be using or instantiate
a new one | [
"Get",
"Redis",
"that",
"user",
"might",
"be",
"using",
"or",
"instantiate",
"a",
"new",
"one"
] | 2a8596c669785ce9b367379b8b5a63e13b0afc46 | https://github.com/weltschmerz1/entangled/blob/2a8596c669785ce9b367379b8b5a63e13b0afc46/lib/entangled/helpers.rb#L5-L13 |
2,866 | dagrz/nba_stats | lib/nba_stats/stats/draft_combine_drill_results.rb | NbaStats.DraftCombineDrillResults.draft_combine_drill_results | def draft_combine_drill_results(
season_year,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::DraftCombineDrillResults.new(
get(DRAFT_COMBINE_DRILL_RESULTS_PATH, {
:LeagueID => league_id,
:SeasonYear => season_year
})
)
end | ruby | def draft_combine_drill_results(
season_year,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::DraftCombineDrillResults.new(
get(DRAFT_COMBINE_DRILL_RESULTS_PATH, {
:LeagueID => league_id,
:SeasonYear => season_year
})
)
end | [
"def",
"draft_combine_drill_results",
"(",
"season_year",
",",
"league_id",
"=",
"NbaStats",
"::",
"Constants",
"::",
"LEAGUE_ID_NBA",
")",
"NbaStats",
"::",
"Resources",
"::",
"DraftCombineDrillResults",
".",
"new",
"(",
"get",
"(",
"DRAFT_COMBINE_DRILL_RESULTS_PATH",
",",
"{",
":LeagueID",
"=>",
"league_id",
",",
":SeasonYear",
"=>",
"season_year",
"}",
")",
")",
"end"
] | Calls the draftcombinedrillresults API and returns a DraftCombineDrillResults resource.
@param season_year [String]
@param league_id [String]
@return [NbaStats::Resources::DraftCombineDrillResults] | [
"Calls",
"the",
"draftcombinedrillresults",
"API",
"and",
"returns",
"a",
"DraftCombineDrillResults",
"resource",
"."
] | d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa | https://github.com/dagrz/nba_stats/blob/d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa/lib/nba_stats/stats/draft_combine_drill_results.rb#L15-L25 |
2,867 | dagrz/nba_stats | lib/nba_stats/stats/play_by_play.rb | NbaStats.PlayByPlay.play_by_play | def play_by_play(
game_id,
start_period=0,
end_period=0
)
NbaStats::Resources::PlayByPlay.new(
get(PLAY_BY_PLAY_PATH, {
:GameID => game_id,
:StartPeriod => start_period,
:EndPeriod => end_period
})
)
end | ruby | def play_by_play(
game_id,
start_period=0,
end_period=0
)
NbaStats::Resources::PlayByPlay.new(
get(PLAY_BY_PLAY_PATH, {
:GameID => game_id,
:StartPeriod => start_period,
:EndPeriod => end_period
})
)
end | [
"def",
"play_by_play",
"(",
"game_id",
",",
"start_period",
"=",
"0",
",",
"end_period",
"=",
"0",
")",
"NbaStats",
"::",
"Resources",
"::",
"PlayByPlay",
".",
"new",
"(",
"get",
"(",
"PLAY_BY_PLAY_PATH",
",",
"{",
":GameID",
"=>",
"game_id",
",",
":StartPeriod",
"=>",
"start_period",
",",
":EndPeriod",
"=>",
"end_period",
"}",
")",
")",
"end"
] | Calls the playbyplay API and returns a PlayByPlay resource.
@param game_id [String]
@param start_period [Integer]
@param end_period [Integer]
@return [NbaStats::Resources::PlayByPlay] | [
"Calls",
"the",
"playbyplay",
"API",
"and",
"returns",
"a",
"PlayByPlay",
"resource",
"."
] | d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa | https://github.com/dagrz/nba_stats/blob/d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa/lib/nba_stats/stats/play_by_play.rb#L16-L28 |
2,868 | mat813/rb-kqueue | lib/rb-kqueue/watcher.rb | KQueue.Watcher.native | def native(flags)
native = Native::KEvent.new
native[:ident] = @ident
native[:filter] = Native::Flags.to_flag("EVFILT", @filter)
native[:flags] = Native::Flags.to_mask("EV", @flags | flags)
native[:fflags] = Native::Flags.to_mask("NOTE_#{@filter.to_s.upcase}", @fflags)
native[:data] = @data if @data
native
end | ruby | def native(flags)
native = Native::KEvent.new
native[:ident] = @ident
native[:filter] = Native::Flags.to_flag("EVFILT", @filter)
native[:flags] = Native::Flags.to_mask("EV", @flags | flags)
native[:fflags] = Native::Flags.to_mask("NOTE_#{@filter.to_s.upcase}", @fflags)
native[:data] = @data if @data
native
end | [
"def",
"native",
"(",
"flags",
")",
"native",
"=",
"Native",
"::",
"KEvent",
".",
"new",
"native",
"[",
":ident",
"]",
"=",
"@ident",
"native",
"[",
":filter",
"]",
"=",
"Native",
"::",
"Flags",
".",
"to_flag",
"(",
"\"EVFILT\"",
",",
"@filter",
")",
"native",
"[",
":flags",
"]",
"=",
"Native",
"::",
"Flags",
".",
"to_mask",
"(",
"\"EV\"",
",",
"@flags",
"|",
"flags",
")",
"native",
"[",
":fflags",
"]",
"=",
"Native",
"::",
"Flags",
".",
"to_mask",
"(",
"\"NOTE_#{@filter.to_s.upcase}\"",
",",
"@fflags",
")",
"native",
"[",
":data",
"]",
"=",
"@data",
"if",
"@data",
"native",
"end"
] | Returns a C struct corresponding to this watcher.
@param flags [Array<Symbol>] Flags for the C struct's `flags` field,
in addition to the `@flags` var.
@return [Native::KEvent] | [
"Returns",
"a",
"C",
"struct",
"corresponding",
"to",
"this",
"watcher",
"."
] | f11c1a8552812bc0b635ef9751d6dc61d4beaa67 | https://github.com/mat813/rb-kqueue/blob/f11c1a8552812bc0b635ef9751d6dc61d4beaa67/lib/rb-kqueue/watcher.rb#L100-L108 |
2,869 | mat813/rb-kqueue | lib/rb-kqueue/watcher.rb | KQueue.Watcher.kevent! | def kevent!(*flags)
if Native.kevent(@queue.fd, native(flags).pointer, 1, nil, 0, nil) < 0
KQueue.handle_error
end
end | ruby | def kevent!(*flags)
if Native.kevent(@queue.fd, native(flags).pointer, 1, nil, 0, nil) < 0
KQueue.handle_error
end
end | [
"def",
"kevent!",
"(",
"*",
"flags",
")",
"if",
"Native",
".",
"kevent",
"(",
"@queue",
".",
"fd",
",",
"native",
"(",
"flags",
")",
".",
"pointer",
",",
"1",
",",
"nil",
",",
"0",
",",
"nil",
")",
"<",
"0",
"KQueue",
".",
"handle_error",
"end",
"end"
] | Runs the `kevent` C call with this Watcher's kevent struct as input.
This effectively means telling kqueue to perform some action
with this Watcher as an argument.
@param flags [Array<Symbol>] Flags specifying the action to perform
as well as any additional flags.
@return [void]
@raise [SystemCallError] If something goes wrong when performing the C call. | [
"Runs",
"the",
"kevent",
"C",
"call",
"with",
"this",
"Watcher",
"s",
"kevent",
"struct",
"as",
"input",
".",
"This",
"effectively",
"means",
"telling",
"kqueue",
"to",
"perform",
"some",
"action",
"with",
"this",
"Watcher",
"as",
"an",
"argument",
"."
] | f11c1a8552812bc0b635ef9751d6dc61d4beaa67 | https://github.com/mat813/rb-kqueue/blob/f11c1a8552812bc0b635ef9751d6dc61d4beaa67/lib/rb-kqueue/watcher.rb#L118-L122 |
2,870 | dagrz/nba_stats | lib/nba_stats/stats/draft_combine_non_stationary_shooting.rb | NbaStats.DraftCombineNonStationaryShooting.draft_combine_non_stationary_shooting | def draft_combine_non_stationary_shooting(
season_year,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::DraftCombineNonStationaryShooting.new(
get(DRAFT_COMBINE_NON_STATIONARY_SHOOTING_PATH, {
:LeagueID => league_id,
:SeasonYear => season_year
})
)
end | ruby | def draft_combine_non_stationary_shooting(
season_year,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::DraftCombineNonStationaryShooting.new(
get(DRAFT_COMBINE_NON_STATIONARY_SHOOTING_PATH, {
:LeagueID => league_id,
:SeasonYear => season_year
})
)
end | [
"def",
"draft_combine_non_stationary_shooting",
"(",
"season_year",
",",
"league_id",
"=",
"NbaStats",
"::",
"Constants",
"::",
"LEAGUE_ID_NBA",
")",
"NbaStats",
"::",
"Resources",
"::",
"DraftCombineNonStationaryShooting",
".",
"new",
"(",
"get",
"(",
"DRAFT_COMBINE_NON_STATIONARY_SHOOTING_PATH",
",",
"{",
":LeagueID",
"=>",
"league_id",
",",
":SeasonYear",
"=>",
"season_year",
"}",
")",
")",
"end"
] | Calls the draftcombinenonstationaryshooting API and returns a DraftCombineNonStationaryShooting resource.
@param season_year [String]
@param league_id [String]
@return [NbaStats::Resources::DraftCombineNonStationaryShooting] | [
"Calls",
"the",
"draftcombinenonstationaryshooting",
"API",
"and",
"returns",
"a",
"DraftCombineNonStationaryShooting",
"resource",
"."
] | d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa | https://github.com/dagrz/nba_stats/blob/d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa/lib/nba_stats/stats/draft_combine_non_stationary_shooting.rb#L15-L25 |
2,871 | listia/walmart_open | lib/walmart_open/request.rb | WalmartOpen.Request.convert_param_keys | def convert_param_keys(underscored_params)
pairs = underscored_params.map do |key, value|
key = key.to_s.gsub(/_([a-z])/i) { $1.upcase }
[key, value]
end
Hash[pairs]
end | ruby | def convert_param_keys(underscored_params)
pairs = underscored_params.map do |key, value|
key = key.to_s.gsub(/_([a-z])/i) { $1.upcase }
[key, value]
end
Hash[pairs]
end | [
"def",
"convert_param_keys",
"(",
"underscored_params",
")",
"pairs",
"=",
"underscored_params",
".",
"map",
"do",
"|",
"key",
",",
"value",
"|",
"key",
"=",
"key",
".",
"to_s",
".",
"gsub",
"(",
"/",
"/i",
")",
"{",
"$1",
".",
"upcase",
"}",
"[",
"key",
",",
"value",
"]",
"end",
"Hash",
"[",
"pairs",
"]",
"end"
] | Converts foo_bar_param to fooBarParam. | [
"Converts",
"foo_bar_param",
"to",
"fooBarParam",
"."
] | f563da4ae7b620d7c3c52ebafb6af50a77d614b2 | https://github.com/listia/walmart_open/blob/f563da4ae7b620d7c3c52ebafb6af50a77d614b2/lib/walmart_open/request.rb#L71-L77 |
2,872 | dagrz/nba_stats | lib/nba_stats/stats/box_score_misc.rb | NbaStats.BoxScoreMisc.box_score_misc | def box_score_misc(
game_id,
range_type=0,
start_period=0,
end_period=0,
start_range=0,
end_range=0
)
NbaStats::Resources::BoxScoreMisc.new(
get(BOX_SCORE_MISC_PATH, {
:GameID => game_id,
:RangeType => range_type,
:StartPeriod => start_period,
:EndPeriod => end_period,
:StartRange => start_range,
:EndRange => end_range
})
)
end | ruby | def box_score_misc(
game_id,
range_type=0,
start_period=0,
end_period=0,
start_range=0,
end_range=0
)
NbaStats::Resources::BoxScoreMisc.new(
get(BOX_SCORE_MISC_PATH, {
:GameID => game_id,
:RangeType => range_type,
:StartPeriod => start_period,
:EndPeriod => end_period,
:StartRange => start_range,
:EndRange => end_range
})
)
end | [
"def",
"box_score_misc",
"(",
"game_id",
",",
"range_type",
"=",
"0",
",",
"start_period",
"=",
"0",
",",
"end_period",
"=",
"0",
",",
"start_range",
"=",
"0",
",",
"end_range",
"=",
"0",
")",
"NbaStats",
"::",
"Resources",
"::",
"BoxScoreMisc",
".",
"new",
"(",
"get",
"(",
"BOX_SCORE_MISC_PATH",
",",
"{",
":GameID",
"=>",
"game_id",
",",
":RangeType",
"=>",
"range_type",
",",
":StartPeriod",
"=>",
"start_period",
",",
":EndPeriod",
"=>",
"end_period",
",",
":StartRange",
"=>",
"start_range",
",",
":EndRange",
"=>",
"end_range",
"}",
")",
")",
"end"
] | Calls the boxscoremisc API and returns a BoxScoreMisc resource.
@param game_id [String]
@param range_type [Integer]
@param start_period [Integer]
@param end_period [Integer]
@param start_range [Integer]
@param end_range [Integer]
@return [NbaStats::Resources::BoxScoreMisc] | [
"Calls",
"the",
"boxscoremisc",
"API",
"and",
"returns",
"a",
"BoxScoreMisc",
"resource",
"."
] | d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa | https://github.com/dagrz/nba_stats/blob/d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa/lib/nba_stats/stats/box_score_misc.rb#L19-L37 |
2,873 | dagrz/nba_stats | lib/nba_stats/stats/league_dash_team_stats.rb | NbaStats.LeagueDashTeamStats.league_dash_team_stats | def league_dash_team_stats(
season,
date_from=nil,
date_to=nil,
game_scope=nil,
game_segment=nil,
last_n_games=0,
location=nil,
measure_type=NbaStats::Constants::MEASURE_TYPE_BASE,
month=0,
opponent_team_id=0,
outcome=nil,
pace_adjust=NbaStats::Constants::NO,
per_mode=NbaStats::Constants::PER_MODE_GAME,
period=0,
player_experience=nil,
player_position=nil,
plus_minus=NbaStats::Constants::NO,
rank=NbaStats::Constants::NO,
season_segment=nil,
starter_bench=nil,
vs_conference=nil,
vs_division=nil,
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::LeagueDashTeamStats.new(
get(LEAGUE_DASH_TEAM_STATS_PATH, {
:DateFrom => date_from,
:DateTo => date_to,
:GameScope => game_scope,
:GameSegment => game_segment,
:LastNGames => last_n_games,
:LeagueID => league_id,
:Location => location,
:MeasureType => measure_type,
:Month => month,
:OpponentTeamID => opponent_team_id,
:Outcome => outcome,
:PaceAdjust => pace_adjust,
:PerMode => per_mode,
:Period => period,
:PlayerExperience => player_experience,
:PlayerPosition => player_position,
:PlusMinus => plus_minus,
:Rank => rank,
:Season => season,
:SeasonSegment => season_segment,
:SeasonType => season_type,
:StarterBench => starter_bench,
:VsConference => vs_conference,
:VsDivision => vs_division
})
)
end | ruby | def league_dash_team_stats(
season,
date_from=nil,
date_to=nil,
game_scope=nil,
game_segment=nil,
last_n_games=0,
location=nil,
measure_type=NbaStats::Constants::MEASURE_TYPE_BASE,
month=0,
opponent_team_id=0,
outcome=nil,
pace_adjust=NbaStats::Constants::NO,
per_mode=NbaStats::Constants::PER_MODE_GAME,
period=0,
player_experience=nil,
player_position=nil,
plus_minus=NbaStats::Constants::NO,
rank=NbaStats::Constants::NO,
season_segment=nil,
starter_bench=nil,
vs_conference=nil,
vs_division=nil,
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::LeagueDashTeamStats.new(
get(LEAGUE_DASH_TEAM_STATS_PATH, {
:DateFrom => date_from,
:DateTo => date_to,
:GameScope => game_scope,
:GameSegment => game_segment,
:LastNGames => last_n_games,
:LeagueID => league_id,
:Location => location,
:MeasureType => measure_type,
:Month => month,
:OpponentTeamID => opponent_team_id,
:Outcome => outcome,
:PaceAdjust => pace_adjust,
:PerMode => per_mode,
:Period => period,
:PlayerExperience => player_experience,
:PlayerPosition => player_position,
:PlusMinus => plus_minus,
:Rank => rank,
:Season => season,
:SeasonSegment => season_segment,
:SeasonType => season_type,
:StarterBench => starter_bench,
:VsConference => vs_conference,
:VsDivision => vs_division
})
)
end | [
"def",
"league_dash_team_stats",
"(",
"season",
",",
"date_from",
"=",
"nil",
",",
"date_to",
"=",
"nil",
",",
"game_scope",
"=",
"nil",
",",
"game_segment",
"=",
"nil",
",",
"last_n_games",
"=",
"0",
",",
"location",
"=",
"nil",
",",
"measure_type",
"=",
"NbaStats",
"::",
"Constants",
"::",
"MEASURE_TYPE_BASE",
",",
"month",
"=",
"0",
",",
"opponent_team_id",
"=",
"0",
",",
"outcome",
"=",
"nil",
",",
"pace_adjust",
"=",
"NbaStats",
"::",
"Constants",
"::",
"NO",
",",
"per_mode",
"=",
"NbaStats",
"::",
"Constants",
"::",
"PER_MODE_GAME",
",",
"period",
"=",
"0",
",",
"player_experience",
"=",
"nil",
",",
"player_position",
"=",
"nil",
",",
"plus_minus",
"=",
"NbaStats",
"::",
"Constants",
"::",
"NO",
",",
"rank",
"=",
"NbaStats",
"::",
"Constants",
"::",
"NO",
",",
"season_segment",
"=",
"nil",
",",
"starter_bench",
"=",
"nil",
",",
"vs_conference",
"=",
"nil",
",",
"vs_division",
"=",
"nil",
",",
"season_type",
"=",
"NbaStats",
"::",
"Constants",
"::",
"SEASON_TYPE_REGULAR",
",",
"league_id",
"=",
"NbaStats",
"::",
"Constants",
"::",
"LEAGUE_ID_NBA",
")",
"NbaStats",
"::",
"Resources",
"::",
"LeagueDashTeamStats",
".",
"new",
"(",
"get",
"(",
"LEAGUE_DASH_TEAM_STATS_PATH",
",",
"{",
":DateFrom",
"=>",
"date_from",
",",
":DateTo",
"=>",
"date_to",
",",
":GameScope",
"=>",
"game_scope",
",",
":GameSegment",
"=>",
"game_segment",
",",
":LastNGames",
"=>",
"last_n_games",
",",
":LeagueID",
"=>",
"league_id",
",",
":Location",
"=>",
"location",
",",
":MeasureType",
"=>",
"measure_type",
",",
":Month",
"=>",
"month",
",",
":OpponentTeamID",
"=>",
"opponent_team_id",
",",
":Outcome",
"=>",
"outcome",
",",
":PaceAdjust",
"=>",
"pace_adjust",
",",
":PerMode",
"=>",
"per_mode",
",",
":Period",
"=>",
"period",
",",
":PlayerExperience",
"=>",
"player_experience",
",",
":PlayerPosition",
"=>",
"player_position",
",",
":PlusMinus",
"=>",
"plus_minus",
",",
":Rank",
"=>",
"rank",
",",
":Season",
"=>",
"season",
",",
":SeasonSegment",
"=>",
"season_segment",
",",
":SeasonType",
"=>",
"season_type",
",",
":StarterBench",
"=>",
"starter_bench",
",",
":VsConference",
"=>",
"vs_conference",
",",
":VsDivision",
"=>",
"vs_division",
"}",
")",
")",
"end"
] | Calls the leaguedashteamstats API and returns a LeagueDashTeamStats resource.
@param date_from [Date]
@param date_to [Date]
@param game_scope [String]
@param game_segment [String]
@param last_n_games [Integer]
@param league_id [String]
@param location [String]
@param measure_type [String]
@param month [Integer]
@param opponent_team_id [String]
@param outcome [String]
@param pace_adjust [String]
@param per_mode [String]
@param period [Integer]
@param player_experience [String]
@param player_position [String]
@param plus_minus [String]
@param rank [String]
@param season [String]
@param season_segment [String]
@param season_type [String]
@param starter_bench [String]
@param vs_conference [String]
@param vs_division [String]
@return [NbaStats::Resources::LeagueDashTeamStats] | [
"Calls",
"the",
"leaguedashteamstats",
"API",
"and",
"returns",
"a",
"LeagueDashTeamStats",
"resource",
"."
] | d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa | https://github.com/dagrz/nba_stats/blob/d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa/lib/nba_stats/stats/league_dash_team_stats.rb#L37-L91 |
2,874 | dagrz/nba_stats | lib/nba_stats/stats/player_game_log.rb | NbaStats.PlayerGameLog.player_game_log | def player_game_log(
player_id,
season,
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::PlayerGameLog.new(
get(PLAYER_GAME_LOG_PATH, {
:Season => season,
:LeagueID => league_id,
:PlayerID => player_id,
:SeasonType => season_type
})
)
end | ruby | def player_game_log(
player_id,
season,
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::PlayerGameLog.new(
get(PLAYER_GAME_LOG_PATH, {
:Season => season,
:LeagueID => league_id,
:PlayerID => player_id,
:SeasonType => season_type
})
)
end | [
"def",
"player_game_log",
"(",
"player_id",
",",
"season",
",",
"season_type",
"=",
"NbaStats",
"::",
"Constants",
"::",
"SEASON_TYPE_REGULAR",
",",
"league_id",
"=",
"NbaStats",
"::",
"Constants",
"::",
"LEAGUE_ID_NBA",
")",
"NbaStats",
"::",
"Resources",
"::",
"PlayerGameLog",
".",
"new",
"(",
"get",
"(",
"PLAYER_GAME_LOG_PATH",
",",
"{",
":Season",
"=>",
"season",
",",
":LeagueID",
"=>",
"league_id",
",",
":PlayerID",
"=>",
"player_id",
",",
":SeasonType",
"=>",
"season_type",
"}",
")",
")",
"end"
] | Calls the playergamelog API and returns a PlayerGameLog resource.
@param league_id [String]
@param player_id [Integer]
@param season [String]
@param season_type [String]
@return [NbaStats::Resources::PlayerGameLog] | [
"Calls",
"the",
"playergamelog",
"API",
"and",
"returns",
"a",
"PlayerGameLog",
"resource",
"."
] | d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa | https://github.com/dagrz/nba_stats/blob/d6fe6cf81f74a2ce7a054aeec5e9db59a6ec42aa/lib/nba_stats/stats/player_game_log.rb#L17-L31 |
2,875 | dcuddeback/rspec-tag_matchers | lib/rspec/tag_matchers/multiple_input_matcher.rb | RSpec::TagMatchers.MultipleInputMatcher.matches? | def matches?(rendered)
@rendered = rendered
@failures = matchers.reject do |matcher|
matcher.matches?(rendered)
end
@failures.empty?
end | ruby | def matches?(rendered)
@rendered = rendered
@failures = matchers.reject do |matcher|
matcher.matches?(rendered)
end
@failures.empty?
end | [
"def",
"matches?",
"(",
"rendered",
")",
"@rendered",
"=",
"rendered",
"@failures",
"=",
"matchers",
".",
"reject",
"do",
"|",
"matcher",
"|",
"matcher",
".",
"matches?",
"(",
"rendered",
")",
"end",
"@failures",
".",
"empty?",
"end"
] | Initializes a matcher that matches multiple input elements.
@param [Hash] components A hash of matchers. The keys should be the keys used in Rails'
multi-parameter assignment, e.g., <tt>"1i"</tt>, <tt>"2s"</tt>, etc,
and the values are the matchers that must be satisfied.
Tests whether the matcher matches the +rendered+ string. It delegates matching to its
matchers. It returns true if all of its matchers return true. It returns false if *any* of its
matchers return false.
@param [String] rendered A string of HTML or an Object whose +to_s+ method returns HTML.
(That includes Nokogiri classes.)
@return [Boolean] | [
"Initializes",
"a",
"matcher",
"that",
"matches",
"multiple",
"input",
"elements",
"."
] | 6396a833d99ea669699afb1b3dfc62c4512c8882 | https://github.com/dcuddeback/rspec-tag_matchers/blob/6396a833d99ea669699afb1b3dfc62c4512c8882/lib/rspec/tag_matchers/multiple_input_matcher.rb#L44-L51 |
2,876 | dcuddeback/rspec-tag_matchers | lib/rspec/tag_matchers/multiple_input_matcher.rb | RSpec::TagMatchers.MultipleInputMatcher.for | def for(*args)
@for = args.dup
@for.extend(DeepFlattening)
@for = @for.deep_flatten
@components.each do |index, matcher|
delegated_for(index, matcher, @for)
end
self
end | ruby | def for(*args)
@for = args.dup
@for.extend(DeepFlattening)
@for = @for.deep_flatten
@components.each do |index, matcher|
delegated_for(index, matcher, @for)
end
self
end | [
"def",
"for",
"(",
"*",
"args",
")",
"@for",
"=",
"args",
".",
"dup",
"@for",
".",
"extend",
"(",
"DeepFlattening",
")",
"@for",
"=",
"@for",
".",
"deep_flatten",
"@components",
".",
"each",
"do",
"|",
"index",
",",
"matcher",
"|",
"delegated_for",
"(",
"index",
",",
"matcher",
",",
"@for",
")",
"end",
"self",
"end"
] | Specifies the inputs' names with more accuracy than the default regular expressions. It
delegates to each matcher's +for+ method. But it first appends the matcher's key to the last
component of the input's name.
@example Input naming delegation
hour_matcher = HasSelect.new
minute_matcher = HasSelect.new
time_matcher = MultipleInputMatcher.new('4i' => hour_matcher, '5i' => minute_matcher)
time_matcher.for(:event => :start_time) # calls hour_matcher.for("event", "start_time(4i)")
# and minute_matcher.for("event", "start_time(5i)")
@param [Array, Hash] args A hierarchy of string that specify the attribute name.
@return [MultipleInputMatcher] self | [
"Specifies",
"the",
"inputs",
"names",
"with",
"more",
"accuracy",
"than",
"the",
"default",
"regular",
"expressions",
".",
"It",
"delegates",
"to",
"each",
"matcher",
"s",
"+",
"for",
"+",
"method",
".",
"But",
"it",
"first",
"appends",
"the",
"matcher",
"s",
"key",
"to",
"the",
"last",
"component",
"of",
"the",
"input",
"s",
"name",
"."
] | 6396a833d99ea669699afb1b3dfc62c4512c8882 | https://github.com/dcuddeback/rspec-tag_matchers/blob/6396a833d99ea669699afb1b3dfc62c4512c8882/lib/rspec/tag_matchers/multiple_input_matcher.rb#L68-L77 |
2,877 | dcuddeback/rspec-tag_matchers | lib/rspec/tag_matchers/multiple_input_matcher.rb | RSpec::TagMatchers.MultipleInputMatcher.delegated_for | def delegated_for(key, matcher, args)
args = args.dup
args[-1] = args[-1].to_s
args[-1] += "(#{key})"
matcher.for(*args)
end | ruby | def delegated_for(key, matcher, args)
args = args.dup
args[-1] = args[-1].to_s
args[-1] += "(#{key})"
matcher.for(*args)
end | [
"def",
"delegated_for",
"(",
"key",
",",
"matcher",
",",
"args",
")",
"args",
"=",
"args",
".",
"dup",
"args",
"[",
"-",
"1",
"]",
"=",
"args",
"[",
"-",
"1",
"]",
".",
"to_s",
"args",
"[",
"-",
"1",
"]",
"+=",
"\"(#{key})\"",
"matcher",
".",
"for",
"(",
"args",
")",
"end"
] | Set's +matcher+'s input name according to +args+ and +key+.
@param [String] key The matcher's key.
@param [HasInput] matcher The matcher.
@param [Arrah, Hash] args A hierarchy of names that would normally be passed to
{HasInput#for}. | [
"Set",
"s",
"+",
"matcher",
"+",
"s",
"input",
"name",
"according",
"to",
"+",
"args",
"+",
"and",
"+",
"key",
"+",
"."
] | 6396a833d99ea669699afb1b3dfc62c4512c8882 | https://github.com/dcuddeback/rspec-tag_matchers/blob/6396a833d99ea669699afb1b3dfc62c4512c8882/lib/rspec/tag_matchers/multiple_input_matcher.rb#L108-L113 |
2,878 | coderanger/dco | lib/dco/cli.rb | Dco.CLI.assert_repo! | def assert_repo!
begin
# Check if the repo fails to load at all.
repo
rescue Exception
raise Thor::Error.new("#{repo_path} does not appear to be a git repository")
end
unless repo.repo.writable?
raise Thor::Error.new("Git repository at #{repo.repo.path} is read-only")
end
end | ruby | def assert_repo!
begin
# Check if the repo fails to load at all.
repo
rescue Exception
raise Thor::Error.new("#{repo_path} does not appear to be a git repository")
end
unless repo.repo.writable?
raise Thor::Error.new("Git repository at #{repo.repo.path} is read-only")
end
end | [
"def",
"assert_repo!",
"begin",
"# Check if the repo fails to load at all.",
"repo",
"rescue",
"Exception",
"raise",
"Thor",
"::",
"Error",
".",
"new",
"(",
"\"#{repo_path} does not appear to be a git repository\"",
")",
"end",
"unless",
"repo",
".",
"repo",
".",
"writable?",
"raise",
"Thor",
"::",
"Error",
".",
"new",
"(",
"\"Git repository at #{repo.repo.path} is read-only\"",
")",
"end",
"end"
] | Check that we are in a git repo that we have write access to.
@api private
@return [void] | [
"Check",
"that",
"we",
"are",
"in",
"a",
"git",
"repo",
"that",
"we",
"have",
"write",
"access",
"to",
"."
] | a18d60bd9217bcf08f3c264080752f64d855ec39 | https://github.com/coderanger/dco/blob/a18d60bd9217bcf08f3c264080752f64d855ec39/lib/dco/cli.rb#L328-L338 |
2,879 | coderanger/dco | lib/dco/cli.rb | Dco.CLI.current_branch | def current_branch
repo.current_branch.tap {|b| raise Thor::Error.new("No explicit branch passed and current head looks detached: #{b}") if b[0] == '(' }
end | ruby | def current_branch
repo.current_branch.tap {|b| raise Thor::Error.new("No explicit branch passed and current head looks detached: #{b}") if b[0] == '(' }
end | [
"def",
"current_branch",
"repo",
".",
"current_branch",
".",
"tap",
"{",
"|",
"b",
"|",
"raise",
"Thor",
"::",
"Error",
".",
"new",
"(",
"\"No explicit branch passed and current head looks detached: #{b}\"",
")",
"if",
"b",
"[",
"0",
"]",
"==",
"'('",
"}",
"end"
] | Get the current branch but raise an error if it looks like we're on a detched head.
@api private
@return [String] | [
"Get",
"the",
"current",
"branch",
"but",
"raise",
"an",
"error",
"if",
"it",
"looks",
"like",
"we",
"re",
"on",
"a",
"detched",
"head",
"."
] | a18d60bd9217bcf08f3c264080752f64d855ec39 | https://github.com/coderanger/dco/blob/a18d60bd9217bcf08f3c264080752f64d855ec39/lib/dco/cli.rb#L360-L362 |
2,880 | coderanger/dco | lib/dco/cli.rb | Dco.CLI.has_sign_off? | def has_sign_off?(commit_or_message)
message = commit_or_message.is_a?(String) ? commit_or_message : commit_or_message.message
if message =~ /^Signed-off-by: (.+)$/
$1
else
nil
end
end | ruby | def has_sign_off?(commit_or_message)
message = commit_or_message.is_a?(String) ? commit_or_message : commit_or_message.message
if message =~ /^Signed-off-by: (.+)$/
$1
else
nil
end
end | [
"def",
"has_sign_off?",
"(",
"commit_or_message",
")",
"message",
"=",
"commit_or_message",
".",
"is_a?",
"(",
"String",
")",
"?",
"commit_or_message",
":",
"commit_or_message",
".",
"message",
"if",
"message",
"=~",
"/",
"/",
"$1",
"else",
"nil",
"end",
"end"
] | Check if a commit or commit message is already signed off.
@api private
@param commit_or_message [String, Git::Commit] Commit object or message string.
@return [String, nil] | [
"Check",
"if",
"a",
"commit",
"or",
"commit",
"message",
"is",
"already",
"signed",
"off",
"."
] | a18d60bd9217bcf08f3c264080752f64d855ec39 | https://github.com/coderanger/dco/blob/a18d60bd9217bcf08f3c264080752f64d855ec39/lib/dco/cli.rb#L394-L401 |
2,881 | sawaken/ruby-binary-parser | lib/binary_parser/general_class/abstract_binary.rb | BinaryParser.AbstractBinary.alt | def alt(binary_or_uint)
case binary_or_uint
when Integer
alt_uint(binary_or_uint)
when String
alt_binary(binary_or_uint)
else
raise BadManipulationError, "Argument shouled be Integer or binary-encoded String."
end
end | ruby | def alt(binary_or_uint)
case binary_or_uint
when Integer
alt_uint(binary_or_uint)
when String
alt_binary(binary_or_uint)
else
raise BadManipulationError, "Argument shouled be Integer or binary-encoded String."
end
end | [
"def",
"alt",
"(",
"binary_or_uint",
")",
"case",
"binary_or_uint",
"when",
"Integer",
"alt_uint",
"(",
"binary_or_uint",
")",
"when",
"String",
"alt_binary",
"(",
"binary_or_uint",
")",
"else",
"raise",
"BadManipulationError",
",",
"\"Argument shouled be Integer or binary-encoded String.\"",
"end",
"end"
] | Methods for generating modified binary. | [
"Methods",
"for",
"generating",
"modified",
"binary",
"."
] | c9ae043915d1a91677a2296e2f15d2929242d8f7 | https://github.com/sawaken/ruby-binary-parser/blob/c9ae043915d1a91677a2296e2f15d2929242d8f7/lib/binary_parser/general_class/abstract_binary.rb#L44-L53 |
2,882 | domitry/mikon | lib/mikon/core/dataframe.rb | Mikon.DataFrame.[] | def [](arg)
case
when arg.is_a?(Range)
index = @index.select{|i| arg.include?(i)}
Mikon::DataFrame.new(index.map{|i| self.row(i)}, {index: index})
when arg.is_a?(Symbol)
self.column(arg)
end
end | ruby | def [](arg)
case
when arg.is_a?(Range)
index = @index.select{|i| arg.include?(i)}
Mikon::DataFrame.new(index.map{|i| self.row(i)}, {index: index})
when arg.is_a?(Symbol)
self.column(arg)
end
end | [
"def",
"[]",
"(",
"arg",
")",
"case",
"when",
"arg",
".",
"is_a?",
"(",
"Range",
")",
"index",
"=",
"@index",
".",
"select",
"{",
"|",
"i",
"|",
"arg",
".",
"include?",
"(",
"i",
")",
"}",
"Mikon",
"::",
"DataFrame",
".",
"new",
"(",
"index",
".",
"map",
"{",
"|",
"i",
"|",
"self",
".",
"row",
"(",
"i",
")",
"}",
",",
"{",
"index",
":",
"index",
"}",
")",
"when",
"arg",
".",
"is_a?",
"(",
"Symbol",
")",
"self",
".",
"column",
"(",
"arg",
")",
"end",
"end"
] | Accessor for column and rows
@example
df = DataFrame.new({a: [1, 2, 3], b: [2, 3, 4]})
df[0..1].to_json #-> {a: [1, 2], b: [2, 3]}
df[:a] #-> <Mikon::Series> | [
"Accessor",
"for",
"column",
"and",
"rows"
] | 69886f5b6767d141e0a5624f0de2f34743909537 | https://github.com/domitry/mikon/blob/69886f5b6767d141e0a5624f0de2f34743909537/lib/mikon/core/dataframe.rb#L140-L149 |
2,883 | domitry/mikon | lib/mikon/core/dataframe.rb | Mikon.DataFrame.column | def column(label)
pos = @labels.index(label)
raise "There is no column named " + label if pos.nil?
Mikon::Series.new(label, @data[pos], index: @index)
end | ruby | def column(label)
pos = @labels.index(label)
raise "There is no column named " + label if pos.nil?
Mikon::Series.new(label, @data[pos], index: @index)
end | [
"def",
"column",
"(",
"label",
")",
"pos",
"=",
"@labels",
".",
"index",
"(",
"label",
")",
"raise",
"\"There is no column named \"",
"+",
"label",
"if",
"pos",
".",
"nil?",
"Mikon",
"::",
"Series",
".",
"new",
"(",
"label",
",",
"@data",
"[",
"pos",
"]",
",",
"index",
":",
"@index",
")",
"end"
] | Access column with its name | [
"Access",
"column",
"with",
"its",
"name"
] | 69886f5b6767d141e0a5624f0de2f34743909537 | https://github.com/domitry/mikon/blob/69886f5b6767d141e0a5624f0de2f34743909537/lib/mikon/core/dataframe.rb#L152-L156 |
2,884 | domitry/mikon | lib/mikon/core/dataframe.rb | Mikon.DataFrame.to_html | def to_html(threshold=50)
html = "<html><table><tr><td></td>"
html += @labels.map{|label| "<th>" + label.to_s + "</th>"}.join
html += "</tr>"
self.each_row.with_index do |row, pos|
next if pos > threshold && pos != self.length-1
html += "<tr><th>" + @index[pos].to_s + "</th>"
html += @labels.map{|label| "<td>" + row[label].to_s + "</td>"}.join
html += "</tr>"
html += "<tr><th>...</th>" + "<td>...</td>"*@labels.length + "</tr>" if pos == threshold
end
html += "</table>"
end | ruby | def to_html(threshold=50)
html = "<html><table><tr><td></td>"
html += @labels.map{|label| "<th>" + label.to_s + "</th>"}.join
html += "</tr>"
self.each_row.with_index do |row, pos|
next if pos > threshold && pos != self.length-1
html += "<tr><th>" + @index[pos].to_s + "</th>"
html += @labels.map{|label| "<td>" + row[label].to_s + "</td>"}.join
html += "</tr>"
html += "<tr><th>...</th>" + "<td>...</td>"*@labels.length + "</tr>" if pos == threshold
end
html += "</table>"
end | [
"def",
"to_html",
"(",
"threshold",
"=",
"50",
")",
"html",
"=",
"\"<html><table><tr><td></td>\"",
"html",
"+=",
"@labels",
".",
"map",
"{",
"|",
"label",
"|",
"\"<th>\"",
"+",
"label",
".",
"to_s",
"+",
"\"</th>\"",
"}",
".",
"join",
"html",
"+=",
"\"</tr>\"",
"self",
".",
"each_row",
".",
"with_index",
"do",
"|",
"row",
",",
"pos",
"|",
"next",
"if",
"pos",
">",
"threshold",
"&&",
"pos",
"!=",
"self",
".",
"length",
"-",
"1",
"html",
"+=",
"\"<tr><th>\"",
"+",
"@index",
"[",
"pos",
"]",
".",
"to_s",
"+",
"\"</th>\"",
"html",
"+=",
"@labels",
".",
"map",
"{",
"|",
"label",
"|",
"\"<td>\"",
"+",
"row",
"[",
"label",
"]",
".",
"to_s",
"+",
"\"</td>\"",
"}",
".",
"join",
"html",
"+=",
"\"</tr>\"",
"html",
"+=",
"\"<tr><th>...</th>\"",
"+",
"\"<td>...</td>\"",
"*",
"@labels",
".",
"length",
"+",
"\"</tr>\"",
"if",
"pos",
"==",
"threshold",
"end",
"html",
"+=",
"\"</table>\"",
"end"
] | IRuby notebook automatically call this method | [
"IRuby",
"notebook",
"automatically",
"call",
"this",
"method"
] | 69886f5b6767d141e0a5624f0de2f34743909537 | https://github.com/domitry/mikon/blob/69886f5b6767d141e0a5624f0de2f34743909537/lib/mikon/core/dataframe.rb#L179-L191 |
2,885 | domitry/mikon | lib/mikon/core/dataframe.rb | Mikon.DataFrame.sort | def sort(label, ascending=true)
i = @labels.index(label)
raise "No column named" + label.to_s if i.nil?
order = @data[i].sorted_indices
order.reverse! unless ascending
self.sort_by.with_index{|val, i| order.index(i)}
end | ruby | def sort(label, ascending=true)
i = @labels.index(label)
raise "No column named" + label.to_s if i.nil?
order = @data[i].sorted_indices
order.reverse! unless ascending
self.sort_by.with_index{|val, i| order.index(i)}
end | [
"def",
"sort",
"(",
"label",
",",
"ascending",
"=",
"true",
")",
"i",
"=",
"@labels",
".",
"index",
"(",
"label",
")",
"raise",
"\"No column named\"",
"+",
"label",
".",
"to_s",
"if",
"i",
".",
"nil?",
"order",
"=",
"@data",
"[",
"i",
"]",
".",
"sorted_indices",
"order",
".",
"reverse!",
"unless",
"ascending",
"self",
".",
"sort_by",
".",
"with_index",
"{",
"|",
"val",
",",
"i",
"|",
"order",
".",
"index",
"(",
"i",
")",
"}",
"end"
] | Sort by label
@param [Symbol] label column name to sort by
@param [Bool] ascending default true | [
"Sort",
"by",
"label"
] | 69886f5b6767d141e0a5624f0de2f34743909537 | https://github.com/domitry/mikon/blob/69886f5b6767d141e0a5624f0de2f34743909537/lib/mikon/core/dataframe.rb#L273-L279 |
2,886 | domitry/mikon | lib/mikon/core/dataframe.rb | Mikon.DataFrame.row | def row(index)
pos = @index.index(index)
arr = @data.map{|column| column[pos]}
Mikon::Row.new(@labels, arr, index)
end | ruby | def row(index)
pos = @index.index(index)
arr = @data.map{|column| column[pos]}
Mikon::Row.new(@labels, arr, index)
end | [
"def",
"row",
"(",
"index",
")",
"pos",
"=",
"@index",
".",
"index",
"(",
"index",
")",
"arr",
"=",
"@data",
".",
"map",
"{",
"|",
"column",
"|",
"column",
"[",
"pos",
"]",
"}",
"Mikon",
"::",
"Row",
".",
"new",
"(",
"@labels",
",",
"arr",
",",
"index",
")",
"end"
] | Access row using index | [
"Access",
"row",
"using",
"index"
] | 69886f5b6767d141e0a5624f0de2f34743909537 | https://github.com/domitry/mikon/blob/69886f5b6767d141e0a5624f0de2f34743909537/lib/mikon/core/dataframe.rb#L327-L331 |
2,887 | opulent/opulent | lib/opulent/parser/yield.rb | Opulent.Parser.block_yield | def block_yield(parent, indent)
return unless accept :yield
# Consume the newline from the end of the element
error :yield unless accept(:line_feed).strip.empty?
# Create a new node
yield_node = [:yield, nil, {}, [], indent]
parent[@children] << yield_node
end | ruby | def block_yield(parent, indent)
return unless accept :yield
# Consume the newline from the end of the element
error :yield unless accept(:line_feed).strip.empty?
# Create a new node
yield_node = [:yield, nil, {}, [], indent]
parent[@children] << yield_node
end | [
"def",
"block_yield",
"(",
"parent",
",",
"indent",
")",
"return",
"unless",
"accept",
":yield",
"# Consume the newline from the end of the element",
"error",
":yield",
"unless",
"accept",
"(",
":line_feed",
")",
".",
"strip",
".",
"empty?",
"# Create a new node",
"yield_node",
"=",
"[",
":yield",
",",
"nil",
",",
"{",
"}",
",",
"[",
"]",
",",
"indent",
"]",
"parent",
"[",
"@children",
"]",
"<<",
"yield_node",
"end"
] | Match a yield with a explicit or implicit target
yield target
@param parent [Node] Parent node to which we append the definition | [
"Match",
"a",
"yield",
"with",
"a",
"explicit",
"or",
"implicit",
"target"
] | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/parser/yield.rb#L11-L21 |
2,888 | Yellowen/Faalis | lib/faalis/dashboard/sections/resource_create.rb | Faalis::Dashboard::Sections.ResourceCreate.create | def create
authorize model
@resource = model.new(creation_params)
@resource.assign_attributes(**reflections_hash) unless reflections_hash.nil?
# Customize the create behaviour
before_create_hook(@resource)
# TODO: Handle M2M relations in here
if @resource.save
after_create_hook(@resource)
successful_response(:create)
else
errorful_resopnse(:create, @resource.errors) do
redirect_to Rails.application.routes.url_helpers.send(@new_route)
end
end
end | ruby | def create
authorize model
@resource = model.new(creation_params)
@resource.assign_attributes(**reflections_hash) unless reflections_hash.nil?
# Customize the create behaviour
before_create_hook(@resource)
# TODO: Handle M2M relations in here
if @resource.save
after_create_hook(@resource)
successful_response(:create)
else
errorful_resopnse(:create, @resource.errors) do
redirect_to Rails.application.routes.url_helpers.send(@new_route)
end
end
end | [
"def",
"create",
"authorize",
"model",
"@resource",
"=",
"model",
".",
"new",
"(",
"creation_params",
")",
"@resource",
".",
"assign_attributes",
"(",
"**",
"reflections_hash",
")",
"unless",
"reflections_hash",
".",
"nil?",
"# Customize the create behaviour",
"before_create_hook",
"(",
"@resource",
")",
"# TODO: Handle M2M relations in here",
"if",
"@resource",
".",
"save",
"after_create_hook",
"(",
"@resource",
")",
"successful_response",
"(",
":create",
")",
"else",
"errorful_resopnse",
"(",
":create",
",",
"@resource",
".",
"errors",
")",
"do",
"redirect_to",
"Rails",
".",
"application",
".",
"routes",
".",
"url_helpers",
".",
"send",
"(",
"@new_route",
")",
"end",
"end",
"end"
] | The actual action method for creating new resource. | [
"The",
"actual",
"action",
"method",
"for",
"creating",
"new",
"resource",
"."
] | d12abdb8559dabbf6b2044e3ba437038527039b2 | https://github.com/Yellowen/Faalis/blob/d12abdb8559dabbf6b2044e3ba437038527039b2/lib/faalis/dashboard/sections/resource_create.rb#L71-L89 |
2,889 | Yellowen/Faalis | lib/faalis/dashboard/sections/resource_create.rb | Faalis::Dashboard::Sections.ResourceCreate.is_reflection? | def is_reflection?(c)
has_many = ActiveRecord::Reflection::HasManyReflection
has_and_belongs_to_many = ActiveRecord::Reflection::HasAndBelongsToManyReflection
has_many_through = ActiveRecord::Reflection::ThroughReflection
result = c.is_a?(has_many) || c.is_a?(has_and_belongs_to_many)
result || c.is_a?(has_many_through)
end | ruby | def is_reflection?(c)
has_many = ActiveRecord::Reflection::HasManyReflection
has_and_belongs_to_many = ActiveRecord::Reflection::HasAndBelongsToManyReflection
has_many_through = ActiveRecord::Reflection::ThroughReflection
result = c.is_a?(has_many) || c.is_a?(has_and_belongs_to_many)
result || c.is_a?(has_many_through)
end | [
"def",
"is_reflection?",
"(",
"c",
")",
"has_many",
"=",
"ActiveRecord",
"::",
"Reflection",
"::",
"HasManyReflection",
"has_and_belongs_to_many",
"=",
"ActiveRecord",
"::",
"Reflection",
"::",
"HasAndBelongsToManyReflection",
"has_many_through",
"=",
"ActiveRecord",
"::",
"Reflection",
"::",
"ThroughReflection",
"result",
"=",
"c",
".",
"is_a?",
"(",
"has_many",
")",
"||",
"c",
".",
"is_a?",
"(",
"has_and_belongs_to_many",
")",
"result",
"||",
"c",
".",
"is_a?",
"(",
"has_many_through",
")",
"end"
] | Check whether the given column is a reflection or not. | [
"Check",
"whether",
"the",
"given",
"column",
"is",
"a",
"reflection",
"or",
"not",
"."
] | d12abdb8559dabbf6b2044e3ba437038527039b2 | https://github.com/Yellowen/Faalis/blob/d12abdb8559dabbf6b2044e3ba437038527039b2/lib/faalis/dashboard/sections/resource_create.rb#L126-L133 |
2,890 | platanus/dialers | lib/dialers/transformable.rb | Dialers.Transformable.transform_to_one | def transform_to_one(entity_class_or_decider, root: nil)
object = root ? raw_data[root] : raw_data
transform_attributes_to_object(entity_class_or_decider, object)
end | ruby | def transform_to_one(entity_class_or_decider, root: nil)
object = root ? raw_data[root] : raw_data
transform_attributes_to_object(entity_class_or_decider, object)
end | [
"def",
"transform_to_one",
"(",
"entity_class_or_decider",
",",
"root",
":",
"nil",
")",
"object",
"=",
"root",
"?",
"raw_data",
"[",
"root",
"]",
":",
"raw_data",
"transform_attributes_to_object",
"(",
"entity_class_or_decider",
",",
"object",
")",
"end"
] | Transforms a response into one object based on the response's body.
If you pass a hash like this:
{ 200 => ProductCreated, 202 => ProductAccepted }
the transformation will decide which object to create based on the status.
It's important to note that the class must provide attribute writers for this method to be
able to fill an object with the responses's body data.
@param entity_class_or_decider [Hash, Class] A class or a hash of Fixnum => Class
to decide with the status.
@param root [String, nil] The root to use to get the object from the body.
@return [Object] The result of the transformation. | [
"Transforms",
"a",
"response",
"into",
"one",
"object",
"based",
"on",
"the",
"response",
"s",
"body",
"."
] | 8fd8750c367ec0d058d2adfe25915125d95cb890 | https://github.com/platanus/dialers/blob/8fd8750c367ec0d058d2adfe25915125d95cb890/lib/dialers/transformable.rb#L28-L31 |
2,891 | platanus/dialers | lib/dialers/transformable.rb | Dialers.Transformable.transform_to_many | def transform_to_many(entity_class_or_decider, root: nil)
items = get_rooted_items(root)
unless items.is_a?(Array)
fail Dialers::ImpossibleTranformationError.new(response)
end
items.map { |item| transform_attributes_to_object(entity_class_or_decider, item) }
end | ruby | def transform_to_many(entity_class_or_decider, root: nil)
items = get_rooted_items(root)
unless items.is_a?(Array)
fail Dialers::ImpossibleTranformationError.new(response)
end
items.map { |item| transform_attributes_to_object(entity_class_or_decider, item) }
end | [
"def",
"transform_to_many",
"(",
"entity_class_or_decider",
",",
"root",
":",
"nil",
")",
"items",
"=",
"get_rooted_items",
"(",
"root",
")",
"unless",
"items",
".",
"is_a?",
"(",
"Array",
")",
"fail",
"Dialers",
"::",
"ImpossibleTranformationError",
".",
"new",
"(",
"response",
")",
"end",
"items",
".",
"map",
"{",
"|",
"item",
"|",
"transform_attributes_to_object",
"(",
"entity_class_or_decider",
",",
"item",
")",
"}",
"end"
] | Transforms a response into many objects based on the response's body.
@param entity_class_or_decider [Hash, Class] A class or a hash of Fixnum => Class
to decide with the status.
@param root [String, nil] The root to use to get an array from the body.
@return [Array<Object>] The result of the transformation. | [
"Transforms",
"a",
"response",
"into",
"many",
"objects",
"based",
"on",
"the",
"response",
"s",
"body",
"."
] | 8fd8750c367ec0d058d2adfe25915125d95cb890 | https://github.com/platanus/dialers/blob/8fd8750c367ec0d058d2adfe25915125d95cb890/lib/dialers/transformable.rb#L40-L46 |
2,892 | taganaka/polipus | lib/polipus.rb | Polipus.PolipusCrawler.add_url | def add_url(url, params = {})
page = Page.new(url, params)
yield(page) if block_given?
internal_queue << page.to_json
end | ruby | def add_url(url, params = {})
page = Page.new(url, params)
yield(page) if block_given?
internal_queue << page.to_json
end | [
"def",
"add_url",
"(",
"url",
",",
"params",
"=",
"{",
"}",
")",
"page",
"=",
"Page",
".",
"new",
"(",
"url",
",",
"params",
")",
"yield",
"(",
"page",
")",
"if",
"block_given?",
"internal_queue",
"<<",
"page",
".",
"to_json",
"end"
] | Enqueue an url, no matter what | [
"Enqueue",
"an",
"url",
"no",
"matter",
"what"
] | 8917a37c151a8e36fcc49fb5461aaeaf97f1f5a6 | https://github.com/taganaka/polipus/blob/8917a37c151a8e36fcc49fb5461aaeaf97f1f5a6/lib/polipus.rb#L359-L363 |
2,893 | taganaka/polipus | lib/polipus.rb | Polipus.PolipusCrawler.should_be_visited? | def should_be_visited?(url, with_tracker = true)
case
# robots.txt
when !allowed_by_robot?(url)
false
# Check against whitelist pattern matching
when !@follow_links_like.empty? && @follow_links_like.none? { |p| url.path =~ p }
false
# Check against blacklist pattern matching
when @skip_links_like.any? { |p| url.path =~ p }
false
# Page is marked as expired
when page_expired?(Page.new(url))
true
# Check against url tracker
when with_tracker && url_tracker.visited?(@options[:include_query_string_in_saved_page] ? url.to_s : url.to_s.gsub(/\?.*$/, ''))
false
else
true
end
end | ruby | def should_be_visited?(url, with_tracker = true)
case
# robots.txt
when !allowed_by_robot?(url)
false
# Check against whitelist pattern matching
when !@follow_links_like.empty? && @follow_links_like.none? { |p| url.path =~ p }
false
# Check against blacklist pattern matching
when @skip_links_like.any? { |p| url.path =~ p }
false
# Page is marked as expired
when page_expired?(Page.new(url))
true
# Check against url tracker
when with_tracker && url_tracker.visited?(@options[:include_query_string_in_saved_page] ? url.to_s : url.to_s.gsub(/\?.*$/, ''))
false
else
true
end
end | [
"def",
"should_be_visited?",
"(",
"url",
",",
"with_tracker",
"=",
"true",
")",
"case",
"# robots.txt",
"when",
"!",
"allowed_by_robot?",
"(",
"url",
")",
"false",
"# Check against whitelist pattern matching",
"when",
"!",
"@follow_links_like",
".",
"empty?",
"&&",
"@follow_links_like",
".",
"none?",
"{",
"|",
"p",
"|",
"url",
".",
"path",
"=~",
"p",
"}",
"false",
"# Check against blacklist pattern matching",
"when",
"@skip_links_like",
".",
"any?",
"{",
"|",
"p",
"|",
"url",
".",
"path",
"=~",
"p",
"}",
"false",
"# Page is marked as expired",
"when",
"page_expired?",
"(",
"Page",
".",
"new",
"(",
"url",
")",
")",
"true",
"# Check against url tracker",
"when",
"with_tracker",
"&&",
"url_tracker",
".",
"visited?",
"(",
"@options",
"[",
":include_query_string_in_saved_page",
"]",
"?",
"url",
".",
"to_s",
":",
"url",
".",
"to_s",
".",
"gsub",
"(",
"/",
"\\?",
"/",
",",
"''",
")",
")",
"false",
"else",
"true",
"end",
"end"
] | URLs enqueue policy | [
"URLs",
"enqueue",
"policy"
] | 8917a37c151a8e36fcc49fb5461aaeaf97f1f5a6 | https://github.com/taganaka/polipus/blob/8917a37c151a8e36fcc49fb5461aaeaf97f1f5a6/lib/polipus.rb#L375-L395 |
2,894 | taganaka/polipus | lib/polipus.rb | Polipus.PolipusCrawler.links_for | def links_for(page)
page.domain_aliases = domain_aliases
@focus_crawl_block.nil? ? page.links : @focus_crawl_block.call(page)
end | ruby | def links_for(page)
page.domain_aliases = domain_aliases
@focus_crawl_block.nil? ? page.links : @focus_crawl_block.call(page)
end | [
"def",
"links_for",
"(",
"page",
")",
"page",
".",
"domain_aliases",
"=",
"domain_aliases",
"@focus_crawl_block",
".",
"nil?",
"?",
"page",
".",
"links",
":",
"@focus_crawl_block",
".",
"call",
"(",
"page",
")",
"end"
] | It extracts URLs from the page | [
"It",
"extracts",
"URLs",
"from",
"the",
"page"
] | 8917a37c151a8e36fcc49fb5461aaeaf97f1f5a6 | https://github.com/taganaka/polipus/blob/8917a37c151a8e36fcc49fb5461aaeaf97f1f5a6/lib/polipus.rb#L398-L401 |
2,895 | taganaka/polipus | lib/polipus.rb | Polipus.PolipusCrawler.page_expired? | def page_expired?(page)
return false if @options[:ttl_page].nil?
stored_page = @storage.get(page)
r = stored_page && stored_page.expired?(@options[:ttl_page])
@logger.debug { "Page #{page.url} marked as expired" } if r
r
end | ruby | def page_expired?(page)
return false if @options[:ttl_page].nil?
stored_page = @storage.get(page)
r = stored_page && stored_page.expired?(@options[:ttl_page])
@logger.debug { "Page #{page.url} marked as expired" } if r
r
end | [
"def",
"page_expired?",
"(",
"page",
")",
"return",
"false",
"if",
"@options",
"[",
":ttl_page",
"]",
".",
"nil?",
"stored_page",
"=",
"@storage",
".",
"get",
"(",
"page",
")",
"r",
"=",
"stored_page",
"&&",
"stored_page",
".",
"expired?",
"(",
"@options",
"[",
":ttl_page",
"]",
")",
"@logger",
".",
"debug",
"{",
"\"Page #{page.url} marked as expired\"",
"}",
"if",
"r",
"r",
"end"
] | whether a page is expired or not | [
"whether",
"a",
"page",
"is",
"expired",
"or",
"not"
] | 8917a37c151a8e36fcc49fb5461aaeaf97f1f5a6 | https://github.com/taganaka/polipus/blob/8917a37c151a8e36fcc49fb5461aaeaf97f1f5a6/lib/polipus.rb#L404-L410 |
2,896 | taganaka/polipus | lib/polipus.rb | Polipus.PolipusCrawler.page_exists? | def page_exists?(page)
return false if page.user_data && page.user_data.p_seeded
@storage.exists?(page) && !page_expired?(page)
end | ruby | def page_exists?(page)
return false if page.user_data && page.user_data.p_seeded
@storage.exists?(page) && !page_expired?(page)
end | [
"def",
"page_exists?",
"(",
"page",
")",
"return",
"false",
"if",
"page",
".",
"user_data",
"&&",
"page",
".",
"user_data",
".",
"p_seeded",
"@storage",
".",
"exists?",
"(",
"page",
")",
"&&",
"!",
"page_expired?",
"(",
"page",
")",
"end"
] | whether a page exists or not | [
"whether",
"a",
"page",
"exists",
"or",
"not"
] | 8917a37c151a8e36fcc49fb5461aaeaf97f1f5a6 | https://github.com/taganaka/polipus/blob/8917a37c151a8e36fcc49fb5461aaeaf97f1f5a6/lib/polipus.rb#L413-L416 |
2,897 | taganaka/polipus | lib/polipus.rb | Polipus.PolipusCrawler.enqueue | def enqueue(url_to_visit, current_page)
page_to_visit = Page.new(url_to_visit.to_s, referer: current_page.url.to_s, depth: current_page.depth + 1)
internal_queue << page_to_visit.to_json
to_track = @options[:include_query_string_in_saved_page] ? url_to_visit.to_s : url_to_visit.to_s.gsub(/\?.*$/, '')
url_tracker.visit to_track
@logger.debug { "Added (#{url_to_visit}) to the queue" }
end | ruby | def enqueue(url_to_visit, current_page)
page_to_visit = Page.new(url_to_visit.to_s, referer: current_page.url.to_s, depth: current_page.depth + 1)
internal_queue << page_to_visit.to_json
to_track = @options[:include_query_string_in_saved_page] ? url_to_visit.to_s : url_to_visit.to_s.gsub(/\?.*$/, '')
url_tracker.visit to_track
@logger.debug { "Added (#{url_to_visit}) to the queue" }
end | [
"def",
"enqueue",
"(",
"url_to_visit",
",",
"current_page",
")",
"page_to_visit",
"=",
"Page",
".",
"new",
"(",
"url_to_visit",
".",
"to_s",
",",
"referer",
":",
"current_page",
".",
"url",
".",
"to_s",
",",
"depth",
":",
"current_page",
".",
"depth",
"+",
"1",
")",
"internal_queue",
"<<",
"page_to_visit",
".",
"to_json",
"to_track",
"=",
"@options",
"[",
":include_query_string_in_saved_page",
"]",
"?",
"url_to_visit",
".",
"to_s",
":",
"url_to_visit",
".",
"to_s",
".",
"gsub",
"(",
"/",
"\\?",
"/",
",",
"''",
")",
"url_tracker",
".",
"visit",
"to_track",
"@logger",
".",
"debug",
"{",
"\"Added (#{url_to_visit}) to the queue\"",
"}",
"end"
] | The url is enqueued for a later visit | [
"The",
"url",
"is",
"enqueued",
"for",
"a",
"later",
"visit"
] | 8917a37c151a8e36fcc49fb5461aaeaf97f1f5a6 | https://github.com/taganaka/polipus/blob/8917a37c151a8e36fcc49fb5461aaeaf97f1f5a6/lib/polipus.rb#L429-L435 |
2,898 | taganaka/polipus | lib/polipus.rb | Polipus.PolipusCrawler.execute_plugin | def execute_plugin(method)
Polipus::Plugin.plugins.each do |k, p|
next unless p.respond_to?(method)
@logger.info { "Running plugin method #{method} on #{k}" }
ret_val = p.send(method, self)
instance_eval(&ret_val) if ret_val.is_a? Proc
end
end | ruby | def execute_plugin(method)
Polipus::Plugin.plugins.each do |k, p|
next unless p.respond_to?(method)
@logger.info { "Running plugin method #{method} on #{k}" }
ret_val = p.send(method, self)
instance_eval(&ret_val) if ret_val.is_a? Proc
end
end | [
"def",
"execute_plugin",
"(",
"method",
")",
"Polipus",
"::",
"Plugin",
".",
"plugins",
".",
"each",
"do",
"|",
"k",
",",
"p",
"|",
"next",
"unless",
"p",
".",
"respond_to?",
"(",
"method",
")",
"@logger",
".",
"info",
"{",
"\"Running plugin method #{method} on #{k}\"",
"}",
"ret_val",
"=",
"p",
".",
"send",
"(",
"method",
",",
"self",
")",
"instance_eval",
"(",
"ret_val",
")",
"if",
"ret_val",
".",
"is_a?",
"Proc",
"end",
"end"
] | It invokes a plugin method if any | [
"It",
"invokes",
"a",
"plugin",
"method",
"if",
"any"
] | 8917a37c151a8e36fcc49fb5461aaeaf97f1f5a6 | https://github.com/taganaka/polipus/blob/8917a37c151a8e36fcc49fb5461aaeaf97f1f5a6/lib/polipus.rb#L478-L485 |
2,899 | mateomurphy/rails_locale_detection | lib/rails_locale_detection/detection_methods.rb | RailsLocaleDetection.DetectionMethods.set_default_url_option_for_request? | def set_default_url_option_for_request?
RailsLocaleDetection.set_default_url_option === true || RailsLocaleDetection.set_default_url_option == :always || RailsLocaleDetection.set_default_url_option == :explicitly && params[locale_key].present?
end | ruby | def set_default_url_option_for_request?
RailsLocaleDetection.set_default_url_option === true || RailsLocaleDetection.set_default_url_option == :always || RailsLocaleDetection.set_default_url_option == :explicitly && params[locale_key].present?
end | [
"def",
"set_default_url_option_for_request?",
"RailsLocaleDetection",
".",
"set_default_url_option",
"===",
"true",
"||",
"RailsLocaleDetection",
".",
"set_default_url_option",
"==",
":always",
"||",
"RailsLocaleDetection",
".",
"set_default_url_option",
"==",
":explicitly",
"&&",
"params",
"[",
"locale_key",
"]",
".",
"present?",
"end"
] | returns true if the default url option should be set for this request | [
"returns",
"true",
"if",
"the",
"default",
"url",
"option",
"should",
"be",
"set",
"for",
"this",
"request"
] | 0c7748db7374196ca0b5f6aa12aea339671fe704 | https://github.com/mateomurphy/rails_locale_detection/blob/0c7748db7374196ca0b5f6aa12aea339671fe704/lib/rails_locale_detection/detection_methods.rb#L50-L52 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.