repo stringlengths 5 67 | path stringlengths 4 218 | func_name stringlengths 0 151 | original_string stringlengths 52 373k | language stringclasses 6 values | code stringlengths 52 373k | code_tokens listlengths 10 512 | docstring stringlengths 3 47.2k | docstring_tokens listlengths 3 234 | sha stringlengths 40 40 | url stringlengths 85 339 | partition stringclasses 3 values |
|---|---|---|---|---|---|---|---|---|---|---|---|
snowplow/snowplow-ruby-tracker | lib/snowplow-tracker/emitters.rb | SnowplowTracker.AsyncEmitter.flush | def flush(async=true)
loop do
@lock.synchronize do
@queue.synchronize do
@results_unprocessed += 1
end
@queue << @buffer
@buffer = []
end
if not async
LOGGER.info('Starting synchronous flush')
@queue.synchronize do
@all_processed_condition.wait_while { @results_unprocessed > 0 }
LOGGER.info('Finished synchronous flush')
end
end
break if @buffer.size < 1
end
end | ruby | def flush(async=true)
loop do
@lock.synchronize do
@queue.synchronize do
@results_unprocessed += 1
end
@queue << @buffer
@buffer = []
end
if not async
LOGGER.info('Starting synchronous flush')
@queue.synchronize do
@all_processed_condition.wait_while { @results_unprocessed > 0 }
LOGGER.info('Finished synchronous flush')
end
end
break if @buffer.size < 1
end
end | [
"def",
"flush",
"(",
"async",
"=",
"true",
")",
"loop",
"do",
"@lock",
".",
"synchronize",
"do",
"@queue",
".",
"synchronize",
"do",
"@results_unprocessed",
"+=",
"1",
"end",
"@queue",
"<<",
"@buffer",
"@buffer",
"=",
"[",
"]",
"end",
"if",
"not",
"async... | Flush the buffer
If async is false, block until the queue is empty | [
"Flush",
"the",
"buffer",
"If",
"async",
"is",
"false",
"block",
"until",
"the",
"queue",
"is",
"empty"
] | 39fcfa2be793f2e25e73087a9700abc93f43b5e8 | https://github.com/snowplow/snowplow-ruby-tracker/blob/39fcfa2be793f2e25e73087a9700abc93f43b5e8/lib/snowplow-tracker/emitters.rb#L259-L277 | valid |
abrom/rocketchat-ruby | lib/rocket_chat/util.rb | RocketChat.Util.stringify_hash_keys | def stringify_hash_keys(hash)
new_hash = {}
hash.each do |key, value|
new_hash[key.to_s] =
if value.is_a? Hash
stringify_hash_keys value
else
value
end
end
new_hash
end | ruby | def stringify_hash_keys(hash)
new_hash = {}
hash.each do |key, value|
new_hash[key.to_s] =
if value.is_a? Hash
stringify_hash_keys value
else
value
end
end
new_hash
end | [
"def",
"stringify_hash_keys",
"(",
"hash",
")",
"new_hash",
"=",
"{",
"}",
"hash",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"new_hash",
"[",
"key",
".",
"to_s",
"]",
"=",
"if",
"value",
".",
"is_a?",
"Hash",
"stringify_hash_keys",
"value",
"el... | Stringify symbolized hash keys
@param [Hash] hash A string/symbol keyed hash
@return Stringified hash | [
"Stringify",
"symbolized",
"hash",
"keys"
] | 4664693217c5e6142a873710a8867757ba84ca16 | https://github.com/abrom/rocketchat-ruby/blob/4664693217c5e6142a873710a8867757ba84ca16/lib/rocket_chat/util.rb#L13-L24 | valid |
abrom/rocketchat-ruby | lib/rocket_chat/util.rb | RocketChat.Util.slice_hash | def slice_hash(hash, *keys)
return {} if keys.length.zero?
new_hash = {}
hash.each do |key, value|
new_hash[key] = value if keys.include? key
end
new_hash
end | ruby | def slice_hash(hash, *keys)
return {} if keys.length.zero?
new_hash = {}
hash.each do |key, value|
new_hash[key] = value if keys.include? key
end
new_hash
end | [
"def",
"slice_hash",
"(",
"hash",
",",
"*",
"keys",
")",
"return",
"{",
"}",
"if",
"keys",
".",
"length",
".",
"zero?",
"new_hash",
"=",
"{",
"}",
"hash",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"new_hash",
"[",
"key",
"]",
"=",
"value"... | Slice keys from hash
@param [Hash] hash A hash to slice key/value pairs from
@param [Array] *keys The keys to be sliced
@return Hash filtered by keys | [
"Slice",
"keys",
"from",
"hash"
] | 4664693217c5e6142a873710a8867757ba84ca16 | https://github.com/abrom/rocketchat-ruby/blob/4664693217c5e6142a873710a8867757ba84ca16/lib/rocket_chat/util.rb#L32-L40 | valid |
abrom/rocketchat-ruby | lib/rocket_chat/server.rb | RocketChat.Server.login | def login(username, password)
response = request_json(
'/api/v1/login',
method: :post,
body: {
username: username,
password: password
}
)
Session.new self, Token.new(response['data'])
end | ruby | def login(username, password)
response = request_json(
'/api/v1/login',
method: :post,
body: {
username: username,
password: password
}
)
Session.new self, Token.new(response['data'])
end | [
"def",
"login",
"(",
"username",
",",
"password",
")",
"response",
"=",
"request_json",
"(",
"'/api/v1/login'",
",",
"method",
":",
":post",
",",
"body",
":",
"{",
"username",
":",
"username",
",",
"password",
":",
"password",
"}",
")",
"Session",
".",
"... | Login REST API
@param [String] username Username
@param [String] password Password
@return [Session] Rocket.Chat Session
@raise [HTTPError, StatusError] | [
"Login",
"REST",
"API"
] | 4664693217c5e6142a873710a8867757ba84ca16 | https://github.com/abrom/rocketchat-ruby/blob/4664693217c5e6142a873710a8867757ba84ca16/lib/rocket_chat/server.rb#L37-L47 | valid |
spovich/mandrill_dm | lib/mandrill_dm/message.rb | MandrillDm.Message.attachments | def attachments
regular_attachments = mail.attachments.reject(&:inline?)
regular_attachments.collect do |attachment|
{
name: attachment.filename,
type: attachment.mime_type,
content: Base64.encode64(attachment.body.decoded)
}
end
end | ruby | def attachments
regular_attachments = mail.attachments.reject(&:inline?)
regular_attachments.collect do |attachment|
{
name: attachment.filename,
type: attachment.mime_type,
content: Base64.encode64(attachment.body.decoded)
}
end
end | [
"def",
"attachments",
"regular_attachments",
"=",
"mail",
".",
"attachments",
".",
"reject",
"(",
"&",
":inline?",
")",
"regular_attachments",
".",
"collect",
"do",
"|",
"attachment",
"|",
"{",
"name",
":",
"attachment",
".",
"filename",
",",
"type",
":",
"a... | Returns a Mandrill API compatible attachment hash | [
"Returns",
"a",
"Mandrill",
"API",
"compatible",
"attachment",
"hash"
] | 0636a9969292d3c545df111c296361af47f6373b | https://github.com/spovich/mandrill_dm/blob/0636a9969292d3c545df111c296361af47f6373b/lib/mandrill_dm/message.rb#L12-L21 | valid |
spovich/mandrill_dm | lib/mandrill_dm/message.rb | MandrillDm.Message.images | def images
inline_attachments = mail.attachments.select(&:inline?)
inline_attachments.collect do |attachment|
{
name: attachment.cid,
type: attachment.mime_type,
content: Base64.encode64(attachment.body.decoded)
}
end
end | ruby | def images
inline_attachments = mail.attachments.select(&:inline?)
inline_attachments.collect do |attachment|
{
name: attachment.cid,
type: attachment.mime_type,
content: Base64.encode64(attachment.body.decoded)
}
end
end | [
"def",
"images",
"inline_attachments",
"=",
"mail",
".",
"attachments",
".",
"select",
"(",
"&",
":inline?",
")",
"inline_attachments",
".",
"collect",
"do",
"|",
"attachment",
"|",
"{",
"name",
":",
"attachment",
".",
"cid",
",",
"type",
":",
"attachment",
... | Mandrill uses a different hash for inlined image attachments | [
"Mandrill",
"uses",
"a",
"different",
"hash",
"for",
"inlined",
"image",
"attachments"
] | 0636a9969292d3c545df111c296361af47f6373b | https://github.com/spovich/mandrill_dm/blob/0636a9969292d3c545df111c296361af47f6373b/lib/mandrill_dm/message.rb#L24-L33 | valid |
denniskuczynski/beanstalkd_view | lib/beanstalkd_view/beanstalkd_utils.rb | BeanstalkdView.BeanstalkdUtils.get_chart_data_hash | def get_chart_data_hash(tubes)
chart_data = {}
chart_data["total_jobs_data"] = Hash.new
chart_data["buried_jobs_data"] = Hash.new
chart_data["total_jobs_data"]["items"] = Array.new
chart_data["buried_jobs_data"]["items"] = Array.new
tubes.each do |tube|
stats = tube.stats
add_chart_data_to_hash(tube, stats[:total_jobs], chart_data["total_jobs_data"]["items"])
add_chart_data_to_hash(tube, stats[:current_jobs_buried], chart_data["buried_jobs_data"]["items"])
end
chart_data
end | ruby | def get_chart_data_hash(tubes)
chart_data = {}
chart_data["total_jobs_data"] = Hash.new
chart_data["buried_jobs_data"] = Hash.new
chart_data["total_jobs_data"]["items"] = Array.new
chart_data["buried_jobs_data"]["items"] = Array.new
tubes.each do |tube|
stats = tube.stats
add_chart_data_to_hash(tube, stats[:total_jobs], chart_data["total_jobs_data"]["items"])
add_chart_data_to_hash(tube, stats[:current_jobs_buried], chart_data["buried_jobs_data"]["items"])
end
chart_data
end | [
"def",
"get_chart_data_hash",
"(",
"tubes",
")",
"chart_data",
"=",
"{",
"}",
"chart_data",
"[",
"\"total_jobs_data\"",
"]",
"=",
"Hash",
".",
"new",
"chart_data",
"[",
"\"buried_jobs_data\"",
"]",
"=",
"Hash",
".",
"new",
"chart_data",
"[",
"\"total_jobs_data\"... | Return the stats data in a format for the Bluff JS UI Charts | [
"Return",
"the",
"stats",
"data",
"in",
"a",
"format",
"for",
"the",
"Bluff",
"JS",
"UI",
"Charts"
] | 0ab71a552d91f9ef22e704e45f72007fe92e57c9 | https://github.com/denniskuczynski/beanstalkd_view/blob/0ab71a552d91f9ef22e704e45f72007fe92e57c9/lib/beanstalkd_view/beanstalkd_utils.rb#L39-L51 | valid |
denniskuczynski/beanstalkd_view | lib/beanstalkd_view/beanstalkd_utils.rb | BeanstalkdView.BeanstalkdUtils.guess_min_peek_range | def guess_min_peek_range(tubes)
min = 0
tubes.each do |tube|
response = tube.peek('ready')
if response
if min == 0
min = response.id.to_i
else
min = [min, response.id.to_i].min
end
end
end
# Add some jitter in the opposite direction of 1/4 range
jitter_min = (min-(GUESS_PEEK_RANGE*0.25)).to_i
[1, jitter_min].max
end | ruby | def guess_min_peek_range(tubes)
min = 0
tubes.each do |tube|
response = tube.peek('ready')
if response
if min == 0
min = response.id.to_i
else
min = [min, response.id.to_i].min
end
end
end
# Add some jitter in the opposite direction of 1/4 range
jitter_min = (min-(GUESS_PEEK_RANGE*0.25)).to_i
[1, jitter_min].max
end | [
"def",
"guess_min_peek_range",
"(",
"tubes",
")",
"min",
"=",
"0",
"tubes",
".",
"each",
"do",
"|",
"tube",
"|",
"response",
"=",
"tube",
".",
"peek",
"(",
"'ready'",
")",
"if",
"response",
"if",
"min",
"==",
"0",
"min",
"=",
"response",
".",
"id",
... | Pick a Minimum Peek Range Based on minumum ready jobs on all tubes | [
"Pick",
"a",
"Minimum",
"Peek",
"Range",
"Based",
"on",
"minumum",
"ready",
"jobs",
"on",
"all",
"tubes"
] | 0ab71a552d91f9ef22e704e45f72007fe92e57c9 | https://github.com/denniskuczynski/beanstalkd_view/blob/0ab71a552d91f9ef22e704e45f72007fe92e57c9/lib/beanstalkd_view/beanstalkd_utils.rb#L63-L78 | valid |
mattmueller/foursquare2 | lib/foursquare2/pages.rb | Foursquare2.Pages.page_venues | def page_venues(page_id, options={})
response = connection.get do |req|
req.url "pages/#{page_id}/venues", options
end
venues = return_error_or_body(response, response.body.response.venues)
venues = Foursquare2.filter(venues, options[:query]) if options.has_key? :query
venues
end | ruby | def page_venues(page_id, options={})
response = connection.get do |req|
req.url "pages/#{page_id}/venues", options
end
venues = return_error_or_body(response, response.body.response.venues)
venues = Foursquare2.filter(venues, options[:query]) if options.has_key? :query
venues
end | [
"def",
"page_venues",
"(",
"page_id",
",",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"get",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"pages/#{page_id}/venues\"",
",",
"options",
"end",
"venues",
"=",
"return_error_or_body",
"(",
... | Get all venues for a given page.
@param [String] page_id - The page to retrieve venues for.
@param [Hash] options
@option options Integer :limit
@option options Integer :offset - For paging through results
@option options String :ll - Latitude and longitude in format LAT,LON - Limit results to venues near this latitude and longitude. NOT VALID with NE or SW (see after).
@option String :radius - Can be used when including ll. Limit results to venues within this many meters of the specified ll. Not valid with ne or sw.
@option String :sw - With ne, limits results to the bounding quadrangle defined by the latitude and longitude given by sw as its south-west corner, and ne as its north-east corner. Not valid with ll or radius.
@option String :ne - See sw | [
"Get",
"all",
"venues",
"for",
"a",
"given",
"page",
"."
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/pages.rb#L43-L50 | valid |
mattmueller/foursquare2 | lib/foursquare2/pages.rb | Foursquare2.Pages.managed_pages | def managed_pages(options={})
response = connection.get do |req|
req.url "pages/managing", options
end
return_error_or_body(response, response.body.response.managing)
end | ruby | def managed_pages(options={})
response = connection.get do |req|
req.url "pages/managing", options
end
return_error_or_body(response, response.body.response.managing)
end | [
"def",
"managed_pages",
"(",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"get",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"pages/managing\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"response",
",",
"response",
".",
"bo... | Returns a list of managed pages. | [
"Returns",
"a",
"list",
"of",
"managed",
"pages",
"."
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/pages.rb#L57-L62 | valid |
mattmueller/foursquare2 | lib/foursquare2/users.rb | Foursquare2.Users.search_users_by_tip | def search_users_by_tip(options={})
name = options.delete(:name)
options[:limit] = 500
tips = search_tips(options)
user = []
tips.each do |tip|
user << tip['user'] if check_name(tip['user'], name)
end
user.uniq
end | ruby | def search_users_by_tip(options={})
name = options.delete(:name)
options[:limit] = 500
tips = search_tips(options)
user = []
tips.each do |tip|
user << tip['user'] if check_name(tip['user'], name)
end
user.uniq
end | [
"def",
"search_users_by_tip",
"(",
"options",
"=",
"{",
"}",
")",
"name",
"=",
"options",
".",
"delete",
"(",
":name",
")",
"options",
"[",
":limit",
"]",
"=",
"500",
"tips",
"=",
"search_tips",
"(",
"options",
")",
"user",
"=",
"[",
"]",
"tips",
"."... | Search for users by tip
@param [Hash] options
@option options String :ll - Latitude and longitude in format LAT,LON
@option options Integer :limit - The limit of results to return.
@option options Integer :offset - Used to page through results.
@option options String :filter - Set to 'friends' to limit tips to those from friends.
@option options String :query - Only find tips matching this term.
@option options String :name - Match on name | [
"Search",
"for",
"users",
"by",
"tip"
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/users.rb#L52-L61 | valid |
mattmueller/foursquare2 | lib/foursquare2/users.rb | Foursquare2.Users.user_requests | def user_requests(options={})
response = connection.get do |req|
req.url "users/requests", options
end
return_error_or_body(response, response.body.response.requests)
end | ruby | def user_requests(options={})
response = connection.get do |req|
req.url "users/requests", options
end
return_error_or_body(response, response.body.response.requests)
end | [
"def",
"user_requests",
"(",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"get",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"users/requests\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"response",
",",
"response",
".",
"bo... | Get all pending friend requests for the authenticated user | [
"Get",
"all",
"pending",
"friend",
"requests",
"for",
"the",
"authenticated",
"user"
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/users.rb#L70-L75 | valid |
mattmueller/foursquare2 | lib/foursquare2/users.rb | Foursquare2.Users.user_checkins | def user_checkins(options={})
response = connection.get do |req|
req.url "users/self/checkins", options
end
return_error_or_body(response, response.body.response.checkins)
end | ruby | def user_checkins(options={})
response = connection.get do |req|
req.url "users/self/checkins", options
end
return_error_or_body(response, response.body.response.checkins)
end | [
"def",
"user_checkins",
"(",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"get",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"users/self/checkins\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"response",
",",
"response",
".",
... | Get checkins for the authenticated user
@param [Hash] options
@option options Integer :limit
@option options Integer :offest - For paging through results
@option options String :sort - "newestfirst" or "oldestfirst"
@option options Integer :afterTimestamp - Get all checkins after this epoch time.
@option options Integer :beforeTimestamp - Get all checkins before this epoch time. | [
"Get",
"checkins",
"for",
"the",
"authenticated",
"user"
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/users.rb#L96-L101 | valid |
mattmueller/foursquare2 | lib/foursquare2/users.rb | Foursquare2.Users.user_friends | def user_friends(user_id, options={})
response = connection.get do |req|
req.url "users/#{user_id}/friends", options
end
return_error_or_body(response, response.body.response.friends)
end | ruby | def user_friends(user_id, options={})
response = connection.get do |req|
req.url "users/#{user_id}/friends", options
end
return_error_or_body(response, response.body.response.friends)
end | [
"def",
"user_friends",
"(",
"user_id",
",",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"get",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"users/#{user_id}/friends\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"response",
",... | Get all friends for a given user.
@param [String] user_id - The user to retrieve friends for.
@param [Hash] options
@option options Integer :limit
@option options Integer :offest - For paging through results | [
"Get",
"all",
"friends",
"for",
"a",
"given",
"user",
"."
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/users.rb#L110-L115 | valid |
mattmueller/foursquare2 | lib/foursquare2/users.rb | Foursquare2.Users.user_tips | def user_tips(user_id, options={})
response = connection.get do |req|
req.url "users/#{user_id}/tips", options
end
tips = return_error_or_body(response, response.body.response.tips)
tips = Foursquare2.filter(tips, options[:query]) if options.has_key? :query
tips
end | ruby | def user_tips(user_id, options={})
response = connection.get do |req|
req.url "users/#{user_id}/tips", options
end
tips = return_error_or_body(response, response.body.response.tips)
tips = Foursquare2.filter(tips, options[:query]) if options.has_key? :query
tips
end | [
"def",
"user_tips",
"(",
"user_id",
",",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"get",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"users/#{user_id}/tips\"",
",",
"options",
"end",
"tips",
"=",
"return_error_or_body",
"(",
"resp... | Get all tips for a given user, optionally filtering by text.
@param [String] user_id - The user to retrieve friends for.
@param [Hash] options
@option options Integer :limit
@option options Integer :offest - For paging through results
@option options String :sort - One of recent, nearby, popular
@option options String :ll - Latitude and longitude in format LAT,LON - required for nearby sort option.
@option String :query - Only find tips matching this term. | [
"Get",
"all",
"tips",
"for",
"a",
"given",
"user",
"optionally",
"filtering",
"by",
"text",
"."
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/users.rb#L127-L134 | valid |
mattmueller/foursquare2 | lib/foursquare2/users.rb | Foursquare2.Users.user_todos | def user_todos(user_id, options={})
response = connection.get do |req|
req.url "users/#{user_id}/todos", options
end
return_error_or_body(response, response.body.response.todos)
end | ruby | def user_todos(user_id, options={})
response = connection.get do |req|
req.url "users/#{user_id}/todos", options
end
return_error_or_body(response, response.body.response.todos)
end | [
"def",
"user_todos",
"(",
"user_id",
",",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"get",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"users/#{user_id}/todos\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"response",
",",
... | Get all todos for a given user.
@param [String] user_id - The user to retrieve friends for.
@param [Hash] options
@option options String :sort - One of recent, nearby, popular
@option options String :ll - Latitude and longitude in format LAT,LON - required for nearby sort option. | [
"Get",
"all",
"todos",
"for",
"a",
"given",
"user",
"."
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/users.rb#L144-L149 | valid |
mattmueller/foursquare2 | lib/foursquare2/users.rb | Foursquare2.Users.user_photos | def user_photos(options={})
response = connection.get do |req|
req.url "users/self/photos", options
end
return_error_or_body(response, response.body.response.photos)
end | ruby | def user_photos(options={})
response = connection.get do |req|
req.url "users/self/photos", options
end
return_error_or_body(response, response.body.response.photos)
end | [
"def",
"user_photos",
"(",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"get",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"users/self/photos\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"response",
",",
"response",
".",
"b... | Get the photos for the authenticated user.
@param [Hash] options
@option options Integer :limit - The limit of results to return.
@option options Integer :offset - Used to page through results. | [
"Get",
"the",
"photos",
"for",
"the",
"authenticated",
"user",
"."
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/users.rb#L158-L163 | valid |
mattmueller/foursquare2 | lib/foursquare2/users.rb | Foursquare2.Users.user_venue_history | def user_venue_history(options={})
response = connection.get do |req|
req.url "users/self/venuehistory", options
end
return_error_or_body(response, response.body.response.venues)
end | ruby | def user_venue_history(options={})
response = connection.get do |req|
req.url "users/self/venuehistory", options
end
return_error_or_body(response, response.body.response.venues)
end | [
"def",
"user_venue_history",
"(",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"get",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"users/self/venuehistory\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"response",
",",
"response"... | Get the venue history for the authenticated user.
@param [Hash] options
@option options Integer :afterTimestamp - Get all venues after this epoch time.
@option options Integer :beforeTimestamp - Get all venues before this epoch time. | [
"Get",
"the",
"venue",
"history",
"for",
"the",
"authenticated",
"user",
"."
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/users.rb#L172-L177 | valid |
mattmueller/foursquare2 | lib/foursquare2/users.rb | Foursquare2.Users.user_mayorships | def user_mayorships(user_id, options={})
response = connection.get do |req|
req.url "users/#{user_id}/mayorships", options
end
return_error_or_body(response, response.body.response.mayorships)
end | ruby | def user_mayorships(user_id, options={})
response = connection.get do |req|
req.url "users/#{user_id}/mayorships", options
end
return_error_or_body(response, response.body.response.mayorships)
end | [
"def",
"user_mayorships",
"(",
"user_id",
",",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"get",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"users/#{user_id}/mayorships\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"response"... | Get the mayorships for a given user.
@param [String] user_id - The user to retrieve friends for. | [
"Get",
"the",
"mayorships",
"for",
"a",
"given",
"user",
"."
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/users.rb#L183-L188 | valid |
mattmueller/foursquare2 | lib/foursquare2/users.rb | Foursquare2.Users.user_lists | def user_lists(user_id, options={})
response = connection.get do |req|
req.url "users/#{user_id}/lists", options
end
return_error_or_body(response, response.body.response.lists)
end | ruby | def user_lists(user_id, options={})
response = connection.get do |req|
req.url "users/#{user_id}/lists", options
end
return_error_or_body(response, response.body.response.lists)
end | [
"def",
"user_lists",
"(",
"user_id",
",",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"get",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"users/#{user_id}/lists\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"response",
",",
... | Get the lists for a given user.
@param [String] user_id - The user to retrieve lists for.
@param [Hash] options
@option options String :group - One of: created, edited, followed, friends, or suggestions
@option options String :ll - Location of the user, required in order to receive the suggested group. | [
"Get",
"the",
"lists",
"for",
"a",
"given",
"user",
"."
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/users.rb#L197-L202 | valid |
mattmueller/foursquare2 | lib/foursquare2/users.rb | Foursquare2.Users.user_friend_request | def user_friend_request(user_id, options={})
response = connection.post do |req|
req.url "users/#{user_id}/request", options
end
return_error_or_body(response, response.body.response)
end | ruby | def user_friend_request(user_id, options={})
response = connection.post do |req|
req.url "users/#{user_id}/request", options
end
return_error_or_body(response, response.body.response)
end | [
"def",
"user_friend_request",
"(",
"user_id",
",",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"post",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"users/#{user_id}/request\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"respons... | Request friendship with a user
@param [String] user_id - The user to request friendship with. | [
"Request",
"friendship",
"with",
"a",
"user"
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/users.rb#L208-L213 | valid |
mattmueller/foursquare2 | lib/foursquare2/users.rb | Foursquare2.Users.user_set_friend_pings | def user_set_friend_pings(user_id, value)
response = connection.post do |req|
req.url "users/#{user_id}/setpings", value
end
return_error_or_body(response, response.body.response)
end | ruby | def user_set_friend_pings(user_id, value)
response = connection.post do |req|
req.url "users/#{user_id}/setpings", value
end
return_error_or_body(response, response.body.response)
end | [
"def",
"user_set_friend_pings",
"(",
"user_id",
",",
"value",
")",
"response",
"=",
"connection",
".",
"post",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"users/#{user_id}/setpings\"",
",",
"value",
"end",
"return_error_or_body",
"(",
"response",
",",
"response... | Set pings for a friend
@param [String] user_id - The user to set pings for
@param [String] value - The value of ping setting for this friend, either true or false. | [
"Set",
"pings",
"for",
"a",
"friend"
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/users.rb#L253-L258 | valid |
mattmueller/foursquare2 | lib/foursquare2/tips.rb | Foursquare2.Tips.tip | def tip(tip_id, options={})
response = connection.get do |req|
req.url "tips/#{tip_id}", options
end
return_error_or_body(response, response.body.response.tip)
end | ruby | def tip(tip_id, options={})
response = connection.get do |req|
req.url "tips/#{tip_id}", options
end
return_error_or_body(response, response.body.response.tip)
end | [
"def",
"tip",
"(",
"tip_id",
",",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"get",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"tips/#{tip_id}\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"response",
",",
"response",
"... | Retrieve information about a tip.
param [String] tip_id - The id of the tip to retrieve. | [
"Retrieve",
"information",
"about",
"a",
"tip",
"."
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/tips.rb#L8-L13 | valid |
mattmueller/foursquare2 | lib/foursquare2/tips.rb | Foursquare2.Tips.search_tips | def search_tips(options={})
response = connection.get do |req|
req.url "tips/search", options
end
return_error_or_body(response, response.body.response.tips)
end | ruby | def search_tips(options={})
response = connection.get do |req|
req.url "tips/search", options
end
return_error_or_body(response, response.body.response.tips)
end | [
"def",
"search_tips",
"(",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"get",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"tips/search\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"response",
",",
"response",
".",
"body",
... | Search for tips.
@param [Hash] options
@option options String :ll - Latitude and longitude in format LAT,LON
@option options Integer :limit - The limit of results to return.
@option options Integer :offset - Used to page through results.
@option options String :filter - Set to 'friends' to limit tips to those from friends.
@option options String :query - Only find tips matching this term. | [
"Search",
"for",
"tips",
"."
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/tips.rb#L24-L29 | valid |
mattmueller/foursquare2 | lib/foursquare2/tips.rb | Foursquare2.Tips.venue_tips | def venue_tips(venue_id, options={})
query = options.delete(:query)
response = connection.get do |req|
req.url "venues/#{venue_id}/tips", options
end
tips = return_error_or_body(response, response.body.response.tips)
tips = Foursquare2.filter(tips, query) if query
tips
end | ruby | def venue_tips(venue_id, options={})
query = options.delete(:query)
response = connection.get do |req|
req.url "venues/#{venue_id}/tips", options
end
tips = return_error_or_body(response, response.body.response.tips)
tips = Foursquare2.filter(tips, query) if query
tips
end | [
"def",
"venue_tips",
"(",
"venue_id",
",",
"options",
"=",
"{",
"}",
")",
"query",
"=",
"options",
".",
"delete",
"(",
":query",
")",
"response",
"=",
"connection",
".",
"get",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"venues/#{venue_id}/tips\"",
",",... | Search for tips from a venue.
@param [String] venue_id - Venue id to flag, required.
@param [Hash] options
@option options String :sort [recent] One of recent or popular.
@option options Integer :limit [100] Number of results to return, up to 500.
@option options Integer :offset [100] Used to page through results
@option options String :query - Only find tips matching this term. | [
"Search",
"for",
"tips",
"from",
"a",
"venue",
"."
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/tips.rb#L40-L48 | valid |
mattmueller/foursquare2 | lib/foursquare2/tips.rb | Foursquare2.Tips.add_tip | def add_tip(options={})
response = connection.post do |req|
req.url "tips/add", options
end
return_error_or_body(response, response.body.response.tip)
end | ruby | def add_tip(options={})
response = connection.post do |req|
req.url "tips/add", options
end
return_error_or_body(response, response.body.response.tip)
end | [
"def",
"add_tip",
"(",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"post",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"tips/add\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"response",
",",
"response",
".",
"body",
".",... | Add a tip
@param [Hash] options
@option options String :venueId - Required, which venue to add the tip to.
@option options String :text - The text of the tip.
@option options String :url - Optionally associated url. | [
"Add",
"a",
"tip"
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/tips.rb#L57-L62 | valid |
mattmueller/foursquare2 | lib/foursquare2/tips.rb | Foursquare2.Tips.mark_tip_todo | def mark_tip_todo(tip_id, options={})
response = connection.post do |req|
req.url "tips/#{tip_id}/marktodo", options
end
return_error_or_body(response, response.body.response)
end | ruby | def mark_tip_todo(tip_id, options={})
response = connection.post do |req|
req.url "tips/#{tip_id}/marktodo", options
end
return_error_or_body(response, response.body.response)
end | [
"def",
"mark_tip_todo",
"(",
"tip_id",
",",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"post",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"tips/#{tip_id}/marktodo\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"response",
",... | Mark a tip todo for the authenticated user.
param [String] tip_id - The id of the tip to mark. | [
"Mark",
"a",
"tip",
"todo",
"for",
"the",
"authenticated",
"user",
"."
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/tips.rb#L68-L73 | valid |
mattmueller/foursquare2 | lib/foursquare2/events.rb | Foursquare2.Events.event | def event(event_id, options={})
response = connection.get do |req|
req.url "events/#{event_id}", options
end
return_error_or_body(response, response.body.response.event)
end | ruby | def event(event_id, options={})
response = connection.get do |req|
req.url "events/#{event_id}", options
end
return_error_or_body(response, response.body.response.event)
end | [
"def",
"event",
"(",
"event_id",
",",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"get",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"events/#{event_id}\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"response",
",",
"respon... | Retrieve information about an event
param [String] event_id The ID of the event | [
"Retrieve",
"information",
"about",
"an",
"event"
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/events.rb#L8-L13 | valid |
mattmueller/foursquare2 | lib/foursquare2/campaigns.rb | Foursquare2.Campaigns.campaign | def campaign(campaign_id, options={})
response = connection.get do |req|
req.url "campaigns/#{campaign_id}", options
end
return_error_or_body(response, response.body.response.campaign)
end | ruby | def campaign(campaign_id, options={})
response = connection.get do |req|
req.url "campaigns/#{campaign_id}", options
end
return_error_or_body(response, response.body.response.campaign)
end | [
"def",
"campaign",
"(",
"campaign_id",
",",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"get",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"campaigns/#{campaign_id}\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"response",
",... | Retrieve information about a campaign
param [String] campaign_id The ID of the venue | [
"Retrieve",
"information",
"about",
"a",
"campaign"
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/campaigns.rb#L7-L12 | valid |
mattmueller/foursquare2 | lib/foursquare2/client.rb | Foursquare2.Client.connection | def connection
params = {}
params[:client_id] = @client_id if @client_id
params[:client_secret] = @client_secret if @client_secret
params[:oauth_token] = @oauth_token if @oauth_token
params[:v] = @api_version if @api_version
params[:locale] = @locale if @locale
@connection ||= Faraday::Connection.new(:url => api_url, :ssl => @ssl, :params => params, :headers => default_headers) do |builder|
@connection_middleware.each do |middleware|
builder.use *middleware
end
builder.adapter Faraday.default_adapter
end
end | ruby | def connection
params = {}
params[:client_id] = @client_id if @client_id
params[:client_secret] = @client_secret if @client_secret
params[:oauth_token] = @oauth_token if @oauth_token
params[:v] = @api_version if @api_version
params[:locale] = @locale if @locale
@connection ||= Faraday::Connection.new(:url => api_url, :ssl => @ssl, :params => params, :headers => default_headers) do |builder|
@connection_middleware.each do |middleware|
builder.use *middleware
end
builder.adapter Faraday.default_adapter
end
end | [
"def",
"connection",
"params",
"=",
"{",
"}",
"params",
"[",
":client_id",
"]",
"=",
"@client_id",
"if",
"@client_id",
"params",
"[",
":client_secret",
"]",
"=",
"@client_secret",
"if",
"@client_secret",
"params",
"[",
":oauth_token",
"]",
"=",
"@oauth_token",
... | Sets up the connection to be used for all requests based on options passed during initialization. | [
"Sets",
"up",
"the",
"connection",
"to",
"be",
"used",
"for",
"all",
"requests",
"based",
"on",
"options",
"passed",
"during",
"initialization",
"."
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/client.rb#L58-L71 | valid |
mattmueller/foursquare2 | lib/foursquare2/client.rb | Foursquare2.Client.return_error_or_body | def return_error_or_body(response, response_body)
if response.body['meta'].code == 200
response_body
else
raise Foursquare2::APIError.new(response.body['meta'], response.body['response'])
end
end | ruby | def return_error_or_body(response, response_body)
if response.body['meta'].code == 200
response_body
else
raise Foursquare2::APIError.new(response.body['meta'], response.body['response'])
end
end | [
"def",
"return_error_or_body",
"(",
"response",
",",
"response_body",
")",
"if",
"response",
".",
"body",
"[",
"'meta'",
"]",
".",
"code",
"==",
"200",
"response_body",
"else",
"raise",
"Foursquare2",
"::",
"APIError",
".",
"new",
"(",
"response",
".",
"body... | Helper method to return errors or desired response data as appropriate.
Added just for convenience to avoid having to traverse farther down the response just to get to returned data. | [
"Helper",
"method",
"to",
"return",
"errors",
"or",
"desired",
"response",
"data",
"as",
"appropriate",
"."
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/client.rb#L83-L89 | valid |
mattmueller/foursquare2 | lib/foursquare2/checkins.rb | Foursquare2.Checkins.checkin | def checkin(checkin_id, options={})
response = connection.get do |req|
req.url "checkins/#{checkin_id}", options
end
return_error_or_body(response, response.body.response.checkin)
end | ruby | def checkin(checkin_id, options={})
response = connection.get do |req|
req.url "checkins/#{checkin_id}", options
end
return_error_or_body(response, response.body.response.checkin)
end | [
"def",
"checkin",
"(",
"checkin_id",
",",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"get",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"checkins/#{checkin_id}\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"response",
",",
... | Retrive information about a single checkin.
@param [String] checkin_id the ID of the checkin.
@param [Hash] options
@option options String :signature - Signature allowing users to bypass the friends-only access check on checkins | [
"Retrive",
"information",
"about",
"a",
"single",
"checkin",
"."
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/checkins.rb#L10-L15 | valid |
mattmueller/foursquare2 | lib/foursquare2/checkins.rb | Foursquare2.Checkins.recent_checkins | def recent_checkins(options={})
response = connection.get do |req|
req.url "checkins/recent", options
end
return_error_or_body(response, response.body.response.recent)
end | ruby | def recent_checkins(options={})
response = connection.get do |req|
req.url "checkins/recent", options
end
return_error_or_body(response, response.body.response.recent)
end | [
"def",
"recent_checkins",
"(",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"get",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"checkins/recent\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"response",
",",
"response",
".",
... | Retrive a list of recent checkins from friends.
@param [Hash] options
@option options String :ll - Latitude and longitude in format LAT,LON
@option options String :limit - Maximum results to return (max 100)
@option options Integer :afterTimestamp - Seconds after which to look for checkins | [
"Retrive",
"a",
"list",
"of",
"recent",
"checkins",
"from",
"friends",
"."
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/checkins.rb#L24-L29 | valid |
mattmueller/foursquare2 | lib/foursquare2/checkins.rb | Foursquare2.Checkins.add_checkin | def add_checkin(options={})
response = connection.post do |req|
req.url "checkins/add", options
end
return_error_or_body(response, response.body.response.checkin)
end | ruby | def add_checkin(options={})
response = connection.post do |req|
req.url "checkins/add", options
end
return_error_or_body(response, response.body.response.checkin)
end | [
"def",
"add_checkin",
"(",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"post",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"checkins/add\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"response",
",",
"response",
".",
"body"... | Checkin on behalf of the user.
@param [Hash] options
@option options String :venueId - Venue for the checkin.
@option options String :venue - For venueless checkins (name or other identifier)
@option options String :shout - Message to be included with the checkin.
@option options String :broadcast - Required, one or more of private,public,facebook,twitter. Comma-separated.
@option options String :ll - Latitude and longitude in format LAT,LON
@option options Integer :llAcc - Accuracy of the lat/lon in meters.
@option options Integer :alt - Altitude in meters
@option options Integer :altAcc - Accuracy of the altitude in meters | [
"Checkin",
"on",
"behalf",
"of",
"the",
"user",
"."
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/checkins.rb#L43-L48 | valid |
mattmueller/foursquare2 | lib/foursquare2/checkins.rb | Foursquare2.Checkins.add_checkin_comment | def add_checkin_comment(checkin_id, options={})
response = connection.post do |req|
req.url "checkins/#{checkin_id}/addcomment", options
end
return_error_or_body(response, response.body.response)
end | ruby | def add_checkin_comment(checkin_id, options={})
response = connection.post do |req|
req.url "checkins/#{checkin_id}/addcomment", options
end
return_error_or_body(response, response.body.response)
end | [
"def",
"add_checkin_comment",
"(",
"checkin_id",
",",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"post",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"checkins/#{checkin_id}/addcomment\"",
",",
"options",
"end",
"return_error_or_body",
"("... | Add a comment to a checkin.
@param [String] checkin_id the ID of the checkin.
@param [Hash] options
@option options String :text - Text of the comment to add, 200 character max. | [
"Add",
"a",
"comment",
"to",
"a",
"checkin",
"."
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/checkins.rb#L56-L61 | valid |
mattmueller/foursquare2 | lib/foursquare2/checkins.rb | Foursquare2.Checkins.add_checkin_reply | def add_checkin_reply(checkin_id, options={})
response = connection.post do |req|
req.url "checkins/#{checkin_id}/reply", options
end
return_error_or_body(response, response.body.response.reply)
end | ruby | def add_checkin_reply(checkin_id, options={})
response = connection.post do |req|
req.url "checkins/#{checkin_id}/reply", options
end
return_error_or_body(response, response.body.response.reply)
end | [
"def",
"add_checkin_reply",
"(",
"checkin_id",
",",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"post",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"checkins/#{checkin_id}/reply\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"re... | Add a reply to a checkin.
@param [String] checkin_id the ID of the checkin.
@param [Hash] options
@option options String :text - The text of the post, up to 200 characters.
@option options String :url - Link for more details. This page will be opened in an embedded web view in the foursquare application, unless contentId is specified and a native link handler is registered and present. We support the following URL schemes: http, https, foursquare, mailto, tel, and sms.
@option options String :contentId - Identifier for the post to be used in a native link, up to 50 characters. A url must also be specified in the request. | [
"Add",
"a",
"reply",
"to",
"a",
"checkin",
"."
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/checkins.rb#L99-L104 | valid |
mattmueller/foursquare2 | lib/foursquare2/venuegroups.rb | Foursquare2.Venuegroups.venuegroup | def venuegroup(group_id, options={})
response = connection.get do |req|
req.url "venuegroups/#{group_id}", options
end
return_error_or_body(response, response.body.response.venueGroup)
end | ruby | def venuegroup(group_id, options={})
response = connection.get do |req|
req.url "venuegroups/#{group_id}", options
end
return_error_or_body(response, response.body.response.venueGroup)
end | [
"def",
"venuegroup",
"(",
"group_id",
",",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"get",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"venuegroups/#{group_id}\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"response",
",",... | Retrieve information about a venuegroup
param [String] group_id The ID of the venuegroup | [
"Retrieve",
"information",
"about",
"a",
"venuegroup"
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/venuegroups.rb#L8-L13 | valid |
mattmueller/foursquare2 | lib/foursquare2/venuegroups.rb | Foursquare2.Venuegroups.add_venuegroup | def add_venuegroup(options={})
response = connection.post do |req|
req.url "venuegroups/add", options
end
return_error_or_body(response, response.body.response.venueGroup)
end | ruby | def add_venuegroup(options={})
response = connection.post do |req|
req.url "venuegroups/add", options
end
return_error_or_body(response, response.body.response.venueGroup)
end | [
"def",
"add_venuegroup",
"(",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"post",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"venuegroups/add\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"response",
",",
"response",
".",
... | Create a venue group. If the venueId parameter is specified,
then the endpoint will add the specified venues to the venue group.
If it is not possible to add all of the specified venues to the group,
then creation of the venue group will fail entirely.
@param [Hash] options
@option options String :name - Required. The name to give the group.
@option options String :venueId - Comma-delimited list of venue IDs to add to the group. If this parameter is not specified, then the venue group will initially be empty. | [
"Create",
"a",
"venue",
"group",
".",
"If",
"the",
"venueId",
"parameter",
"is",
"specified",
"then",
"the",
"endpoint",
"will",
"add",
"the",
"specified",
"venues",
"to",
"the",
"venue",
"group",
".",
"If",
"it",
"is",
"not",
"possible",
"to",
"add",
"a... | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/venuegroups.rb#L23-L28 | valid |
mattmueller/foursquare2 | lib/foursquare2/venuegroups.rb | Foursquare2.Venuegroups.venuegroup_update | def venuegroup_update(group_id, options={})
response = connection.post do |req|
req.url "venuegroups/#{group_id}/update", options
end
return_error_or_body(response, response.body.response.venueGroup)
end | ruby | def venuegroup_update(group_id, options={})
response = connection.post do |req|
req.url "venuegroups/#{group_id}/update", options
end
return_error_or_body(response, response.body.response.venueGroup)
end | [
"def",
"venuegroup_update",
"(",
"group_id",
",",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"post",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"venuegroups/#{group_id}/update\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"re... | Updates a venue group. At least one of the name and venueId parameters must be specified.
@param [String] group_id - required The ID of the venue group to modify
@param [Hash] options
@option options String :name - If specified, the new name to give to the group.
@option options String :venueId - If specified, a comma-delimited list of venue IDs that will become the new set of venue IDs for the group. | [
"Updates",
"a",
"venue",
"group",
".",
"At",
"least",
"one",
"of",
"the",
"name",
"and",
"venueId",
"parameters",
"must",
"be",
"specified",
"."
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/venuegroups.rb#L37-L42 | valid |
mattmueller/foursquare2 | lib/foursquare2/venuegroups.rb | Foursquare2.Venuegroups.list_venuegroup | def list_venuegroup(options={})
response = connection.get do |req|
req.url "venuegroups/list", options
end
return_error_or_body(response, response.body.response.venueGroups)
end | ruby | def list_venuegroup(options={})
response = connection.get do |req|
req.url "venuegroups/list", options
end
return_error_or_body(response, response.body.response.venueGroups)
end | [
"def",
"list_venuegroup",
"(",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"get",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"venuegroups/list\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"response",
",",
"response",
".",
... | List all venue groups owned by the user. | [
"List",
"all",
"venue",
"groups",
"owned",
"by",
"the",
"user",
"."
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/venuegroups.rb#L46-L51 | valid |
mattmueller/foursquare2 | lib/foursquare2/specials.rb | Foursquare2.Specials.special | def special(special_id, options={})
response = connection.get do |req|
req.url "specials/#{special_id}", options
end
return_error_or_body(response, response.body.response.special)
end | ruby | def special(special_id, options={})
response = connection.get do |req|
req.url "specials/#{special_id}", options
end
return_error_or_body(response, response.body.response.special)
end | [
"def",
"special",
"(",
"special_id",
",",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"get",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"specials/#{special_id}\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"response",
",",
... | Retrieve information about a special
param [String] special_id The ID of the special | [
"Retrieve",
"information",
"about",
"a",
"special"
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/specials.rb#L8-L13 | valid |
mattmueller/foursquare2 | lib/foursquare2/specials.rb | Foursquare2.Specials.search_specials | def search_specials(options={})
response = connection.get do |req|
req.url "specials/search", options
end
return_error_or_body(response, response.body.response.specials.items)
end | ruby | def search_specials(options={})
response = connection.get do |req|
req.url "specials/search", options
end
return_error_or_body(response, response.body.response.specials.items)
end | [
"def",
"search_specials",
"(",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"get",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"specials/search\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"response",
",",
"response",
".",
... | Search for specials
@param [Hash] options
@option options String :ll - Latitude and longitude in format LAT,LON
@option options Integer :llAcc - Accuracy of the lat/lon in meters.
@option options Integer :alt - Altitude in meters
@option options Integer :altAcc - Accuracy of the altitude in meters
@option options Integer :limit - The limit of results to return. | [
"Search",
"for",
"specials"
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/specials.rb#L24-L29 | valid |
mattmueller/foursquare2 | lib/foursquare2/lists.rb | Foursquare2.Lists.list | def list(list_id, options={})
response = connection.get do |req|
req.url "lists/#{list_id}", options
end
return_error_or_body(response, response.body.response.list)
end | ruby | def list(list_id, options={})
response = connection.get do |req|
req.url "lists/#{list_id}", options
end
return_error_or_body(response, response.body.response.list)
end | [
"def",
"list",
"(",
"list_id",
",",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"get",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"lists/#{list_id}\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"response",
",",
"response",... | Retrieve information about a list.
@param [String] list_id - The id of the list to retrieve.
@param [Hash] options
@option options Integer :limit - Number of results to return, up to 200.
@option options Integer :offset - The number of results to skip. Used to page through results. | [
"Retrieve",
"information",
"about",
"a",
"list",
"."
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/lists.rb#L11-L16 | valid |
mattmueller/foursquare2 | lib/foursquare2/venues.rb | Foursquare2.Venues.trending_venues | def trending_venues(ll, options={})
options[:ll] = ll
response = connection.get do |req|
req.url "venues/trending", options
end
return_error_or_body(response, response.body.response)
end | ruby | def trending_venues(ll, options={})
options[:ll] = ll
response = connection.get do |req|
req.url "venues/trending", options
end
return_error_or_body(response, response.body.response)
end | [
"def",
"trending_venues",
"(",
"ll",
",",
"options",
"=",
"{",
"}",
")",
"options",
"[",
":ll",
"]",
"=",
"ll",
"response",
"=",
"connection",
".",
"get",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"venues/trending\"",
",",
"options",
"end",
"return_e... | Search for trending venues
@param [String] :ll Latitude and longitude in format LAT,LON
@param [Hash] options
@option options Integer :limit - Number of results to return, up to 50.
@option options Integer :radius - Radius in meters, up to approximately 2000 meters. | [
"Search",
"for",
"trending",
"venues"
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/venues.rb#L40-L46 | valid |
mattmueller/foursquare2 | lib/foursquare2/venues.rb | Foursquare2.Venues.search_venues_by_tip | def search_venues_by_tip(options={})
tips = search_tips(options)
venues = []
tips.each do |tip|
venues << tip['venue']
end
venues
end | ruby | def search_venues_by_tip(options={})
tips = search_tips(options)
venues = []
tips.each do |tip|
venues << tip['venue']
end
venues
end | [
"def",
"search_venues_by_tip",
"(",
"options",
"=",
"{",
"}",
")",
"tips",
"=",
"search_tips",
"(",
"options",
")",
"venues",
"=",
"[",
"]",
"tips",
".",
"each",
"do",
"|",
"tip",
"|",
"venues",
"<<",
"tip",
"[",
"'venue'",
"]",
"end",
"venues",
"end... | Search for venues by tip
@param [Hash] options
@option options String :ll - Latitude and longitude in format LAT,LON
@option options Integer :limit - The limit of results to return.
@option options Integer :offset - Used to page through results.
@option options String :filter - Set to 'friends' to limit tips to those from friends.
@option options String :query - Only find tips matching this term. | [
"Search",
"for",
"venues",
"by",
"tip"
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/venues.rb#L57-L64 | valid |
mattmueller/foursquare2 | lib/foursquare2/venues.rb | Foursquare2.Venues.venue_categories | def venue_categories(options={})
response = connection.get do |req|
req.url "venues/categories", options
end
return_error_or_body(response, response.body.response.categories)
end | ruby | def venue_categories(options={})
response = connection.get do |req|
req.url "venues/categories", options
end
return_error_or_body(response, response.body.response.categories)
end | [
"def",
"venue_categories",
"(",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"get",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"venues/categories\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"response",
",",
"response",
".",... | Retrieve information about all venue categories. | [
"Retrieve",
"information",
"about",
"all",
"venue",
"categories",
"."
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/venues.rb#L68-L73 | valid |
mattmueller/foursquare2 | lib/foursquare2/venues.rb | Foursquare2.Venues.venue_links | def venue_links(venue_id, options={})
response = connection.get do |req|
req.url "venues/#{venue_id}/links", options
end
return_error_or_body(response, response.body.response.links)
end | ruby | def venue_links(venue_id, options={})
response = connection.get do |req|
req.url "venues/#{venue_id}/links", options
end
return_error_or_body(response, response.body.response.links)
end | [
"def",
"venue_links",
"(",
"venue_id",
",",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"get",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"venues/#{venue_id}/links\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"response",
",... | Retrieve links for a venue.
param [String] venue_id The ID of the venue | [
"Retrieve",
"links",
"for",
"a",
"venue",
"."
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/venues.rb#L79-L84 | valid |
mattmueller/foursquare2 | lib/foursquare2/venues.rb | Foursquare2.Venues.add_venue | def add_venue(options={})
response = connection.post do |req|
req.url "venues/add", options
end
return_error_or_body(response, response.body.response.venue)
end | ruby | def add_venue(options={})
response = connection.post do |req|
req.url "venues/add", options
end
return_error_or_body(response, response.body.response.venue)
end | [
"def",
"add_venue",
"(",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"post",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"venues/add\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"response",
",",
"response",
".",
"body",
... | Add a venue
@param [Hash] options
@option options String :name - Name of the venue (required)
@option options String :address
@option options String :crossStreet
@option options String :city
@option options String :state
@option options String :zip
@option options String :phone
@option options String :ll - Latitude and longitude in format LAT,LON
@option options String :primaryCategoryId - Main category for the venue, must be in the list of venue categories. | [
"Add",
"a",
"venue"
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/venues.rb#L98-L103 | valid |
mattmueller/foursquare2 | lib/foursquare2/venues.rb | Foursquare2.Venues.mark_venue_todo | def mark_venue_todo(venue_id, options={})
response = connection.post do |req|
req.url "venues/#{venue_id}/marktodo", options
end
return_error_or_body(response, response.body.response)
end | ruby | def mark_venue_todo(venue_id, options={})
response = connection.post do |req|
req.url "venues/#{venue_id}/marktodo", options
end
return_error_or_body(response, response.body.response)
end | [
"def",
"mark_venue_todo",
"(",
"venue_id",
",",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"post",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"venues/#{venue_id}/marktodo\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"respons... | Mark a venue as todo for the authenticated user
@param [String] venue_id - Venue id to mark todo, required.
@param [Hash] options
@option options String :text - Text for the tip/todo | [
"Mark",
"a",
"venue",
"as",
"todo",
"for",
"the",
"authenticated",
"user"
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/venues.rb#L111-L116 | valid |
mattmueller/foursquare2 | lib/foursquare2/venues.rb | Foursquare2.Venues.suggest_completion_venues | def suggest_completion_venues(options={})
response = connection.get do |req|
req.url "venues/suggestCompletion", options
end
return_error_or_body(response, response.body.response)
end | ruby | def suggest_completion_venues(options={})
response = connection.get do |req|
req.url "venues/suggestCompletion", options
end
return_error_or_body(response, response.body.response)
end | [
"def",
"suggest_completion_venues",
"(",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"get",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"venues/suggestCompletion\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"response",
",",
"r... | Suggest venue completions. Returns a list of mini-venues partially matching the search term, near the location.
@param [Hash] options
@option options String :ll - Latitude and longitude in format LAT,LON
@option options Integer :llAcc - Accuracy of the lat/lon in meters.
@option options Integer :alt - Altitude in meters
@option options Integer :altAcc - Accuracy of the altitude in meters
@option options String :query - Query to match venues on.
@option options Integer :limit - The limit of results to return. | [
"Suggest",
"venue",
"completions",
".",
"Returns",
"a",
"list",
"of",
"mini",
"-",
"venues",
"partially",
"matching",
"the",
"search",
"term",
"near",
"the",
"location",
"."
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/venues.rb#L208-L213 | valid |
mattmueller/foursquare2 | lib/foursquare2/venues.rb | Foursquare2.Venues.venue_menus | def venue_menus(venue_id, options={})
response = connection.get do |req|
req.url "venues/#{venue_id}/menu", options
end
return_error_or_body(response, response.body.response)
end | ruby | def venue_menus(venue_id, options={})
response = connection.get do |req|
req.url "venues/#{venue_id}/menu", options
end
return_error_or_body(response, response.body.response)
end | [
"def",
"venue_menus",
"(",
"venue_id",
",",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"get",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"venues/#{venue_id}/menu\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"response",
","... | Retrieve menus for a venue.
param [String] venue_id The ID of the venue | [
"Retrieve",
"menus",
"for",
"a",
"venue",
"."
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/venues.rb#L219-L224 | valid |
mattmueller/foursquare2 | lib/foursquare2/venues.rb | Foursquare2.Venues.venues_timeseries | def venues_timeseries(options={})
options[:venueId] = options[:venueId].join(',') # Transforms the array into a 'comma-separated list' of ids.
response = connection.get do |req|
req.url "venues/timeseries", options
end
return_error_or_body(response, response.body.response)
end | ruby | def venues_timeseries(options={})
options[:venueId] = options[:venueId].join(',') # Transforms the array into a 'comma-separated list' of ids.
response = connection.get do |req|
req.url "venues/timeseries", options
end
return_error_or_body(response, response.body.response)
end | [
"def",
"venues_timeseries",
"(",
"options",
"=",
"{",
"}",
")",
"options",
"[",
":venueId",
"]",
"=",
"options",
"[",
":venueId",
"]",
".",
"join",
"(",
"','",
")",
"response",
"=",
"connection",
".",
"get",
"do",
"|",
"req",
"|",
"req",
".",
"url",
... | Get daily venue stats for a list of venues over a time range.
Client instance should represent an OAuth user who is the venues owner.
@param [Hash] options
@option options Array[String] :venueId - A list of venue ids to retrieve series data for.
@option options Integer :startAt - Required. The start of the time range to retrieve stats for (seconds since epoch).
@option options Integer :endAt - The end of the time range to retrieve stats for (seconds since epoch). If omitted, the current time is assumed.
@option options String :fields - Specifies which fields to return. May be one or more of totalCheckins, newCheckins, uniqueVisitors, sharing, genders, ages, hours, separated by commas. | [
"Get",
"daily",
"venue",
"stats",
"for",
"a",
"list",
"of",
"venues",
"over",
"a",
"time",
"range",
".",
"Client",
"instance",
"should",
"represent",
"an",
"OAuth",
"user",
"who",
"is",
"the",
"venues",
"owner",
"."
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/venues.rb#L276-L282 | valid |
mattmueller/foursquare2 | lib/foursquare2/settings.rb | Foursquare2.Settings.update_setting | def update_setting(setting, value, options={})
response = connection.post do |req|
req.url "settings/#{setting}/set", {:value => value}.merge(options)
end
return_error_or_body(response, response.body.response)
end | ruby | def update_setting(setting, value, options={})
response = connection.post do |req|
req.url "settings/#{setting}/set", {:value => value}.merge(options)
end
return_error_or_body(response, response.body.response)
end | [
"def",
"update_setting",
"(",
"setting",
",",
"value",
",",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"post",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"settings/#{setting}/set\"",
",",
"{",
":value",
"=>",
"value",
"}",
".",
... | Update a single setting for the authenticated user.
@param [String] setting - The name of the setting to update, one of sendtotwitter, sendtofacebook, pings.
@param [String] value - One of '1','0' | [
"Update",
"a",
"single",
"setting",
"for",
"the",
"authenticated",
"user",
"."
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/settings.rb#L29-L34 | valid |
mattmueller/foursquare2 | lib/foursquare2/photos.rb | Foursquare2.Photos.photo | def photo(photo_id, options={})
response = connection.get do |req|
req.url "photos/#{photo_id}", options
end
return_error_or_body(response, response.body.response.photo)
end | ruby | def photo(photo_id, options={})
response = connection.get do |req|
req.url "photos/#{photo_id}", options
end
return_error_or_body(response, response.body.response.photo)
end | [
"def",
"photo",
"(",
"photo_id",
",",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"get",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"photos/#{photo_id}\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"response",
",",
"respon... | Retrieve a photo
@params [String] photo_id - The ID of the photo | [
"Retrieve",
"a",
"photo"
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/photos.rb#L8-L13 | valid |
mattmueller/foursquare2 | lib/foursquare2/photos.rb | Foursquare2.Photos.add_photo | def add_photo(options={})
response = connection.post('photos/add', options)
return_error_or_body(response, response.body.response.photo)
end | ruby | def add_photo(options={})
response = connection.post('photos/add', options)
return_error_or_body(response, response.body.response.photo)
end | [
"def",
"add_photo",
"(",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"post",
"(",
"'photos/add'",
",",
"options",
")",
"return_error_or_body",
"(",
"response",
",",
"response",
".",
"body",
".",
"response",
".",
"photo",
")",
"end"
] | Add a photo
@param [Hash] options
@option options UploadIO :photo - the photo. Like Faraday::UploadIO.new('pic_path', 'image/jpeg')
@option options String :checkinId - the ID of a checkin owned by the user
@option options String :tipId - the ID of a tip owned by the user
@option options String :venueId - the ID of a venue
@option options String :broadcast - Required, one or more of private,public,facebook,twitter. Comma-separated.
@option options String :ll - Latitude and longitude in format LAT,LON
@option options Integer :llAcc - Accuracy of the lat/lon in meters.
@option options Integer :alt - Altitude in meters
@option options Integer :altAcc - Accuracy of the altitude in meters | [
"Add",
"a",
"photo"
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/photos.rb#L27-L30 | valid |
mattmueller/foursquare2 | lib/foursquare2/photos.rb | Foursquare2.Photos.venue_photos | def venue_photos(venue_id, options = {:group => 'venue'})
response = connection.get do |req|
req.url "venues/#{venue_id}/photos", options
end
return_error_or_body(response, response.body.response.photos)
end | ruby | def venue_photos(venue_id, options = {:group => 'venue'})
response = connection.get do |req|
req.url "venues/#{venue_id}/photos", options
end
return_error_or_body(response, response.body.response.photos)
end | [
"def",
"venue_photos",
"(",
"venue_id",
",",
"options",
"=",
"{",
":group",
"=>",
"'venue'",
"}",
")",
"response",
"=",
"connection",
".",
"get",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"venues/#{venue_id}/photos\"",
",",
"options",
"end",
"return_error_... | Retrieve photos for a venue
@params [String] venue_id - The ID of the venue
@param [Hash] options
@option options String :group - Pass checkin for photos added by friends (including on their recent checkins). Pass venue for public photos added to the venue by non-friends. Use multi to fetch both. Default - venue
@option options Integer :limit - Number of results to return, up to 500.
@option options Integer :offset - Used to page through results. | [
"Retrieve",
"photos",
"for",
"a",
"venue"
] | 0affc7d4bd5a3aea51e16782def38f589d16e60a | https://github.com/mattmueller/foursquare2/blob/0affc7d4bd5a3aea51e16782def38f589d16e60a/lib/foursquare2/photos.rb#L39-L44 | valid |
modernistik/parse-stack | lib/parse/model/associations/collection_proxy.rb | Parse.CollectionProxy.forward | def forward(method, params = nil)
return unless @delegate && @delegate.respond_to?(method)
params.nil? ? @delegate.send(method) : @delegate.send(method, params)
end | ruby | def forward(method, params = nil)
return unless @delegate && @delegate.respond_to?(method)
params.nil? ? @delegate.send(method) : @delegate.send(method, params)
end | [
"def",
"forward",
"(",
"method",
",",
"params",
"=",
"nil",
")",
"return",
"unless",
"@delegate",
"&&",
"@delegate",
".",
"respond_to?",
"(",
"method",
")",
"params",
".",
"nil?",
"?",
"@delegate",
".",
"send",
"(",
"method",
")",
":",
"@delegate",
".",
... | Forward a method call to the delegate.
@param method [Symbol] the name of the method to forward
@param params [Object] method parameters
@return [Object] the return value from the forwarded method. | [
"Forward",
"a",
"method",
"call",
"to",
"the",
"delegate",
"."
] | 23730f8faa20ff90d994cdb5771096c9a9a5bdff | https://github.com/modernistik/parse-stack/blob/23730f8faa20ff90d994cdb5771096c9a9a5bdff/lib/parse/model/associations/collection_proxy.rb#L78-L81 | valid |
modernistik/parse-stack | lib/parse/model/associations/collection_proxy.rb | Parse.CollectionProxy.add | def add(*items)
notify_will_change! if items.count > 0
items.each do |item|
collection.push item
end
@collection
end | ruby | def add(*items)
notify_will_change! if items.count > 0
items.each do |item|
collection.push item
end
@collection
end | [
"def",
"add",
"(",
"*",
"items",
")",
"notify_will_change!",
"if",
"items",
".",
"count",
">",
"0",
"items",
".",
"each",
"do",
"|",
"item",
"|",
"collection",
".",
"push",
"item",
"end",
"@collection",
"end"
] | Add items to the collection
@param items [Array] items to add | [
"Add",
"items",
"to",
"the",
"collection"
] | 23730f8faa20ff90d994cdb5771096c9a9a5bdff | https://github.com/modernistik/parse-stack/blob/23730f8faa20ff90d994cdb5771096c9a9a5bdff/lib/parse/model/associations/collection_proxy.rb#L143-L149 | valid |
modernistik/parse-stack | lib/parse/model/associations/collection_proxy.rb | Parse.CollectionProxy.<< | def <<(*list)
if list.count > 0
notify_will_change!
list.flatten.each { |e| collection.push(e) }
end
end | ruby | def <<(*list)
if list.count > 0
notify_will_change!
list.flatten.each { |e| collection.push(e) }
end
end | [
"def",
"<<",
"(",
"*",
"list",
")",
"if",
"list",
".",
"count",
">",
"0",
"notify_will_change!",
"list",
".",
"flatten",
".",
"each",
"{",
"|",
"e",
"|",
"collection",
".",
"push",
"(",
"e",
")",
"}",
"end",
"end"
] | Append items to the collection | [
"Append",
"items",
"to",
"the",
"collection"
] | 23730f8faa20ff90d994cdb5771096c9a9a5bdff | https://github.com/modernistik/parse-stack/blob/23730f8faa20ff90d994cdb5771096c9a9a5bdff/lib/parse/model/associations/collection_proxy.rb#L314-L319 | valid |
modernistik/parse-stack | lib/parse/model/core/properties.rb | Parse.Properties.format_value | def format_value(key, val, data_type = nil)
# if data_type wasn't passed, then get the data_type from the fields hash
data_type ||= self.fields[key]
val = format_operation(key, val, data_type)
case data_type
when :object
val = val.with_indifferent_access if val.is_a?(Hash)
when :array
# All "array" types use a collection proxy
val = val.to_a if val.is_a?(Parse::CollectionProxy) #all objects must be in array form
val = [val] unless val.is_a?(Array) #all objects must be in array form
val.compact! #remove any nil
val = Parse::CollectionProxy.new val, delegate: self, key: key
when :geopoint
val = Parse::GeoPoint.new(val) unless val.blank?
when :file
val = Parse::File.new(val) unless val.blank?
when :bytes
val = Parse::Bytes.new(val) unless val.blank?
when :integer
if val.nil? || val.respond_to?(:to_i) == false
val = nil
else
val = val.to_i
end
when :boolean
if val.nil?
val = nil
else
val = val ? true : false
end
when :string
val = val.to_s unless val.blank?
when :float
val = val.to_f unless val.blank?
when :acl
# ACL types go through a special conversion
val = ACL.typecast(val, self)
when :date
# if it respond to parse_date, then use that as the conversion.
if val.respond_to?(:parse_date) && val.is_a?(Parse::Date) == false
val = val.parse_date
# if the value is a hash, then it may be the Parse hash format for an iso date.
elsif val.is_a?(Hash) # val.respond_to?(:iso8601)
val = Parse::Date.parse(val["iso"] || val[:iso])
elsif val.is_a?(String)
# if it's a string, try parsing the date
val = Parse::Date.parse val
#elsif val.present?
# pus "[Parse::Stack] Invalid date value '#{val}' assigned to #{self.class}##{key}, it should be a Parse::Date or DateTime."
# raise ValueError, "Invalid date value '#{val}' assigned to #{self.class}##{key}, it should be a Parse::Date or DateTime."
end
when :timezone
val = Parse::TimeZone.new(val) if val.present?
else
# You can provide a specific class instead of a symbol format
if data_type.respond_to?(:typecast)
val = data_type.typecast(val)
else
warn "Property :#{key}: :#{data_type} has no valid data type"
val = val #default
end
end
val
end | ruby | def format_value(key, val, data_type = nil)
# if data_type wasn't passed, then get the data_type from the fields hash
data_type ||= self.fields[key]
val = format_operation(key, val, data_type)
case data_type
when :object
val = val.with_indifferent_access if val.is_a?(Hash)
when :array
# All "array" types use a collection proxy
val = val.to_a if val.is_a?(Parse::CollectionProxy) #all objects must be in array form
val = [val] unless val.is_a?(Array) #all objects must be in array form
val.compact! #remove any nil
val = Parse::CollectionProxy.new val, delegate: self, key: key
when :geopoint
val = Parse::GeoPoint.new(val) unless val.blank?
when :file
val = Parse::File.new(val) unless val.blank?
when :bytes
val = Parse::Bytes.new(val) unless val.blank?
when :integer
if val.nil? || val.respond_to?(:to_i) == false
val = nil
else
val = val.to_i
end
when :boolean
if val.nil?
val = nil
else
val = val ? true : false
end
when :string
val = val.to_s unless val.blank?
when :float
val = val.to_f unless val.blank?
when :acl
# ACL types go through a special conversion
val = ACL.typecast(val, self)
when :date
# if it respond to parse_date, then use that as the conversion.
if val.respond_to?(:parse_date) && val.is_a?(Parse::Date) == false
val = val.parse_date
# if the value is a hash, then it may be the Parse hash format for an iso date.
elsif val.is_a?(Hash) # val.respond_to?(:iso8601)
val = Parse::Date.parse(val["iso"] || val[:iso])
elsif val.is_a?(String)
# if it's a string, try parsing the date
val = Parse::Date.parse val
#elsif val.present?
# pus "[Parse::Stack] Invalid date value '#{val}' assigned to #{self.class}##{key}, it should be a Parse::Date or DateTime."
# raise ValueError, "Invalid date value '#{val}' assigned to #{self.class}##{key}, it should be a Parse::Date or DateTime."
end
when :timezone
val = Parse::TimeZone.new(val) if val.present?
else
# You can provide a specific class instead of a symbol format
if data_type.respond_to?(:typecast)
val = data_type.typecast(val)
else
warn "Property :#{key}: :#{data_type} has no valid data type"
val = val #default
end
end
val
end | [
"def",
"format_value",
"(",
"key",
",",
"val",
",",
"data_type",
"=",
"nil",
")",
"data_type",
"||=",
"self",
".",
"fields",
"[",
"key",
"]",
"val",
"=",
"format_operation",
"(",
"key",
",",
"val",
",",
"data_type",
")",
"case",
"data_type",
"when",
":... | this method takes an input value and transforms it to the proper local format
depending on the data type that was set for a particular property key.
Return the internal representation of a property value for a given data type.
@param key [Symbol] the name of the property
@param val [Object] the value to format.
@param data_type [Symbol] provide a hint to the data_type of this value.
@return [Object] | [
"this",
"method",
"takes",
"an",
"input",
"value",
"and",
"transforms",
"it",
"to",
"the",
"proper",
"local",
"format",
"depending",
"on",
"the",
"data",
"type",
"that",
"was",
"set",
"for",
"a",
"particular",
"property",
"key",
".",
"Return",
"the",
"inte... | 23730f8faa20ff90d994cdb5771096c9a9a5bdff | https://github.com/modernistik/parse-stack/blob/23730f8faa20ff90d994cdb5771096c9a9a5bdff/lib/parse/model/core/properties.rb#L549-L615 | valid |
modernistik/parse-stack | lib/parse/model/associations/relation_collection_proxy.rb | Parse.RelationCollectionProxy.all | def all(constraints = {})
q = query( {limit: :max}.merge(constraints) )
if block_given?
# if we have a query, then use the Proc with it (more efficient)
return q.present? ? q.results(&Proc.new) : collection.each(&Proc.new)
end
# if no block given, get all the results
q.present? ? q.results : collection
end | ruby | def all(constraints = {})
q = query( {limit: :max}.merge(constraints) )
if block_given?
# if we have a query, then use the Proc with it (more efficient)
return q.present? ? q.results(&Proc.new) : collection.each(&Proc.new)
end
# if no block given, get all the results
q.present? ? q.results : collection
end | [
"def",
"all",
"(",
"constraints",
"=",
"{",
"}",
")",
"q",
"=",
"query",
"(",
"{",
"limit",
":",
":max",
"}",
".",
"merge",
"(",
"constraints",
")",
")",
"if",
"block_given?",
"return",
"q",
".",
"present?",
"?",
"q",
".",
"results",
"(",
"&",
"P... | You can get items within the collection relation filtered by a specific set
of query constraints. | [
"You",
"can",
"get",
"items",
"within",
"the",
"collection",
"relation",
"filtered",
"by",
"a",
"specific",
"set",
"of",
"query",
"constraints",
"."
] | 23730f8faa20ff90d994cdb5771096c9a9a5bdff | https://github.com/modernistik/parse-stack/blob/23730f8faa20ff90d994cdb5771096c9a9a5bdff/lib/parse/model/associations/relation_collection_proxy.rb#L57-L65 | valid |
modernistik/parse-stack | lib/parse/model/object.rb | Parse.Object.twin | def twin
h = self.as_json
h.delete(Parse::Model::OBJECT_ID)
h.delete(:objectId)
h.delete(:id)
self.class.new h
end | ruby | def twin
h = self.as_json
h.delete(Parse::Model::OBJECT_ID)
h.delete(:objectId)
h.delete(:id)
self.class.new h
end | [
"def",
"twin",
"h",
"=",
"self",
".",
"as_json",
"h",
".",
"delete",
"(",
"Parse",
"::",
"Model",
"::",
"OBJECT_ID",
")",
"h",
".",
"delete",
"(",
":objectId",
")",
"h",
".",
"delete",
"(",
":id",
")",
"self",
".",
"class",
".",
"new",
"h",
"end"... | This method creates a new object of the same instance type with a copy of
all the properties of the current instance. This is useful when you want
to create a duplicate record.
@return [Parse::Object] a twin copy of the object without the objectId | [
"This",
"method",
"creates",
"a",
"new",
"object",
"of",
"the",
"same",
"instance",
"type",
"with",
"a",
"copy",
"of",
"all",
"the",
"properties",
"of",
"the",
"current",
"instance",
".",
"This",
"is",
"useful",
"when",
"you",
"want",
"to",
"create",
"a"... | 23730f8faa20ff90d994cdb5771096c9a9a5bdff | https://github.com/modernistik/parse-stack/blob/23730f8faa20ff90d994cdb5771096c9a9a5bdff/lib/parse/model/object.rb#L428-L434 | valid |
modernistik/parse-stack | lib/parse/model/file.rb | Parse.File.save | def save
unless saved? || @contents.nil? || @name.nil?
response = client.create_file(@name, @contents, @mime_type)
unless response.error?
result = response.result
@name = result[FIELD_NAME] || File.basename(result[FIELD_URL])
@url = result[FIELD_URL]
end
end
saved?
end | ruby | def save
unless saved? || @contents.nil? || @name.nil?
response = client.create_file(@name, @contents, @mime_type)
unless response.error?
result = response.result
@name = result[FIELD_NAME] || File.basename(result[FIELD_URL])
@url = result[FIELD_URL]
end
end
saved?
end | [
"def",
"save",
"unless",
"saved?",
"||",
"@contents",
".",
"nil?",
"||",
"@name",
".",
"nil?",
"response",
"=",
"client",
".",
"create_file",
"(",
"@name",
",",
"@contents",
",",
"@mime_type",
")",
"unless",
"response",
".",
"error?",
"result",
"=",
"respo... | Save the file by uploading it to Parse and creating a file pointer.
@return [Boolean] true if successfully uploaded and saved. | [
"Save",
"the",
"file",
"by",
"uploading",
"it",
"to",
"Parse",
"and",
"creating",
"a",
"file",
"pointer",
"."
] | 23730f8faa20ff90d994cdb5771096c9a9a5bdff | https://github.com/modernistik/parse-stack/blob/23730f8faa20ff90d994cdb5771096c9a9a5bdff/lib/parse/model/file.rb#L171-L181 | valid |
modernistik/parse-stack | lib/parse/model/push.rb | Parse.Push.where | def where(constraints = nil)
return query.compile_where unless constraints.is_a?(Hash)
query.where constraints
query
end | ruby | def where(constraints = nil)
return query.compile_where unless constraints.is_a?(Hash)
query.where constraints
query
end | [
"def",
"where",
"(",
"constraints",
"=",
"nil",
")",
"return",
"query",
".",
"compile_where",
"unless",
"constraints",
".",
"is_a?",
"(",
"Hash",
")",
"query",
".",
"where",
"constraints",
"query",
"end"
] | Apply a set of constraints.
@param constraints [Hash] the set of {Parse::Query} cosntraints
@return [Hash] if no constraints were passed, returns a compiled query.
@return [Parse::Query] if constraints were passed, returns the chainable query. | [
"Apply",
"a",
"set",
"of",
"constraints",
"."
] | 23730f8faa20ff90d994cdb5771096c9a9a5bdff | https://github.com/modernistik/parse-stack/blob/23730f8faa20ff90d994cdb5771096c9a9a5bdff/lib/parse/model/push.rb#L102-L106 | valid |
modernistik/parse-stack | lib/parse/model/push.rb | Parse.Push.payload | def payload
msg = {
data: {
alert: alert,
badge: badge || "Increment"
}
}
msg[:data][:sound] = sound if sound.present?
msg[:data][:title] = title if title.present?
msg[:data].merge! @data if @data.is_a?(Hash)
if @expiration_time.present?
msg[:expiration_time] = @expiration_time.respond_to?(:iso8601) ? @expiration_time.iso8601(3) : @expiration_time
end
if @push_time.present?
msg[:push_time] = @push_time.respond_to?(:iso8601) ? @push_time.iso8601(3) : @push_time
end
if @expiration_interval.is_a?(Numeric)
msg[:expiration_interval] = @expiration_interval.to_i
end
if query.where.present?
q = @query.dup
if @channels.is_a?(Array) && @channels.empty? == false
q.where :channels.in => @channels
end
msg[:where] = q.compile_where unless q.where.empty?
elsif @channels.is_a?(Array) && @channels.empty? == false
msg[:channels] = @channels
end
msg
end | ruby | def payload
msg = {
data: {
alert: alert,
badge: badge || "Increment"
}
}
msg[:data][:sound] = sound if sound.present?
msg[:data][:title] = title if title.present?
msg[:data].merge! @data if @data.is_a?(Hash)
if @expiration_time.present?
msg[:expiration_time] = @expiration_time.respond_to?(:iso8601) ? @expiration_time.iso8601(3) : @expiration_time
end
if @push_time.present?
msg[:push_time] = @push_time.respond_to?(:iso8601) ? @push_time.iso8601(3) : @push_time
end
if @expiration_interval.is_a?(Numeric)
msg[:expiration_interval] = @expiration_interval.to_i
end
if query.where.present?
q = @query.dup
if @channels.is_a?(Array) && @channels.empty? == false
q.where :channels.in => @channels
end
msg[:where] = q.compile_where unless q.where.empty?
elsif @channels.is_a?(Array) && @channels.empty? == false
msg[:channels] = @channels
end
msg
end | [
"def",
"payload",
"msg",
"=",
"{",
"data",
":",
"{",
"alert",
":",
"alert",
",",
"badge",
":",
"badge",
"||",
"\"Increment\"",
"}",
"}",
"msg",
"[",
":data",
"]",
"[",
":sound",
"]",
"=",
"sound",
"if",
"sound",
".",
"present?",
"msg",
"[",
":data"... | This method takes all the parameters of the instance and creates a proper
hash structure, required by Parse, in order to process the push notification.
@return [Hash] the prepared push payload to be used in the request. | [
"This",
"method",
"takes",
"all",
"the",
"parameters",
"of",
"the",
"instance",
"and",
"creates",
"a",
"proper",
"hash",
"structure",
"required",
"by",
"Parse",
"in",
"order",
"to",
"process",
"the",
"push",
"notification",
"."
] | 23730f8faa20ff90d994cdb5771096c9a9a5bdff | https://github.com/modernistik/parse-stack/blob/23730f8faa20ff90d994cdb5771096c9a9a5bdff/lib/parse/model/push.rb#L133-L166 | valid |
modernistik/parse-stack | lib/parse/model/push.rb | Parse.Push.send | def send(message = nil)
@alert = message if message.is_a?(String)
@data = message if message.is_a?(Hash)
client.push( payload.as_json )
end | ruby | def send(message = nil)
@alert = message if message.is_a?(String)
@data = message if message.is_a?(Hash)
client.push( payload.as_json )
end | [
"def",
"send",
"(",
"message",
"=",
"nil",
")",
"@alert",
"=",
"message",
"if",
"message",
".",
"is_a?",
"(",
"String",
")",
"@data",
"=",
"message",
"if",
"message",
".",
"is_a?",
"(",
"Hash",
")",
"client",
".",
"push",
"(",
"payload",
".",
"as_jso... | helper method to send a message
@param message [String] the message to send | [
"helper",
"method",
"to",
"send",
"a",
"message"
] | 23730f8faa20ff90d994cdb5771096c9a9a5bdff | https://github.com/modernistik/parse-stack/blob/23730f8faa20ff90d994cdb5771096c9a9a5bdff/lib/parse/model/push.rb#L170-L174 | valid |
modernistik/parse-stack | lib/parse/query.rb | Parse.Query.distinct | def distinct(field)
if field.nil? == false && field.respond_to?(:to_s)
# disable counting if it was enabled.
old_count_value = @count
@count = nil
compile_query = compile # temporary store
# add distinct field
compile_query[:distinct] = Query.format_field(field).to_sym
@count = old_count_value
# perform aggregation
return client.aggregate_objects(@table, compile_query.as_json, _opts ).result
else
raise ArgumentError, "Invalid field name passed to `distinct`."
end
end | ruby | def distinct(field)
if field.nil? == false && field.respond_to?(:to_s)
# disable counting if it was enabled.
old_count_value = @count
@count = nil
compile_query = compile # temporary store
# add distinct field
compile_query[:distinct] = Query.format_field(field).to_sym
@count = old_count_value
# perform aggregation
return client.aggregate_objects(@table, compile_query.as_json, _opts ).result
else
raise ArgumentError, "Invalid field name passed to `distinct`."
end
end | [
"def",
"distinct",
"(",
"field",
")",
"if",
"field",
".",
"nil?",
"==",
"false",
"&&",
"field",
".",
"respond_to?",
"(",
":to_s",
")",
"old_count_value",
"=",
"@count",
"@count",
"=",
"nil",
"compile_query",
"=",
"compile",
"compile_query",
"[",
":distinct",... | Queries can be made using distinct, allowing you find unique values for a specified field.
For this to be performant, please remember to index your database.
@example
# Return a set of unique city names
# for users who are greater than 21 years old
Parse::Query.all(distinct: :age)
query = Parse::Query.new("_User")
query.where :age.gt => 21
# triggers query
query.distinct(:city) #=> ["San Diego", "Los Angeles", "San Juan"]
@note This feature requires use of the Master Key in the API.
@param field [Symbol|String] The name of the field used for filtering.
@version 1.8.0 | [
"Queries",
"can",
"be",
"made",
"using",
"distinct",
"allowing",
"you",
"find",
"unique",
"values",
"for",
"a",
"specified",
"field",
".",
"For",
"this",
"to",
"be",
"performant",
"please",
"remember",
"to",
"index",
"your",
"database",
"."
] | 23730f8faa20ff90d994cdb5771096c9a9a5bdff | https://github.com/modernistik/parse-stack/blob/23730f8faa20ff90d994cdb5771096c9a9a5bdff/lib/parse/query.rb#L628-L642 | valid |
modernistik/parse-stack | lib/parse/query.rb | Parse.Query.fetch! | def fetch!(compiled_query)
response = client.find_objects(@table, compiled_query.as_json, _opts )
if response.error?
puts "[ParseQuery] #{response.error}"
end
response
end | ruby | def fetch!(compiled_query)
response = client.find_objects(@table, compiled_query.as_json, _opts )
if response.error?
puts "[ParseQuery] #{response.error}"
end
response
end | [
"def",
"fetch!",
"(",
"compiled_query",
")",
"response",
"=",
"client",
".",
"find_objects",
"(",
"@table",
",",
"compiled_query",
".",
"as_json",
",",
"_opts",
")",
"if",
"response",
".",
"error?",
"puts",
"\"[ParseQuery] #{response.error}\"",
"end",
"response",
... | Performs the fetch request for the query.
@param compiled_query [Hash] the compiled query
@return [Parse::Response] a response for a query request. | [
"Performs",
"the",
"fetch",
"request",
"for",
"the",
"query",
"."
] | 23730f8faa20ff90d994cdb5771096c9a9a5bdff | https://github.com/modernistik/parse-stack/blob/23730f8faa20ff90d994cdb5771096c9a9a5bdff/lib/parse/query.rb#L768-L775 | valid |
modernistik/parse-stack | lib/parse/query.rb | Parse.Query.decode | def decode(list)
list.map { |m| Parse::Object.build(m, @table) }.compact
end | ruby | def decode(list)
list.map { |m| Parse::Object.build(m, @table) }.compact
end | [
"def",
"decode",
"(",
"list",
")",
"list",
".",
"map",
"{",
"|",
"m",
"|",
"Parse",
"::",
"Object",
".",
"build",
"(",
"m",
",",
"@table",
")",
"}",
".",
"compact",
"end"
] | Builds objects based on the set of Parse JSON hashes in an array.
@param list [Array<Hash>] a list of Parse JSON hashes
@return [Array<Parse::Object>] an array of Parse::Object subclasses. | [
"Builds",
"objects",
"based",
"on",
"the",
"set",
"of",
"Parse",
"JSON",
"hashes",
"in",
"an",
"array",
"."
] | 23730f8faa20ff90d994cdb5771096c9a9a5bdff | https://github.com/modernistik/parse-stack/blob/23730f8faa20ff90d994cdb5771096c9a9a5bdff/lib/parse/query.rb#L833-L835 | valid |
modernistik/parse-stack | lib/parse/query.rb | Parse.Query.compile | def compile(encode: true, includeClassName: false)
run_callbacks :prepare do
q = {} #query
q[:limit] = @limit if @limit.is_a?(Numeric) && @limit > 0
q[:skip] = @skip if @skip > 0
q[:include] = @includes.join(',') unless @includes.empty?
q[:keys] = @keys.join(',') unless @keys.empty?
q[:order] = @order.join(',') unless @order.empty?
unless @where.empty?
q[:where] = Parse::Query.compile_where(@where)
q[:where] = q[:where].to_json if encode
end
if @count && @count > 0
# if count is requested
q[:limit] = 0
q[:count] = 1
end
if includeClassName
q[:className] = @table
end
q
end
end | ruby | def compile(encode: true, includeClassName: false)
run_callbacks :prepare do
q = {} #query
q[:limit] = @limit if @limit.is_a?(Numeric) && @limit > 0
q[:skip] = @skip if @skip > 0
q[:include] = @includes.join(',') unless @includes.empty?
q[:keys] = @keys.join(',') unless @keys.empty?
q[:order] = @order.join(',') unless @order.empty?
unless @where.empty?
q[:where] = Parse::Query.compile_where(@where)
q[:where] = q[:where].to_json if encode
end
if @count && @count > 0
# if count is requested
q[:limit] = 0
q[:count] = 1
end
if includeClassName
q[:className] = @table
end
q
end
end | [
"def",
"compile",
"(",
"encode",
":",
"true",
",",
"includeClassName",
":",
"false",
")",
"run_callbacks",
":prepare",
"do",
"q",
"=",
"{",
"}",
"q",
"[",
":limit",
"]",
"=",
"@limit",
"if",
"@limit",
".",
"is_a?",
"(",
"Numeric",
")",
"&&",
"@limit",
... | Complies the query and runs all prepare callbacks.
@param encode [Boolean] whether to encode the `where` clause to a JSON string.
@param includeClassName [Boolean] whether to include the class name of the collection.
@return [Hash] a hash representing the prepared query request.
@see #before_prepare
@see #after_prepare | [
"Complies",
"the",
"query",
"and",
"runs",
"all",
"prepare",
"callbacks",
"."
] | 23730f8faa20ff90d994cdb5771096c9a9a5bdff | https://github.com/modernistik/parse-stack/blob/23730f8faa20ff90d994cdb5771096c9a9a5bdff/lib/parse/query.rb#L856-L880 | valid |
modernistik/parse-stack | lib/parse/client.rb | Parse.Client.get | def get(uri, query = nil, headers = {})
request :get, uri, query: query, headers: headers
end | ruby | def get(uri, query = nil, headers = {})
request :get, uri, query: query, headers: headers
end | [
"def",
"get",
"(",
"uri",
",",
"query",
"=",
"nil",
",",
"headers",
"=",
"{",
"}",
")",
"request",
":get",
",",
"uri",
",",
"query",
":",
"query",
",",
"headers",
":",
"headers",
"end"
] | Send a GET request.
@param uri [String] the uri path for this request.
@param query [Hash] the set of url query parameters.
@param headers [Hash] additional headers to send in this request.
@return (see #request) | [
"Send",
"a",
"GET",
"request",
"."
] | 23730f8faa20ff90d994cdb5771096c9a9a5bdff | https://github.com/modernistik/parse-stack/blob/23730f8faa20ff90d994cdb5771096c9a9a5bdff/lib/parse/client.rb#L496-L498 | valid |
modernistik/parse-stack | lib/parse/client.rb | Parse.Client.post | def post(uri, body = nil, headers = {} )
request :post, uri, body: body, headers: headers
end | ruby | def post(uri, body = nil, headers = {} )
request :post, uri, body: body, headers: headers
end | [
"def",
"post",
"(",
"uri",
",",
"body",
"=",
"nil",
",",
"headers",
"=",
"{",
"}",
")",
"request",
":post",
",",
"uri",
",",
"body",
":",
"body",
",",
"headers",
":",
"headers",
"end"
] | Send a POST request.
@param uri (see #get)
@param body [Hash] a hash that will be JSON encoded for the body of this request.
@param headers (see #get)
@return (see #request) | [
"Send",
"a",
"POST",
"request",
"."
] | 23730f8faa20ff90d994cdb5771096c9a9a5bdff | https://github.com/modernistik/parse-stack/blob/23730f8faa20ff90d994cdb5771096c9a9a5bdff/lib/parse/client.rb#L505-L507 | valid |
modernistik/parse-stack | lib/parse/client.rb | Parse.Client.put | def put(uri, body = nil, headers = {})
request :put, uri, body: body, headers: headers
end | ruby | def put(uri, body = nil, headers = {})
request :put, uri, body: body, headers: headers
end | [
"def",
"put",
"(",
"uri",
",",
"body",
"=",
"nil",
",",
"headers",
"=",
"{",
"}",
")",
"request",
":put",
",",
"uri",
",",
"body",
":",
"body",
",",
"headers",
":",
"headers",
"end"
] | Send a PUT request.
@param uri (see #post)
@param body (see #post)
@param headers (see #post)
@return (see #request) | [
"Send",
"a",
"PUT",
"request",
"."
] | 23730f8faa20ff90d994cdb5771096c9a9a5bdff | https://github.com/modernistik/parse-stack/blob/23730f8faa20ff90d994cdb5771096c9a9a5bdff/lib/parse/client.rb#L514-L516 | valid |
modernistik/parse-stack | lib/parse/client.rb | Parse.Client.delete | def delete(uri, body = nil, headers = {})
request :delete, uri, body: body, headers: headers
end | ruby | def delete(uri, body = nil, headers = {})
request :delete, uri, body: body, headers: headers
end | [
"def",
"delete",
"(",
"uri",
",",
"body",
"=",
"nil",
",",
"headers",
"=",
"{",
"}",
")",
"request",
":delete",
",",
"uri",
",",
"body",
":",
"body",
",",
"headers",
":",
"headers",
"end"
] | Send a DELETE request.
@param uri (see #post)
@param body (see #post)
@param headers (see #post)
@return (see #request) | [
"Send",
"a",
"DELETE",
"request",
"."
] | 23730f8faa20ff90d994cdb5771096c9a9a5bdff | https://github.com/modernistik/parse-stack/blob/23730f8faa20ff90d994cdb5771096c9a9a5bdff/lib/parse/client.rb#L523-L525 | valid |
modernistik/parse-stack | lib/parse/model/acl.rb | Parse.ACL.delete | def delete(id)
id = id.id if id.is_a?(Parse::Pointer)
if id.present? && permissions.has_key?(id)
will_change!
permissions.delete(id)
end
end | ruby | def delete(id)
id = id.id if id.is_a?(Parse::Pointer)
if id.present? && permissions.has_key?(id)
will_change!
permissions.delete(id)
end
end | [
"def",
"delete",
"(",
"id",
")",
"id",
"=",
"id",
".",
"id",
"if",
"id",
".",
"is_a?",
"(",
"Parse",
"::",
"Pointer",
")",
"if",
"id",
".",
"present?",
"&&",
"permissions",
".",
"has_key?",
"(",
"id",
")",
"will_change!",
"permissions",
".",
"delete"... | Removes a permission for an objectId or user.
@overload delete(object)
@param object [Parse::User] the user to revoke permissions.
@overload delete(id)
@param id [String] the objectId to revoke permissions. | [
"Removes",
"a",
"permission",
"for",
"an",
"objectId",
"or",
"user",
"."
] | 23730f8faa20ff90d994cdb5771096c9a9a5bdff | https://github.com/modernistik/parse-stack/blob/23730f8faa20ff90d994cdb5771096c9a9a5bdff/lib/parse/model/acl.rb#L211-L217 | valid |
modernistik/parse-stack | lib/parse/model/acl.rb | Parse.ACL.all_read! | def all_read!
will_change!
permissions.keys.each do |perm|
permissions[perm].read! true
end
end | ruby | def all_read!
will_change!
permissions.keys.each do |perm|
permissions[perm].read! true
end
end | [
"def",
"all_read!",
"will_change!",
"permissions",
".",
"keys",
".",
"each",
"do",
"|",
"perm",
"|",
"permissions",
"[",
"perm",
"]",
".",
"read!",
"true",
"end",
"end"
] | Grants read permission on all existing users and roles attached to this object.
@example
object.acl
# { "*": { "read" : true },
# "3KmCvT7Zsb": { "read" : true, "write": true },
# "role:Admins": { "write": true }
# }
object.acl.all_read!
# Outcome:
# { "*": { "read" : true },
# "3KmCvT7Zsb": { "read" : true, "write": true },
# "role:Admins": { "read" : true, "write": true}
# }
@version 1.7.2
@return [Array] list of ACL keys | [
"Grants",
"read",
"permission",
"on",
"all",
"existing",
"users",
"and",
"roles",
"attached",
"to",
"this",
"object",
"."
] | 23730f8faa20ff90d994cdb5771096c9a9a5bdff | https://github.com/modernistik/parse-stack/blob/23730f8faa20ff90d994cdb5771096c9a9a5bdff/lib/parse/model/acl.rb#L350-L355 | valid |
modernistik/parse-stack | lib/parse/model/acl.rb | Parse.ACL.all_write! | def all_write!
will_change!
permissions.keys.each do |perm|
permissions[perm].write! true
end
end | ruby | def all_write!
will_change!
permissions.keys.each do |perm|
permissions[perm].write! true
end
end | [
"def",
"all_write!",
"will_change!",
"permissions",
".",
"keys",
".",
"each",
"do",
"|",
"perm",
"|",
"permissions",
"[",
"perm",
"]",
".",
"write!",
"true",
"end",
"end"
] | Grants write permission on all existing users and roles attached to this object.
@example
object.acl
# { "*": { "read" : true },
# "3KmCvT7Zsb": { "read" : true, "write": true },
# "role:Admins": { "write": true }
# }
object.acl.all_write!
# Outcome:
# { "*": { "read" : true, "write": true },
# "3KmCvT7Zsb": { "read" : true, "write": true },
# "role:Admins": { "write": true }
# }
@version 1.7.2
@return [Array] list of ACL keys | [
"Grants",
"write",
"permission",
"on",
"all",
"existing",
"users",
"and",
"roles",
"attached",
"to",
"this",
"object",
"."
] | 23730f8faa20ff90d994cdb5771096c9a9a5bdff | https://github.com/modernistik/parse-stack/blob/23730f8faa20ff90d994cdb5771096c9a9a5bdff/lib/parse/model/acl.rb#L372-L377 | valid |
modernistik/parse-stack | lib/parse/model/acl.rb | Parse.ACL.no_read! | def no_read!
will_change!
permissions.keys.each do |perm|
permissions[perm].read! false
end
end | ruby | def no_read!
will_change!
permissions.keys.each do |perm|
permissions[perm].read! false
end
end | [
"def",
"no_read!",
"will_change!",
"permissions",
".",
"keys",
".",
"each",
"do",
"|",
"perm",
"|",
"permissions",
"[",
"perm",
"]",
".",
"read!",
"false",
"end",
"end"
] | Denies read permission on all existing users and roles attached to this object.
@example
object.acl
# { "*": { "read" : true },
# "3KmCvT7Zsb": { "read" : true, "write": true },
# "role:Admins": { "write": true }
# }
object.acl.no_read!
# Outcome:
# { "*": nil,
# "3KmCvT7Zsb": { "write": true },
# "role:Admins": { "write": true }
# }
@version 1.7.2
@return [Array] list of ACL keys | [
"Denies",
"read",
"permission",
"on",
"all",
"existing",
"users",
"and",
"roles",
"attached",
"to",
"this",
"object",
"."
] | 23730f8faa20ff90d994cdb5771096c9a9a5bdff | https://github.com/modernistik/parse-stack/blob/23730f8faa20ff90d994cdb5771096c9a9a5bdff/lib/parse/model/acl.rb#L394-L399 | valid |
modernistik/parse-stack | lib/parse/model/acl.rb | Parse.ACL.no_write! | def no_write!
will_change!
permissions.keys.each do |perm|
permissions[perm].write! false
end
end | ruby | def no_write!
will_change!
permissions.keys.each do |perm|
permissions[perm].write! false
end
end | [
"def",
"no_write!",
"will_change!",
"permissions",
".",
"keys",
".",
"each",
"do",
"|",
"perm",
"|",
"permissions",
"[",
"perm",
"]",
".",
"write!",
"false",
"end",
"end"
] | Denies write permission on all existing users and roles attached to this object.
@example
object.acl
# { "*": { "read" : true },
# "3KmCvT7Zsb": { "read" : true, "write": true },
# "role:Admins": { "write": true }
# }
object.acl.no_write!
# Outcome:
# { "*": { "read" : true },
# "3KmCvT7Zsb": { "read" : true },
# "role:Admins": nil
# }
@version 1.7.2
@return [Array] list of ACL keys | [
"Denies",
"write",
"permission",
"on",
"all",
"existing",
"users",
"and",
"roles",
"attached",
"to",
"this",
"object",
"."
] | 23730f8faa20ff90d994cdb5771096c9a9a5bdff | https://github.com/modernistik/parse-stack/blob/23730f8faa20ff90d994cdb5771096c9a9a5bdff/lib/parse/model/acl.rb#L416-L421 | valid |
modernistik/parse-stack | lib/parse/client/response.rb | Parse.Response.batch_responses | def batch_responses
return [@result] unless @batch_response
# if batch response, generate array based on the response hash.
@result.map do |r|
next r unless r.is_a?(Hash)
hash = r[SUCCESS] || r[ERROR]
Parse::Response.new hash
end
end | ruby | def batch_responses
return [@result] unless @batch_response
# if batch response, generate array based on the response hash.
@result.map do |r|
next r unless r.is_a?(Hash)
hash = r[SUCCESS] || r[ERROR]
Parse::Response.new hash
end
end | [
"def",
"batch_responses",
"return",
"[",
"@result",
"]",
"unless",
"@batch_response",
"@result",
".",
"map",
"do",
"|",
"r",
"|",
"next",
"r",
"unless",
"r",
".",
"is_a?",
"(",
"Hash",
")",
"hash",
"=",
"r",
"[",
"SUCCESS",
"]",
"||",
"r",
"[",
"ERRO... | If it is a batch respnose, we'll create an array of Response objects for each
of the ones in the batch.
@return [Array] an array of Response objects. | [
"If",
"it",
"is",
"a",
"batch",
"respnose",
"we",
"ll",
"create",
"an",
"array",
"of",
"Response",
"objects",
"for",
"each",
"of",
"the",
"ones",
"in",
"the",
"batch",
"."
] | 23730f8faa20ff90d994cdb5771096c9a9a5bdff | https://github.com/modernistik/parse-stack/blob/23730f8faa20ff90d994cdb5771096c9a9a5bdff/lib/parse/client/response.rb#L100-L109 | valid |
modernistik/parse-stack | lib/parse/client/response.rb | Parse.Response.parse_result! | def parse_result!(h)
@result = {}
return unless h.is_a?(Hash)
@code = h[CODE]
@error = h[ERROR]
if h[RESULTS].is_a?(Array)
@result = h[RESULTS]
@count = h[COUNT] || @result.count
else
@result = h
@count = 1
end
end | ruby | def parse_result!(h)
@result = {}
return unless h.is_a?(Hash)
@code = h[CODE]
@error = h[ERROR]
if h[RESULTS].is_a?(Array)
@result = h[RESULTS]
@count = h[COUNT] || @result.count
else
@result = h
@count = 1
end
end | [
"def",
"parse_result!",
"(",
"h",
")",
"@result",
"=",
"{",
"}",
"return",
"unless",
"h",
".",
"is_a?",
"(",
"Hash",
")",
"@code",
"=",
"h",
"[",
"CODE",
"]",
"@error",
"=",
"h",
"[",
"ERROR",
"]",
"if",
"h",
"[",
"RESULTS",
"]",
".",
"is_a?",
... | This method takes the result hash and determines if it is a regular
parse query result, object result or a count result. The response should
be a hash either containing the result data or the error. | [
"This",
"method",
"takes",
"the",
"result",
"hash",
"and",
"determines",
"if",
"it",
"is",
"a",
"regular",
"parse",
"query",
"result",
"object",
"result",
"or",
"a",
"count",
"result",
".",
"The",
"response",
"should",
"be",
"a",
"hash",
"either",
"contain... | 23730f8faa20ff90d994cdb5771096c9a9a5bdff | https://github.com/modernistik/parse-stack/blob/23730f8faa20ff90d994cdb5771096c9a9a5bdff/lib/parse/client/response.rb#L114-L127 | valid |
modernistik/parse-stack | lib/parse/model/classes/user.rb | Parse.User.link_auth_data! | def link_auth_data!(service_name, **data)
response = client.set_service_auth_data(id, service_name, data)
raise Parse::Client::ResponseError, response if response.error?
apply_attributes!(response.result)
end | ruby | def link_auth_data!(service_name, **data)
response = client.set_service_auth_data(id, service_name, data)
raise Parse::Client::ResponseError, response if response.error?
apply_attributes!(response.result)
end | [
"def",
"link_auth_data!",
"(",
"service_name",
",",
"**",
"data",
")",
"response",
"=",
"client",
".",
"set_service_auth_data",
"(",
"id",
",",
"service_name",
",",
"data",
")",
"raise",
"Parse",
"::",
"Client",
"::",
"ResponseError",
",",
"response",
"if",
... | Adds the third-party authentication data to for a given service.
@param service_name [Symbol] The name of the service (ex. :facebook)
@param data [Hash] The body of the OAuth data. Dependent on each service.
@raise [Parse::Client::ResponseError] If user was not successfully linked | [
"Adds",
"the",
"third",
"-",
"party",
"authentication",
"data",
"to",
"for",
"a",
"given",
"service",
"."
] | 23730f8faa20ff90d994cdb5771096c9a9a5bdff | https://github.com/modernistik/parse-stack/blob/23730f8faa20ff90d994cdb5771096c9a9a5bdff/lib/parse/model/classes/user.rb#L199-L203 | valid |
modernistik/parse-stack | lib/parse/model/classes/user.rb | Parse.User.signup! | def signup!(passwd = nil)
self.password = passwd || password
if username.blank?
raise Parse::Error::UsernameMissingError, "Signup requires a username."
end
if password.blank?
raise Parse::Error::PasswordMissingError, "Signup requires a password."
end
signup_attrs = attribute_updates
signup_attrs.except! *Parse::Properties::BASE_FIELD_MAP.flatten
# first signup the user, then save any additional attributes
response = client.create_user signup_attrs
if response.success?
apply_attributes! response.result
return true
end
case response.code
when Parse::Response::ERROR_USERNAME_MISSING
raise Parse::Error::UsernameMissingError, response
when Parse::Response::ERROR_PASSWORD_MISSING
raise Parse::Error::PasswordMissingError, response
when Parse::Response::ERROR_USERNAME_TAKEN
raise Parse::Error::UsernameTakenError, response
when Parse::Response::ERROR_EMAIL_TAKEN
raise Parse::Error::EmailTakenError, response
when Parse::Response::ERROR_EMAIL_INVALID
raise Parse::Error::InvalidEmailAddress, response
end
raise Parse::Client::ResponseError, response
end | ruby | def signup!(passwd = nil)
self.password = passwd || password
if username.blank?
raise Parse::Error::UsernameMissingError, "Signup requires a username."
end
if password.blank?
raise Parse::Error::PasswordMissingError, "Signup requires a password."
end
signup_attrs = attribute_updates
signup_attrs.except! *Parse::Properties::BASE_FIELD_MAP.flatten
# first signup the user, then save any additional attributes
response = client.create_user signup_attrs
if response.success?
apply_attributes! response.result
return true
end
case response.code
when Parse::Response::ERROR_USERNAME_MISSING
raise Parse::Error::UsernameMissingError, response
when Parse::Response::ERROR_PASSWORD_MISSING
raise Parse::Error::PasswordMissingError, response
when Parse::Response::ERROR_USERNAME_TAKEN
raise Parse::Error::UsernameTakenError, response
when Parse::Response::ERROR_EMAIL_TAKEN
raise Parse::Error::EmailTakenError, response
when Parse::Response::ERROR_EMAIL_INVALID
raise Parse::Error::InvalidEmailAddress, response
end
raise Parse::Client::ResponseError, response
end | [
"def",
"signup!",
"(",
"passwd",
"=",
"nil",
")",
"self",
".",
"password",
"=",
"passwd",
"||",
"password",
"if",
"username",
".",
"blank?",
"raise",
"Parse",
"::",
"Error",
"::",
"UsernameMissingError",
",",
"\"Signup requires a username.\"",
"end",
"if",
"pa... | You may set a password for this user when you are creating them. Parse never returns a
@param passwd The user's password to be used for signing up.
@raise [Parse::Error::UsernameMissingError] If username is missing.
@raise [Parse::Error::PasswordMissingError] If password is missing.
@raise [Parse::Error::UsernameTakenError] If the username has already been taken.
@raise [Parse::Error::EmailTakenError] If the email has already been taken (or exists in the system).
@raise [Parse::Error::InvalidEmailAddress] If the email is invalid.
@raise [Parse::Client::ResponseError] An unknown error occurred.
@return [Boolean] True if signup it was successful. If it fails an exception is thrown. | [
"You",
"may",
"set",
"a",
"password",
"for",
"this",
"user",
"when",
"you",
"are",
"creating",
"them",
".",
"Parse",
"never",
"returns",
"a"
] | 23730f8faa20ff90d994cdb5771096c9a9a5bdff | https://github.com/modernistik/parse-stack/blob/23730f8faa20ff90d994cdb5771096c9a9a5bdff/lib/parse/model/classes/user.rb#L245-L279 | valid |
modernistik/parse-stack | lib/parse/model/classes/user.rb | Parse.User.login! | def login!(passwd = nil)
self.password = passwd || self.password
response = client.login(username.to_s, password.to_s)
apply_attributes! response.result
self.session_token.present?
end | ruby | def login!(passwd = nil)
self.password = passwd || self.password
response = client.login(username.to_s, password.to_s)
apply_attributes! response.result
self.session_token.present?
end | [
"def",
"login!",
"(",
"passwd",
"=",
"nil",
")",
"self",
".",
"password",
"=",
"passwd",
"||",
"self",
".",
"password",
"response",
"=",
"client",
".",
"login",
"(",
"username",
".",
"to_s",
",",
"password",
".",
"to_s",
")",
"apply_attributes!",
"respon... | Login and get a session token for this user.
@param passwd [String] The password for this user.
@return [Boolean] True/false if we received a valid session token. | [
"Login",
"and",
"get",
"a",
"session",
"token",
"for",
"this",
"user",
"."
] | 23730f8faa20ff90d994cdb5771096c9a9a5bdff | https://github.com/modernistik/parse-stack/blob/23730f8faa20ff90d994cdb5771096c9a9a5bdff/lib/parse/model/classes/user.rb#L284-L289 | valid |
modernistik/parse-stack | lib/parse/model/classes/user.rb | Parse.User.logout | def logout
return true if self.session_token.blank?
client.logout session_token
self.session_token = nil
true
rescue => e
false
end | ruby | def logout
return true if self.session_token.blank?
client.logout session_token
self.session_token = nil
true
rescue => e
false
end | [
"def",
"logout",
"return",
"true",
"if",
"self",
".",
"session_token",
".",
"blank?",
"client",
".",
"logout",
"session_token",
"self",
".",
"session_token",
"=",
"nil",
"true",
"rescue",
"=>",
"e",
"false",
"end"
] | Invalid the current session token for this logged in user.
@return [Boolean] True/false if successful | [
"Invalid",
"the",
"current",
"session",
"token",
"for",
"this",
"logged",
"in",
"user",
"."
] | 23730f8faa20ff90d994cdb5771096c9a9a5bdff | https://github.com/modernistik/parse-stack/blob/23730f8faa20ff90d994cdb5771096c9a9a5bdff/lib/parse/model/classes/user.rb#L293-L300 | valid |
modernistik/parse-stack | lib/parse/model/core/actions.rb | Parse.Query.first_or_create | def first_or_create(query_attrs = {}, resource_attrs = {})
conditions(query_attrs)
klass = Parse::Model.find_class self.table
if klass.blank?
raise ArgumentError, "Parse model with class name #{self.table} is not registered."
end
hash_constraints = constraints(true)
klass.first_or_create(hash_constraints, resource_attrs)
end | ruby | def first_or_create(query_attrs = {}, resource_attrs = {})
conditions(query_attrs)
klass = Parse::Model.find_class self.table
if klass.blank?
raise ArgumentError, "Parse model with class name #{self.table} is not registered."
end
hash_constraints = constraints(true)
klass.first_or_create(hash_constraints, resource_attrs)
end | [
"def",
"first_or_create",
"(",
"query_attrs",
"=",
"{",
"}",
",",
"resource_attrs",
"=",
"{",
"}",
")",
"conditions",
"(",
"query_attrs",
")",
"klass",
"=",
"Parse",
"::",
"Model",
".",
"find_class",
"self",
".",
"table",
"if",
"klass",
".",
"blank?",
"r... | Supporting the `first_or_create` class method to be used in scope chaining with queries.
@!visibility private | [
"Supporting",
"the",
"first_or_create",
"class",
"method",
"to",
"be",
"used",
"in",
"scope",
"chaining",
"with",
"queries",
"."
] | 23730f8faa20ff90d994cdb5771096c9a9a5bdff | https://github.com/modernistik/parse-stack/blob/23730f8faa20ff90d994cdb5771096c9a9a5bdff/lib/parse/model/core/actions.rb#L29-L37 | valid |
modernistik/parse-stack | lib/parse/model/core/actions.rb | Parse.Query.save_all | def save_all(expressions = {})
conditions(expressions)
klass = Parse::Model.find_class self.table
if klass.blank?
raise ArgumentError, "Parse model with class name #{self.table} is not registered."
end
hash_constraints = constraints(true)
klass.save_all(hash_constraints, &Proc.new) if block_given?
klass.save_all(hash_constraints)
end | ruby | def save_all(expressions = {})
conditions(expressions)
klass = Parse::Model.find_class self.table
if klass.blank?
raise ArgumentError, "Parse model with class name #{self.table} is not registered."
end
hash_constraints = constraints(true)
klass.save_all(hash_constraints, &Proc.new) if block_given?
klass.save_all(hash_constraints)
end | [
"def",
"save_all",
"(",
"expressions",
"=",
"{",
"}",
")",
"conditions",
"(",
"expressions",
")",
"klass",
"=",
"Parse",
"::",
"Model",
".",
"find_class",
"self",
".",
"table",
"if",
"klass",
".",
"blank?",
"raise",
"ArgumentError",
",",
"\"Parse model with ... | Supporting the `save_all` method to be used in scope chaining with queries.
@!visibility private | [
"Supporting",
"the",
"save_all",
"method",
"to",
"be",
"used",
"in",
"scope",
"chaining",
"with",
"queries",
"."
] | 23730f8faa20ff90d994cdb5771096c9a9a5bdff | https://github.com/modernistik/parse-stack/blob/23730f8faa20ff90d994cdb5771096c9a9a5bdff/lib/parse/model/core/actions.rb#L41-L51 | valid |
thechrisoshow/rtf | lib/rtf/font.rb | RTF.FontTable.add | def add(font)
if font.instance_of?(Font)
@fonts.push(font) if @fonts.index(font).nil?
end
self
end | ruby | def add(font)
if font.instance_of?(Font)
@fonts.push(font) if @fonts.index(font).nil?
end
self
end | [
"def",
"add",
"(",
"font",
")",
"if",
"font",
".",
"instance_of?",
"(",
"Font",
")",
"@fonts",
".",
"push",
"(",
"font",
")",
"if",
"@fonts",
".",
"index",
"(",
"font",
")",
".",
"nil?",
"end",
"self",
"end"
] | This method adds a font to a FontTable instance. This method returns
a reference to the FontTable object updated.
==== Parameters
font:: A reference to the font to be added. If this is not a Font
object or already exists in the table it will be ignored. | [
"This",
"method",
"adds",
"a",
"font",
"to",
"a",
"FontTable",
"instance",
".",
"This",
"method",
"returns",
"a",
"reference",
"to",
"the",
"FontTable",
"object",
"updated",
"."
] | d6455933262a25628006101be802d7f7b2c3feb7 | https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/font.rb#L109-L114 | valid |
thechrisoshow/rtf | lib/rtf/font.rb | RTF.FontTable.to_rtf | def to_rtf(indent=0)
prefix = indent > 0 ? ' ' * indent : ''
text = StringIO.new
text << "#{prefix}{\\fonttbl"
@fonts.each_index do |index|
text << "\n#{prefix}{\\f#{index}#{@fonts[index].to_rtf}}"
end
text << "\n#{prefix}}"
text.string
end | ruby | def to_rtf(indent=0)
prefix = indent > 0 ? ' ' * indent : ''
text = StringIO.new
text << "#{prefix}{\\fonttbl"
@fonts.each_index do |index|
text << "\n#{prefix}{\\f#{index}#{@fonts[index].to_rtf}}"
end
text << "\n#{prefix}}"
text.string
end | [
"def",
"to_rtf",
"(",
"indent",
"=",
"0",
")",
"prefix",
"=",
"indent",
">",
"0",
"?",
"' '",
"*",
"indent",
":",
"''",
"text",
"=",
"StringIO",
".",
"new",
"text",
"<<",
"\"#{prefix}{\\\\fonttbl\"",
"@fonts",
".",
"each_index",
"do",
"|",
"index",
"|"... | This method generates the RTF text for a FontTable object.
==== Parameters
indent:: The number of spaces to prefix to the lines generated by the
method. Defaults to zero. | [
"This",
"method",
"generates",
"the",
"RTF",
"text",
"for",
"a",
"FontTable",
"object",
"."
] | d6455933262a25628006101be802d7f7b2c3feb7 | https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/font.rb#L160-L169 | valid |
thechrisoshow/rtf | lib/rtf/node.rb | RTF.Node.previous_node | def previous_node
peer = nil
if !parent.nil? and parent.respond_to?(:children)
index = parent.children.index(self)
peer = index > 0 ? parent.children[index - 1] : nil
end
peer
end | ruby | def previous_node
peer = nil
if !parent.nil? and parent.respond_to?(:children)
index = parent.children.index(self)
peer = index > 0 ? parent.children[index - 1] : nil
end
peer
end | [
"def",
"previous_node",
"peer",
"=",
"nil",
"if",
"!",
"parent",
".",
"nil?",
"and",
"parent",
".",
"respond_to?",
"(",
":children",
")",
"index",
"=",
"parent",
".",
"children",
".",
"index",
"(",
"self",
")",
"peer",
"=",
"index",
">",
"0",
"?",
"p... | Constructor for the Node class.
==== Parameters
parent:: A reference to the Node that owns the new Node. May be nil
to indicate a base or root node.
This method retrieves a Node objects previous peer node, returning nil
if the Node has no previous peer. | [
"Constructor",
"for",
"the",
"Node",
"class",
"."
] | d6455933262a25628006101be802d7f7b2c3feb7 | https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L23-L30 | valid |
thechrisoshow/rtf | lib/rtf/node.rb | RTF.Node.next_node | def next_node
peer = nil
if !parent.nil? and parent.respond_to?(:children)
index = parent.children.index(self)
peer = parent.children[index + 1]
end
peer
end | ruby | def next_node
peer = nil
if !parent.nil? and parent.respond_to?(:children)
index = parent.children.index(self)
peer = parent.children[index + 1]
end
peer
end | [
"def",
"next_node",
"peer",
"=",
"nil",
"if",
"!",
"parent",
".",
"nil?",
"and",
"parent",
".",
"respond_to?",
"(",
":children",
")",
"index",
"=",
"parent",
".",
"children",
".",
"index",
"(",
"self",
")",
"peer",
"=",
"parent",
".",
"children",
"[",
... | This method retrieves a Node objects next peer node, returning nil
if the Node has no previous peer. | [
"This",
"method",
"retrieves",
"a",
"Node",
"objects",
"next",
"peer",
"node",
"returning",
"nil",
"if",
"the",
"Node",
"has",
"no",
"previous",
"peer",
"."
] | d6455933262a25628006101be802d7f7b2c3feb7 | https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L34-L41 | valid |
thechrisoshow/rtf | lib/rtf/node.rb | RTF.TextNode.insert | def insert(text, offset)
if !@text.nil?
@text = @text[0, offset] + text.to_s + @text[offset, @text.length]
else
@text = text.to_s
end
end | ruby | def insert(text, offset)
if !@text.nil?
@text = @text[0, offset] + text.to_s + @text[offset, @text.length]
else
@text = text.to_s
end
end | [
"def",
"insert",
"(",
"text",
",",
"offset",
")",
"if",
"!",
"@text",
".",
"nil?",
"@text",
"=",
"@text",
"[",
"0",
",",
"offset",
"]",
"+",
"text",
".",
"to_s",
"+",
"@text",
"[",
"offset",
",",
"@text",
".",
"length",
"]",
"else",
"@text",
"=",... | This method inserts a String into the existing text within a TextNode
object. If the TextNode contains no text then it is simply set to the
text passed in. If the offset specified is past the end of the nodes
text then it is simply appended to the end.
==== Parameters
text:: A String containing the text to be added.
offset:: The numbers of characters from the first character to insert
the new text at. | [
"This",
"method",
"inserts",
"a",
"String",
"into",
"the",
"existing",
"text",
"within",
"a",
"TextNode",
"object",
".",
"If",
"the",
"TextNode",
"contains",
"no",
"text",
"then",
"it",
"is",
"simply",
"set",
"to",
"the",
"text",
"passed",
"in",
".",
"If... | d6455933262a25628006101be802d7f7b2c3feb7 | https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L102-L108 | valid |
thechrisoshow/rtf | lib/rtf/node.rb | RTF.TextNode.to_rtf | def to_rtf
rtf=(@text.nil? ? '' : @text.gsub("{", "\\{").gsub("}", "\\}").gsub("\\", "\\\\"))
# This is from lfarcy / rtf-extensions
# I don't see the point of coding different 128<n<256 range
#f1=lambda { |n| n < 128 ? n.chr : n < 256 ? "\\'#{n.to_s(16)}" : "\\u#{n}\\'3f" }
# Encode as Unicode.
f=lambda { |n| n < 128 ? n.chr : "\\u#{n}\\'3f" }
# Ruby 1.9 is safe, cause detect original encoding
# and convert text to utf-16 first
if RUBY_VERSION>"1.9.0"
return rtf.encode("UTF-16LE", :undef=>:replace).each_codepoint.map(&f).join('')
else
# You SHOULD use UTF-8 as input, ok?
return rtf.unpack('U*').map(&f).join('')
end
end | ruby | def to_rtf
rtf=(@text.nil? ? '' : @text.gsub("{", "\\{").gsub("}", "\\}").gsub("\\", "\\\\"))
# This is from lfarcy / rtf-extensions
# I don't see the point of coding different 128<n<256 range
#f1=lambda { |n| n < 128 ? n.chr : n < 256 ? "\\'#{n.to_s(16)}" : "\\u#{n}\\'3f" }
# Encode as Unicode.
f=lambda { |n| n < 128 ? n.chr : "\\u#{n}\\'3f" }
# Ruby 1.9 is safe, cause detect original encoding
# and convert text to utf-16 first
if RUBY_VERSION>"1.9.0"
return rtf.encode("UTF-16LE", :undef=>:replace).each_codepoint.map(&f).join('')
else
# You SHOULD use UTF-8 as input, ok?
return rtf.unpack('U*').map(&f).join('')
end
end | [
"def",
"to_rtf",
"rtf",
"=",
"(",
"@text",
".",
"nil?",
"?",
"''",
":",
"@text",
".",
"gsub",
"(",
"\"{\"",
",",
"\"\\\\{\"",
")",
".",
"gsub",
"(",
"\"}\"",
",",
"\"\\\\}\"",
")",
".",
"gsub",
"(",
"\"\\\\\"",
",",
"\"\\\\\\\\\"",
")",
")",
"f",
... | This method generates the RTF equivalent for a TextNode object. This
method escapes any special sequences that appear in the text. | [
"This",
"method",
"generates",
"the",
"RTF",
"equivalent",
"for",
"a",
"TextNode",
"object",
".",
"This",
"method",
"escapes",
"any",
"special",
"sequences",
"that",
"appear",
"in",
"the",
"text",
"."
] | d6455933262a25628006101be802d7f7b2c3feb7 | https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L112-L129 | valid |
thechrisoshow/rtf | lib/rtf/node.rb | RTF.ContainerNode.store | def store(node)
if !node.nil?
@children.push(node) if !@children.include?(Node)
node.parent = self if node.parent != self
end
node
end | ruby | def store(node)
if !node.nil?
@children.push(node) if !@children.include?(Node)
node.parent = self if node.parent != self
end
node
end | [
"def",
"store",
"(",
"node",
")",
"if",
"!",
"node",
".",
"nil?",
"@children",
".",
"push",
"(",
"node",
")",
"if",
"!",
"@children",
".",
"include?",
"(",
"Node",
")",
"node",
".",
"parent",
"=",
"self",
"if",
"node",
".",
"parent",
"!=",
"self",
... | This is the constructor for the ContainerNode class.
==== Parameters
parent:: A reference to the parent node that owners the new
ContainerNode object.
This method adds a new node element to the end of the list of nodes
maintained by a ContainerNode object. Nil objects are ignored.
==== Parameters
node:: A reference to the Node object to be added. | [
"This",
"is",
"the",
"constructor",
"for",
"the",
"ContainerNode",
"class",
"."
] | d6455933262a25628006101be802d7f7b2c3feb7 | https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L157-L163 | valid |
thechrisoshow/rtf | lib/rtf/node.rb | RTF.CommandNode.<< | def <<(text)
if !last.nil? and last.respond_to?(:text=)
last.append(text)
else
self.store(TextNode.new(self, text))
end
end | ruby | def <<(text)
if !last.nil? and last.respond_to?(:text=)
last.append(text)
else
self.store(TextNode.new(self, text))
end
end | [
"def",
"<<",
"(",
"text",
")",
"if",
"!",
"last",
".",
"nil?",
"and",
"last",
".",
"respond_to?",
"(",
":text=",
")",
"last",
".",
"append",
"(",
"text",
")",
"else",
"self",
".",
"store",
"(",
"TextNode",
".",
"new",
"(",
"self",
",",
"text",
")... | This is the constructor for the CommandNode class.
==== Parameters
parent:: A reference to the node that owns the new node.
prefix:: A String containing the prefix text for the command.
suffix:: A String containing the suffix text for the command. Defaults
to nil.
split:: A boolean to indicate whether the prefix and suffix should
be written to separate lines whether the node is converted
to RTF. Defaults to true.
wrap:: A boolean to indicate whether the prefix and suffix should
be wrapped in curly braces. Defaults to true.
This method adds text to a command node. If the last child node of the
target node is a TextNode then the text is appended to that. Otherwise
a new TextNode is created and append to the node.
==== Parameters
text:: The String of text to be written to the node. | [
"This",
"is",
"the",
"constructor",
"for",
"the",
"CommandNode",
"class",
"."
] | d6455933262a25628006101be802d7f7b2c3feb7 | https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L250-L256 | valid |
thechrisoshow/rtf | lib/rtf/node.rb | RTF.CommandNode.to_rtf | def to_rtf
text = StringIO.new
text << '{' if wrap?
text << @prefix if @prefix
self.each do |entry|
text << "\n" if split?
text << entry.to_rtf
end
text << "\n" if split?
text << @suffix if @suffix
text << '}' if wrap?
text.string
end | ruby | def to_rtf
text = StringIO.new
text << '{' if wrap?
text << @prefix if @prefix
self.each do |entry|
text << "\n" if split?
text << entry.to_rtf
end
text << "\n" if split?
text << @suffix if @suffix
text << '}' if wrap?
text.string
end | [
"def",
"to_rtf",
"text",
"=",
"StringIO",
".",
"new",
"text",
"<<",
"'{'",
"if",
"wrap?",
"text",
"<<",
"@prefix",
"if",
"@prefix",
"self",
".",
"each",
"do",
"|",
"entry",
"|",
"text",
"<<",
"\"\\n\"",
"if",
"split?",
"text",
"<<",
"entry",
".",
"to... | This method generates the RTF text for a CommandNode object. | [
"This",
"method",
"generates",
"the",
"RTF",
"text",
"for",
"a",
"CommandNode",
"object",
"."
] | d6455933262a25628006101be802d7f7b2c3feb7 | https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L259-L275 | valid |
thechrisoshow/rtf | lib/rtf/node.rb | RTF.CommandNode.paragraph | def paragraph(style=nil)
node = ParagraphNode.new(self, style)
yield node if block_given?
self.store(node)
end | ruby | def paragraph(style=nil)
node = ParagraphNode.new(self, style)
yield node if block_given?
self.store(node)
end | [
"def",
"paragraph",
"(",
"style",
"=",
"nil",
")",
"node",
"=",
"ParagraphNode",
".",
"new",
"(",
"self",
",",
"style",
")",
"yield",
"node",
"if",
"block_given?",
"self",
".",
"store",
"(",
"node",
")",
"end"
] | This method provides a short cut means of creating a paragraph command
node. The method accepts a block that will be passed a single parameter
which will be a reference to the paragraph node created. After the
block is complete the paragraph node is appended to the end of the child
nodes on the object that the method is called against.
==== Parameters
style:: A reference to a ParagraphStyle object that defines the style
for the new paragraph. Defaults to nil to indicate that the
currently applied paragraph styling should be used. | [
"This",
"method",
"provides",
"a",
"short",
"cut",
"means",
"of",
"creating",
"a",
"paragraph",
"command",
"node",
".",
"The",
"method",
"accepts",
"a",
"block",
"that",
"will",
"be",
"passed",
"a",
"single",
"parameter",
"which",
"will",
"be",
"a",
"refer... | d6455933262a25628006101be802d7f7b2c3feb7 | https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L287-L291 | valid |
thechrisoshow/rtf | lib/rtf/node.rb | RTF.CommandNode.list | def list(kind=:bullets)
node = ListNode.new(self)
yield node.list(kind)
self.store(node)
end | ruby | def list(kind=:bullets)
node = ListNode.new(self)
yield node.list(kind)
self.store(node)
end | [
"def",
"list",
"(",
"kind",
"=",
":bullets",
")",
"node",
"=",
"ListNode",
".",
"new",
"(",
"self",
")",
"yield",
"node",
".",
"list",
"(",
"kind",
")",
"self",
".",
"store",
"(",
"node",
")",
"end"
] | This method provides a short cut means of creating a new ordered or
unordered list. The method requires a block that will be passed a
single parameter that'll be a reference to the first level of the
list. See the +ListLevelNode+ doc for more information.
Example usage:
rtf.list do |level1|
level1.item do |li|
li << 'some text'
li.apply(some_style) {|x| x << 'some styled text'}
end
level1.list(:decimal) do |level2|
level2.item {|li| li << 'some other text in a decimal list'}
level2.item {|li| li << 'and here we go'}
end
end | [
"This",
"method",
"provides",
"a",
"short",
"cut",
"means",
"of",
"creating",
"a",
"new",
"ordered",
"or",
"unordered",
"list",
".",
"The",
"method",
"requires",
"a",
"block",
"that",
"will",
"be",
"passed",
"a",
"single",
"parameter",
"that",
"ll",
"be",
... | d6455933262a25628006101be802d7f7b2c3feb7 | https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L312-L316 | valid |
thechrisoshow/rtf | lib/rtf/node.rb | RTF.CommandNode.footnote | def footnote(text)
if !text.nil? and text != ''
mark = CommandNode.new(self, '\fs16\up6\chftn', nil, false)
note = CommandNode.new(self, '\footnote {\fs16\up6\chftn}', nil, false)
note.paragraph << text
self.store(mark)
self.store(note)
end
end | ruby | def footnote(text)
if !text.nil? and text != ''
mark = CommandNode.new(self, '\fs16\up6\chftn', nil, false)
note = CommandNode.new(self, '\footnote {\fs16\up6\chftn}', nil, false)
note.paragraph << text
self.store(mark)
self.store(note)
end
end | [
"def",
"footnote",
"(",
"text",
")",
"if",
"!",
"text",
".",
"nil?",
"and",
"text",
"!=",
"''",
"mark",
"=",
"CommandNode",
".",
"new",
"(",
"self",
",",
"'\\fs16\\up6\\chftn'",
",",
"nil",
",",
"false",
")",
"note",
"=",
"CommandNode",
".",
"new",
"... | This method inserts a footnote at the current position in a node.
==== Parameters
text:: A string containing the text for the footnote. | [
"This",
"method",
"inserts",
"a",
"footnote",
"at",
"the",
"current",
"position",
"in",
"a",
"node",
"."
] | d6455933262a25628006101be802d7f7b2c3feb7 | https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L337-L345 | valid |
thechrisoshow/rtf | lib/rtf/node.rb | RTF.CommandNode.apply | def apply(style)
# Check the input style.
if !style.is_character_style?
RTFError.fire("Non-character style specified to the "\
"CommandNode#apply() method.")
end
# Store fonts and colours.
root.colours << style.foreground unless style.foreground.nil?
root.colours << style.background unless style.background.nil?
root.fonts << style.font unless style.font.nil?
# Generate the command node.
node = CommandNode.new(self, style.prefix(root.fonts, root.colours))
yield node if block_given?
self.store(node)
end | ruby | def apply(style)
# Check the input style.
if !style.is_character_style?
RTFError.fire("Non-character style specified to the "\
"CommandNode#apply() method.")
end
# Store fonts and colours.
root.colours << style.foreground unless style.foreground.nil?
root.colours << style.background unless style.background.nil?
root.fonts << style.font unless style.font.nil?
# Generate the command node.
node = CommandNode.new(self, style.prefix(root.fonts, root.colours))
yield node if block_given?
self.store(node)
end | [
"def",
"apply",
"(",
"style",
")",
"if",
"!",
"style",
".",
"is_character_style?",
"RTFError",
".",
"fire",
"(",
"\"Non-character style specified to the \"",
"\"CommandNode#apply() method.\"",
")",
"end",
"root",
".",
"colours",
"<<",
"style",
".",
"foreground",
"un... | This method provides a short cut means for applying multiple styles via
single command node. The method accepts a block that will be passed a
reference to the node created. Once the block is complete the new node
will be append as the last child of the CommandNode the method is called
on.
==== Parameters
style:: A reference to a CharacterStyle object that contains the style
settings to be applied.
==== Exceptions
RTFError:: Generated whenever a non-character style is specified to
the method. | [
"This",
"method",
"provides",
"a",
"short",
"cut",
"means",
"for",
"applying",
"multiple",
"styles",
"via",
"single",
"command",
"node",
".",
"The",
"method",
"accepts",
"a",
"block",
"that",
"will",
"be",
"passed",
"a",
"reference",
"to",
"the",
"node",
"... | d6455933262a25628006101be802d7f7b2c3feb7 | https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L373-L389 | valid |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.