_id stringlengths 2 6 | title stringlengths 9 130 | partition stringclasses 3
values | text stringlengths 66 10.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q25500 | Foursquare2.Venues.add_venue | validation | 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 | {
"resource": ""
} |
q25501 | Foursquare2.Venues.mark_venue_todo | validation | 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 | {
"resource": ""
} |
q25502 | Foursquare2.Venues.suggest_completion_venues | validation | 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 | {
"resource": ""
} |
q25503 | Foursquare2.Venues.venue_menus | validation | 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 | {
"resource": ""
} |
q25504 | Foursquare2.Venues.venues_timeseries | validation | 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 | {
"resource": ""
} |
q25505 | Foursquare2.Settings.update_setting | validation | 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 | {
"resource": ""
} |
q25506 | Foursquare2.Photos.photo | validation | 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 | {
"resource": ""
} |
q25507 | Foursquare2.Photos.add_photo | validation | def add_photo(options={})
response = connection.post('photos/add', options)
return_error_or_body(response, response.body.response.photo)
end | ruby | {
"resource": ""
} |
q25508 | Foursquare2.Photos.venue_photos | validation | 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 | {
"resource": ""
} |
q25509 | Parse.CollectionProxy.forward | validation | def forward(method, params = nil)
return unless @delegate && @delegate.respond_to?(method)
params.nil? ? @delegate.send(method) : @delegate.send(method, params)
end | ruby | {
"resource": ""
} |
q25510 | Parse.CollectionProxy.add | validation | def add(*items)
notify_will_change! if items.count > 0
items.each do |item|
collection.push item
end
@collection
end | ruby | {
"resource": ""
} |
q25511 | Parse.CollectionProxy.<< | validation | def <<(*list)
if list.count > 0
notify_will_change!
list.flatten.each { |e| collection.push(e) }
end
end | ruby | {
"resource": ""
} |
q25512 | Parse.Properties.format_value | validation | 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)
... | ruby | {
"resource": ""
} |
q25513 | Parse.RelationCollectionProxy.all | validation | 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.pres... | ruby | {
"resource": ""
} |
q25514 | Parse.Object.twin | validation | def twin
h = self.as_json
h.delete(Parse::Model::OBJECT_ID)
h.delete(:objectId)
h.delete(:id)
self.class.new h
end | ruby | {
"resource": ""
} |
q25515 | Parse.File.save | validation | 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]
... | ruby | {
"resource": ""
} |
q25516 | Parse.Push.where | validation | def where(constraints = nil)
return query.compile_where unless constraints.is_a?(Hash)
query.where constraints
query
end | ruby | {
"resource": ""
} |
q25517 | Parse.Push.payload | validation | 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?
... | ruby | {
"resource": ""
} |
q25518 | Parse.Push.send | validation | 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 | {
"resource": ""
} |
q25519 | Parse.Query.distinct | validation | 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_... | ruby | {
"resource": ""
} |
q25520 | Parse.Query.fetch! | validation | 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 | {
"resource": ""
} |
q25521 | Parse.Query.decode | validation | def decode(list)
list.map { |m| Parse::Object.build(m, @table) }.compact
end | ruby | {
"resource": ""
} |
q25522 | Parse.Query.compile | validation | 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 @... | ruby | {
"resource": ""
} |
q25523 | Parse.Client.get | validation | def get(uri, query = nil, headers = {})
request :get, uri, query: query, headers: headers
end | ruby | {
"resource": ""
} |
q25524 | Parse.Client.post | validation | def post(uri, body = nil, headers = {} )
request :post, uri, body: body, headers: headers
end | ruby | {
"resource": ""
} |
q25525 | Parse.Client.put | validation | def put(uri, body = nil, headers = {})
request :put, uri, body: body, headers: headers
end | ruby | {
"resource": ""
} |
q25526 | Parse.Client.delete | validation | def delete(uri, body = nil, headers = {})
request :delete, uri, body: body, headers: headers
end | ruby | {
"resource": ""
} |
q25527 | Parse.ACL.delete | validation | 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 | {
"resource": ""
} |
q25528 | Parse.ACL.all_read! | validation | def all_read!
will_change!
permissions.keys.each do |perm|
permissions[perm].read! true
end
end | ruby | {
"resource": ""
} |
q25529 | Parse.ACL.all_write! | validation | def all_write!
will_change!
permissions.keys.each do |perm|
permissions[perm].write! true
end
end | ruby | {
"resource": ""
} |
q25530 | Parse.ACL.no_read! | validation | def no_read!
will_change!
permissions.keys.each do |perm|
permissions[perm].read! false
end
end | ruby | {
"resource": ""
} |
q25531 | Parse.ACL.no_write! | validation | def no_write!
will_change!
permissions.keys.each do |perm|
permissions[perm].write! false
end
end | ruby | {
"resource": ""
} |
q25532 | Parse.Response.batch_responses | validation | 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 | {
"resource": ""
} |
q25533 | Parse.Response.parse_result! | validation | 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 | {
"resource": ""
} |
q25534 | Parse.User.link_auth_data! | validation | 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 | {
"resource": ""
} |
q25535 | Parse.User.signup! | validation | 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 = ... | ruby | {
"resource": ""
} |
q25536 | Parse.User.login! | validation | 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 | {
"resource": ""
} |
q25537 | Parse.User.logout | validation | def logout
return true if self.session_token.blank?
client.logout session_token
self.session_token = nil
true
rescue => e
false
end | ruby | {
"resource": ""
} |
q25538 | Parse.Query.first_or_create | validation | 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.fir... | ruby | {
"resource": ""
} |
q25539 | Parse.Query.save_all | validation | 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, &Pr... | ruby | {
"resource": ""
} |
q25540 | RTF.FontTable.add | validation | def add(font)
if font.instance_of?(Font)
@fonts.push(font) if @fonts.index(font).nil?
end
self
end | ruby | {
"resource": ""
} |
q25541 | RTF.FontTable.to_rtf | validation | 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.strin... | ruby | {
"resource": ""
} |
q25542 | RTF.Node.previous_node | validation | 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 | {
"resource": ""
} |
q25543 | RTF.Node.next_node | validation | 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 | {
"resource": ""
} |
q25544 | RTF.TextNode.insert | validation | 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 | {
"resource": ""
} |
q25545 | RTF.TextNode.to_rtf | validation | 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" }
# E... | ruby | {
"resource": ""
} |
q25546 | RTF.ContainerNode.store | validation | def store(node)
if !node.nil?
@children.push(node) if !@children.include?(Node)
node.parent = self if node.parent != self
end
node
end | ruby | {
"resource": ""
} |
q25547 | RTF.CommandNode.<< | validation | def <<(text)
if !last.nil? and last.respond_to?(:text=)
last.append(text)
else
self.store(TextNode.new(self, text))
end
end | ruby | {
"resource": ""
} |
q25548 | RTF.CommandNode.to_rtf | validation | 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 << '}' ... | ruby | {
"resource": ""
} |
q25549 | RTF.CommandNode.paragraph | validation | def paragraph(style=nil)
node = ParagraphNode.new(self, style)
yield node if block_given?
self.store(node)
end | ruby | {
"resource": ""
} |
q25550 | RTF.CommandNode.list | validation | def list(kind=:bullets)
node = ListNode.new(self)
yield node.list(kind)
self.store(node)
end | ruby | {
"resource": ""
} |
q25551 | RTF.CommandNode.footnote | validation | 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
... | ruby | {
"resource": ""
} |
q25552 | RTF.CommandNode.apply | validation | 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.f... | ruby | {
"resource": ""
} |
q25553 | RTF.CommandNode.bold | validation | def bold
style = CharacterStyle.new
style.bold = true
if block_given?
apply(style) {|node| yield node}
else
apply(style)
end
end | ruby | {
"resource": ""
} |
q25554 | RTF.CommandNode.italic | validation | def italic
style = CharacterStyle.new
style.italic = true
if block_given?
apply(style) {|node| yield node}
else
apply(style)
end
end | ruby | {
"resource": ""
} |
q25555 | RTF.CommandNode.underline | validation | def underline
style = CharacterStyle.new
style.underline = true
if block_given?
apply(style) {|node| yield node}
else
apply(style)
end
end | ruby | {
"resource": ""
} |
q25556 | RTF.CommandNode.subscript | validation | def subscript
style = CharacterStyle.new
style.subscript = true
if block_given?
apply(style) {|node| yield node}
else
apply(style)
end
end | ruby | {
"resource": ""
} |
q25557 | RTF.CommandNode.superscript | validation | def superscript
style = CharacterStyle.new
style.superscript = true
if block_given?
apply(style) {|node| yield node}
else
apply(style)
end
end | ruby | {
"resource": ""
} |
q25558 | RTF.CommandNode.strike | validation | def strike
style = CharacterStyle.new
style.strike = true
if block_given?
apply(style) {|node| yield node}
else
apply(style)
end
end | ruby | {
"resource": ""
} |
q25559 | RTF.CommandNode.font | validation | def font(font, size=nil)
style = CharacterStyle.new
style.font = font
style.font_size = size
root.fonts << font
if block_given?
apply(style) {|node| yield node}
else
apply(style)
end
end | ruby | {
"resource": ""
} |
q25560 | RTF.CommandNode.foreground | validation | def foreground(colour)
style = CharacterStyle.new
style.foreground = colour
root.colours << colour
if block_given?
apply(style) {|node| yield node}
else
apply(style)
end
end | ruby | {
"resource": ""
} |
q25561 | RTF.CommandNode.colour | validation | def colour(fore, back)
style = CharacterStyle.new
style.foreground = fore
style.background = back
root.colours << fore
root.colours << back
if block_given?
apply(style) {|node| yield node}
else
apply(style)
end
... | ruby | {
"resource": ""
} |
q25562 | RTF.CommandNode.table | validation | def table(rows, columns, *widths)
node = TableNode.new(self, rows, columns, *widths)
yield node if block_given?
store(node)
node
end | ruby | {
"resource": ""
} |
q25563 | RTF.ListLevelNode.list | validation | def list(kind=@kind)
node = ListLevelNode.new(self, @template, kind, @level.level+1)
yield node
self.store(node)
end | ruby | {
"resource": ""
} |
q25564 | RTF.TableNode.column_shading_colour | validation | def column_shading_colour(index, colour)
self.each do |row|
cell = row[index]
cell.shading_colour = colour if cell != nil
end
end | ruby | {
"resource": ""
} |
q25565 | RTF.TableNode.shading_colour | validation | def shading_colour(colour)
if block_given?
0.upto(self.size - 1) do |x|
row = self[x]
0.upto(row.size - 1) do |y|
apply = yield row[y], x, y
row[y].shading_colour = colour if apply
end
end
end
... | ruby | {
"resource": ""
} |
q25566 | RTF.TableRowNode.to_rtf | validation | def to_rtf
text = StringIO.new
temp = StringIO.new
offset = 0
text << "\\trowd\\tgraph#{parent.cell_margin}"
self.each do |entry|
widths = entry.border_widths
colour = entry.shading_colour
text << "\n"
text << "\\clbrdrt\... | ruby | {
"resource": ""
} |
q25567 | RTF.TableCellNode.border_width= | validation | def border_width=(width)
size = width.nil? ? 0 : width
if size > 0
@borders[TOP] = @borders[RIGHT] = @borders[BOTTOM] = @borders[LEFT] = size.to_i
else
@borders = [nil, nil, nil, nil]
end
end | ruby | {
"resource": ""
} |
q25568 | RTF.TableCellNode.top_border_width= | validation | def top_border_width=(width)
size = width.nil? ? 0 : width
if size > 0
@borders[TOP] = size.to_i
else
@borders[TOP] = nil
end
end | ruby | {
"resource": ""
} |
q25569 | RTF.TableCellNode.right_border_width= | validation | def right_border_width=(width)
size = width.nil? ? 0 : width
if size > 0
@borders[RIGHT] = size.to_i
else
@borders[RIGHT] = nil
end
end | ruby | {
"resource": ""
} |
q25570 | RTF.TableCellNode.bottom_border_width= | validation | def bottom_border_width=(width)
size = width.nil? ? 0 : width
if size > 0
@borders[BOTTOM] = size.to_i
else
@borders[BOTTOM] = nil
end
end | ruby | {
"resource": ""
} |
q25571 | RTF.TableCellNode.left_border_width= | validation | def left_border_width=(width)
size = width.nil? ? 0 : width
if size > 0
@borders[LEFT] = size.to_i
else
@borders[LEFT] = nil
end
end | ruby | {
"resource": ""
} |
q25572 | RTF.TableCellNode.border_widths | validation | def border_widths
widths = []
@borders.each {|entry| widths.push(entry.nil? ? 0 : entry)}
widths
end | ruby | {
"resource": ""
} |
q25573 | RTF.ImageNode.get_file_type | validation | def get_file_type
type = nil
read = []
open_file do |file|
# Check if the file is a JPEG.
read_source(file, read, 2)
if read[0,2] == [255, 216]
type = JPEG
else
# Check if it's a PNG.
read_source(file, read... | ruby | {
"resource": ""
} |
q25574 | RTF.ImageNode.to_rtf | validation | def to_rtf
text = StringIO.new
count = 0
#text << '{\pard{\*\shppict{\pict'
text << '{\*\shppict{\pict'
text << "\\picscalex#{@x_scaling}" if @x_scaling != nil
text << "\\picscaley#{@y_scaling}" if @y_scaling != nil
text << "\\piccropl#{@left_crop}" if @left_c... | ruby | {
"resource": ""
} |
q25575 | RTF.ImageNode.to_integer | validation | def to_integer(array, signed=false)
from = nil
to = nil
data = []
if array.size == 2
data.concat(get_endian == BIG_ENDIAN ? array.reverse : array)
from = 'C2'
to = signed ? 's' : 'S'
else
data.concat(get_endian == BIG_ENDI... | ruby | {
"resource": ""
} |
q25576 | RTF.ImageNode.read_source | validation | def read_source(file, read, size=nil)
if block_given?
done = false
while !done and !file.eof?
read << file.getbyte
done = yield read[-1]
end
else
if size != nil
if size > 0
total = 0
... | ruby | {
"resource": ""
} |
q25577 | RTF.ImageNode.get_dimensions | validation | def get_dimensions
dimensions = nil
open_file do |file|
file.pos = DIMENSIONS_OFFSET[@type]
read = []
# Check the image type.
if @type == JPEG
# Read until we can't anymore or we've found what we're looking for.
done = false
... | ruby | {
"resource": ""
} |
q25578 | RTF.Document.header= | validation | def header=(header)
if header.type == HeaderNode::UNIVERSAL
@headers[0] = header
elsif header.type == HeaderNode::LEFT_PAGE
@headers[1] = header
elsif header.type == HeaderNode::RIGHT_PAGE
@headers[2] = header
elsif header.type == HeaderNode::FIRST... | ruby | {
"resource": ""
} |
q25579 | RTF.Document.footer= | validation | def footer=(footer)
if footer.type == FooterNode::UNIVERSAL
@footers[0] = footer
elsif footer.type == FooterNode::LEFT_PAGE
@footers[1] = footer
elsif footer.type == FooterNode::RIGHT_PAGE
@footers[2] = footer
elsif footer.type == FooterNode::FIRST... | ruby | {
"resource": ""
} |
q25580 | RTF.Document.header | validation | def header(type=HeaderNode::UNIVERSAL)
index = 0
if type == HeaderNode::LEFT_PAGE
index = 1
elsif type == HeaderNode::RIGHT_PAGE
index = 2
elsif type == HeaderNode::FIRST_PAGE
index = 3
end
@headers[index]
end | ruby | {
"resource": ""
} |
q25581 | RTF.Document.footer | validation | def footer(type=FooterNode::UNIVERSAL)
index = 0
if type == FooterNode::LEFT_PAGE
index = 1
elsif type == FooterNode::RIGHT_PAGE
index = 2
elsif type == FooterNode::FIRST_PAGE
index = 3
end
@footers[index]
end | ruby | {
"resource": ""
} |
q25582 | RTF.Document.to_rtf | validation | def to_rtf
text = StringIO.new
text << "{#{prefix}\\#{@character_set.id2name}"
text << "\\deff#{@default_font}"
text << "\\deflang#{@language}" if !@language.nil?
text << "\\plain\\fs24\\fet1"
text << "\n#{@fonts.to_rtf}"
text << "\n#{@colours.to_rtf}" if ... | ruby | {
"resource": ""
} |
q25583 | RTF.ColourTable.add | validation | def add(colour)
if colour.instance_of?(Colour)
@colours.push(colour) if @colours.index(colour).nil?
end
self
end | ruby | {
"resource": ""
} |
q25584 | RTF.ColourTable.to_s | validation | def to_s(indent=0)
prefix = indent > 0 ? ' ' * indent : ''
text = StringIO.new
text << "#{prefix}Colour Table (#{@colours.size} colours)"
@colours.each {|colour| text << "\n#{prefix} #{colour}"}
text.string
end | ruby | {
"resource": ""
} |
q25585 | RTF.Information.created= | validation | def created=(setting)
if setting.instance_of?(Time)
@created = setting
else
datetime = Date._parse(setting.to_s).values_at(:year, :mon, :mday, :hour, :min, :sec, :zone, :wday)
if datetime == nil
RTFError.fire("Invalid document creation date/time ... | ruby | {
"resource": ""
} |
q25586 | RTF.Information.to_s | validation | def to_s(indent=0)
prefix = indent > 0 ? ' ' * indent : ''
text = StringIO.new
text << "#{prefix}Information"
text << "\n#{prefix} Title: #{@title}" unless @title.nil?
text << "\n#{prefix} Author: #{@author}" unless @author.nil?
text << "\n#{... | ruby | {
"resource": ""
} |
q25587 | RTF.Information.to_rtf | validation | def to_rtf(indent=0)
prefix = indent > 0 ? ' ' * indent : ''
text = StringIO.new
text << "#{prefix}{\\info"
text << "\n#{prefix}{\\title #{@title}}" unless @title.nil?
text << "\n#{prefix}{\\author #{@author}}" unless @author.nil?
text << "\n#{pr... | ruby | {
"resource": ""
} |
q25588 | SpiderGazelle.Signaller.process_request | validation | def process_request(data, client)
validated = @validated.include?(client)
parser = @validating[client.object_id]
if validated
parser.process data
else
result = parser.signal(data)
case result
when :validate... | ruby | {
"resource": ""
} |
q25589 | SpiderGazelle.Reactor.log | validation | def log(error, context, trace = nil)
msg = String.new
if error.respond_to?(:backtrace)
msg << "unhandled exception: #{error.message} (#{context})"
backtrace = error.backtrace
msg << "\n#{backtrace.join("\n")}" if backtrace
msg << "\... | ruby | {
"resource": ""
} |
q25590 | SpiderGazelle.Spider.ready | validation | def ready
load_promise = load_applications
load_promise.then do
# Check a shutdown request didn't occur as we were loading
if @running
@logger.verbose "All gazelles running"
# This happends on the master thread so we don't ... | ruby | {
"resource": ""
} |
q25591 | HIDAPI.Engine.enumerate | validation | def enumerate(vendor_id = 0, product_id = 0, options = {})
raise HIDAPI::HidApiError, 'not initialized' unless @context
if vendor_id.is_a?(Hash) || (vendor_id.is_a?(String) && options.empty?)
options = vendor_id
vendor_id = 0
product_id = 0
end
if product_id.is_a?(Hash)... | ruby | {
"resource": ""
} |
q25592 | HIDAPI.Engine.get_device | validation | def get_device(vendor_id, product_id, serial_number = nil, options = {})
raise ArgumentError, 'vendor_id must be provided' if vendor_id.to_i == 0
raise ArgumentError, 'product_id must be provided' if product_id.to_i == 0
if serial_number.is_a?(Hash)
options = serial_number
serial_numb... | ruby | {
"resource": ""
} |
q25593 | HIDAPI.Engine.open | validation | def open(vendor_id, product_id, serial_number = nil, options = {})
dev = get_device(vendor_id, product_id, serial_number, options)
dev.open if dev
end | ruby | {
"resource": ""
} |
q25594 | HIDAPI.Engine.get_device_by_path | validation | def get_device_by_path(path, options = {})
# Our linux setup routine creates convenient /dev/hidapi/* links.
# If the user wants to open one of those, we can simple parse the link to generate
# the path that the library expects.
if File.exist?(path)
hidapi_regex = /^\/dev\/hidapi\//
... | ruby | {
"resource": ""
} |
q25595 | HIDAPI.Engine.open_path | validation | def open_path(path, options = {})
dev = get_device_by_path(path, options)
dev.open if dev
end | ruby | {
"resource": ""
} |
q25596 | HIDAPI.Engine.usb_code_for_current_locale | validation | def usb_code_for_current_locale
@usb_code_for_current_locale ||=
begin
locale = I18n.locale
if locale
locale = locale.to_s.partition('.')[0] # remove encoding
result = HIDAPI::Language.get_by_code(locale)
unless result
lo... | ruby | {
"resource": ""
} |
q25597 | HIDAPI.Device.open | validation | def open
if open?
self.open_count += 1
if open_count < 1
HIDAPI.debug "open_count for open device #{path} is #{open_count}"
self.open_count = 1
end
return self
end
self.open_count = 0
begin
self.handle = usb_device.open
raise 'n... | ruby | {
"resource": ""
} |
q25598 | HIDAPI.Device.read_timeout | validation | def read_timeout(milliseconds)
raise DeviceNotOpen unless open?
mutex.synchronize do
if input_reports.count > 0
data = input_reports.delete_at(0)
HIDAPI.debug "read data from device #{path}: #{data.inspect}"
return data
end
if shutdown_thread
... | ruby | {
"resource": ""
} |
q25599 | HIDAPI.Device.send_feature_report | validation | def send_feature_report(data)
raise ArgumentError, 'data must not be blank' if data.nil? || data.length < 1
raise HIDAPI::DeviceNotOpen unless open?
data, report_number, skipped_report_id = clean_output_data(data)
mutex.synchronize do
handle.control_transfer(
bmRequestType:... | ruby | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.