repo
stringlengths
5
58
path
stringlengths
9
168
func_name
stringlengths
9
130
original_string
stringlengths
66
10.5k
language
stringclasses
1 value
code
stringlengths
66
10.5k
code_tokens
list
docstring
stringlengths
8
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
94
266
partition
stringclasses
1 value
chrislee35/dnsbl-client
lib/dnsbl/client.rb
DNSBL.Client.lookup
def lookup(item) # if item is an array, use it, otherwise make it one items = item if item.is_a? String items = [item] end # place the results in the results array results = [] # for each ip or hostname items.each do |item| # sent is used to determine when we have all the answers sen...
ruby
def lookup(item) # if item is an array, use it, otherwise make it one items = item if item.is_a? String items = [item] end # place the results in the results array results = [] # for each ip or hostname items.each do |item| # sent is used to determine when we have all the answers sen...
[ "def", "lookup", "(", "item", ")", "items", "=", "item", "if", "item", ".", "is_a?", "String", "items", "=", "[", "item", "]", "end", "results", "=", "[", "]", "items", ".", "each", "do", "|", "item", "|", "sent", "=", "0", "@starttime", "=", "Ti...
lookup performs the sending of DNS queries for the given items returns an array of DNSBLResult
[ "lookup", "performs", "the", "sending", "of", "DNS", "queries", "for", "the", "given", "items", "returns", "an", "array", "of", "DNSBLResult" ]
d88bb5eae3dfd03c418f67ae5767234a862a92b8
https://github.com/chrislee35/dnsbl-client/blob/d88bb5eae3dfd03c418f67ae5767234a862a92b8/lib/dnsbl/client.rb#L129-L181
train
chrislee35/dnsbl-client
lib/dnsbl/client.rb
DNSBL.Client._decode_response
def _decode_response(buf) reply = Resolv::DNS::Message.decode(buf) results = [] reply.each_answer do |name,ttl,data| if name.to_s =~ /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(.+)$/ ip = [$4,$3,$2,$1].join(".") domain = $5 @dnsbls.each do |dnsblname, config| next unless data.is_a? ...
ruby
def _decode_response(buf) reply = Resolv::DNS::Message.decode(buf) results = [] reply.each_answer do |name,ttl,data| if name.to_s =~ /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(.+)$/ ip = [$4,$3,$2,$1].join(".") domain = $5 @dnsbls.each do |dnsblname, config| next unless data.is_a? ...
[ "def", "_decode_response", "(", "buf", ")", "reply", "=", "Resolv", "::", "DNS", "::", "Message", ".", "decode", "(", "buf", ")", "results", "=", "[", "]", "reply", ".", "each_answer", "do", "|", "name", ",", "ttl", ",", "data", "|", "if", "name", ...
takes a DNS response and converts it into a DNSBLResult
[ "takes", "a", "DNS", "response", "and", "converts", "it", "into", "a", "DNSBLResult" ]
d88bb5eae3dfd03c418f67ae5767234a862a92b8
https://github.com/chrislee35/dnsbl-client/blob/d88bb5eae3dfd03c418f67ae5767234a862a92b8/lib/dnsbl/client.rb#L186-L219
train
chrislee35/dnsbl-client
lib/dnsbl/client.rb
DNSBL.Client.__phpot_decoder
def __phpot_decoder(ip) octets = ip.split(/\./) if octets.length != 4 or octets[0] != "127" return "invalid response" elsif octets[3] == "0" search_engines = ["undocumented", "AltaVista", "Ask", "Baidu", "Excite", "Google", "Looksmart", "Lycos", "MSN", "Yahoo", "Cuil", "InfoSeek", "Miscellaneous"] ...
ruby
def __phpot_decoder(ip) octets = ip.split(/\./) if octets.length != 4 or octets[0] != "127" return "invalid response" elsif octets[3] == "0" search_engines = ["undocumented", "AltaVista", "Ask", "Baidu", "Excite", "Google", "Looksmart", "Lycos", "MSN", "Yahoo", "Cuil", "InfoSeek", "Miscellaneous"] ...
[ "def", "__phpot_decoder", "(", "ip", ")", "octets", "=", "ip", ".", "split", "(", "/", "\\.", "/", ")", "if", "octets", ".", "length", "!=", "4", "or", "octets", "[", "0", "]", "!=", "\"127\"", "return", "\"invalid response\"", "elsif", "octets", "[", ...
decodes the response from Project Honey Pot's service
[ "decodes", "the", "response", "from", "Project", "Honey", "Pot", "s", "service" ]
d88bb5eae3dfd03c418f67ae5767234a862a92b8
https://github.com/chrislee35/dnsbl-client/blob/d88bb5eae3dfd03c418f67ae5767234a862a92b8/lib/dnsbl/client.rb#L222-L253
train
jgoizueta/flt
lib/flt/support/flag_values.rb
Flt.Support.FlagValues
def FlagValues(*params) if params.size==1 && params.first.kind_of?(FlagValues) params.first else FlagValues.new(*params) end end
ruby
def FlagValues(*params) if params.size==1 && params.first.kind_of?(FlagValues) params.first else FlagValues.new(*params) end end
[ "def", "FlagValues", "(", "*", "params", ")", "if", "params", ".", "size", "==", "1", "&&", "params", ".", "first", ".", "kind_of?", "(", "FlagValues", ")", "params", ".", "first", "else", "FlagValues", ".", "new", "(", "*", "params", ")", "end", "en...
Constructor for FlagValues
[ "Constructor", "for", "FlagValues" ]
068869cfb81fe339658348490f4ea1294facfffa
https://github.com/jgoizueta/flt/blob/068869cfb81fe339658348490f4ea1294facfffa/lib/flt/support/flag_values.rb#L322-L328
train
jgoizueta/flt
lib/flt/support/flag_values.rb
Flt.Support.Flags
def Flags(*params) if params.size==1 && params.first.kind_of?(Flags) params.first else Flags.new(*params) end end
ruby
def Flags(*params) if params.size==1 && params.first.kind_of?(Flags) params.first else Flags.new(*params) end end
[ "def", "Flags", "(", "*", "params", ")", "if", "params", ".", "size", "==", "1", "&&", "params", ".", "first", ".", "kind_of?", "(", "Flags", ")", "params", ".", "first", "else", "Flags", ".", "new", "(", "*", "params", ")", "end", "end" ]
Constructor for Flags
[ "Constructor", "for", "Flags" ]
068869cfb81fe339658348490f4ea1294facfffa
https://github.com/jgoizueta/flt/blob/068869cfb81fe339658348490f4ea1294facfffa/lib/flt/support/flag_values.rb#L331-L337
train
jgoizueta/flt
lib/flt/tolerance.rb
Flt.Tolerance.integer
def integer(x) # return integer?(x) ? x.round : nil r = x.round ((x-r).abs <= relative_to(x)) ? r : nil end
ruby
def integer(x) # return integer?(x) ? x.round : nil r = x.round ((x-r).abs <= relative_to(x)) ? r : nil end
[ "def", "integer", "(", "x", ")", "r", "=", "x", ".", "round", "(", "(", "x", "-", "r", ")", ".", "abs", "<=", "relative_to", "(", "x", ")", ")", "?", "r", ":", "nil", "end" ]
If the argument is close to an integer it rounds it
[ "If", "the", "argument", "is", "close", "to", "an", "integer", "it", "rounds", "it" ]
068869cfb81fe339658348490f4ea1294facfffa
https://github.com/jgoizueta/flt/blob/068869cfb81fe339658348490f4ea1294facfffa/lib/flt/tolerance.rb#L135-L139
train
muffinista/gopher2000
lib/gopher2000/dsl.rb
Gopher.DSL.mount
def mount(path, opts = {}) route, folder = path.first # # if path has more than the one option (:route => :folder), # then incorporate the rest of the hash into our opts # if path.size > 1 other_opts = path.dup other_opts.delete(route) opts = opts.merge(other...
ruby
def mount(path, opts = {}) route, folder = path.first # # if path has more than the one option (:route => :folder), # then incorporate the rest of the hash into our opts # if path.size > 1 other_opts = path.dup other_opts.delete(route) opts = opts.merge(other...
[ "def", "mount", "(", "path", ",", "opts", "=", "{", "}", ")", "route", ",", "folder", "=", "path", ".", "first", "if", "path", ".", "size", ">", "1", "other_opts", "=", "path", ".", "dup", "other_opts", ".", "delete", "(", "route", ")", "opts", "...
mount a folder for browsing
[ "mount", "a", "folder", "for", "browsing" ]
0b5333c368b307772a41b4bc77b208d5c3f9196b
https://github.com/muffinista/gopher2000/blob/0b5333c368b307772a41b4bc77b208d5c3f9196b/lib/gopher2000/dsl.rb#L43-L57
train
muffinista/gopher2000
lib/gopher2000/response.rb
Gopher.Response.size
def size case self.body when String then self.body.length when StringIO then self.body.length when File then self.body.size else 0 end end
ruby
def size case self.body when String then self.body.length when StringIO then self.body.length when File then self.body.size else 0 end end
[ "def", "size", "case", "self", ".", "body", "when", "String", "then", "self", ".", "body", ".", "length", "when", "StringIO", "then", "self", ".", "body", ".", "length", "when", "File", "then", "self", ".", "body", ".", "size", "else", "0", "end", "e...
get the size, in bytes, of the response. used for logging @return [Integer] size
[ "get", "the", "size", "in", "bytes", "of", "the", "response", ".", "used", "for", "logging" ]
0b5333c368b307772a41b4bc77b208d5c3f9196b
https://github.com/muffinista/gopher2000/blob/0b5333c368b307772a41b4bc77b208d5c3f9196b/lib/gopher2000/response.rb#L16-L23
train
muffinista/gopher2000
lib/gopher2000/server.rb
Gopher.Server.run!
def run! EventMachine::run do Signal.trap("INT") { puts "It's a trap!" EventMachine.stop } Signal.trap("TERM") { puts "It's a trap!" EventMachine.stop } EventMachine.kqueue = true if EventMachine.kqueue? EventMachine.epoll = ...
ruby
def run! EventMachine::run do Signal.trap("INT") { puts "It's a trap!" EventMachine.stop } Signal.trap("TERM") { puts "It's a trap!" EventMachine.stop } EventMachine.kqueue = true if EventMachine.kqueue? EventMachine.epoll = ...
[ "def", "run!", "EventMachine", "::", "run", "do", "Signal", ".", "trap", "(", "\"INT\"", ")", "{", "puts", "\"It's a trap!\"", "EventMachine", ".", "stop", "}", "Signal", ".", "trap", "(", "\"TERM\"", ")", "{", "puts", "\"It's a trap!\"", "EventMachine", "."...
main app loop. called via at_exit block defined in DSL
[ "main", "app", "loop", ".", "called", "via", "at_exit", "block", "defined", "in", "DSL" ]
0b5333c368b307772a41b4bc77b208d5c3f9196b
https://github.com/muffinista/gopher2000/blob/0b5333c368b307772a41b4bc77b208d5c3f9196b/lib/gopher2000/server.rb#L34-L70
train
muffinista/gopher2000
lib/gopher2000/base.rb
Gopher.Application.should_reload?
def should_reload? ! last_reload.nil? && self.scripts.any? do |f| File.mtime(f) > last_reload end end
ruby
def should_reload? ! last_reload.nil? && self.scripts.any? do |f| File.mtime(f) > last_reload end end
[ "def", "should_reload?", "!", "last_reload", ".", "nil?", "&&", "self", ".", "scripts", ".", "any?", "do", "|", "f", "|", "File", ".", "mtime", "(", "f", ")", ">", "last_reload", "end", "end" ]
check if our script has been updated since the last reload
[ "check", "if", "our", "script", "has", "been", "updated", "since", "the", "last", "reload" ]
0b5333c368b307772a41b4bc77b208d5c3f9196b
https://github.com/muffinista/gopher2000/blob/0b5333c368b307772a41b4bc77b208d5c3f9196b/lib/gopher2000/base.rb#L68-L72
train
muffinista/gopher2000
lib/gopher2000/base.rb
Gopher.Application.reload_stale
def reload_stale reload_check = should_reload? self.last_reload = Time.now return if ! reload_check reset! self.scripts.each do |f| debug_log "reload #{f}" load f end end
ruby
def reload_stale reload_check = should_reload? self.last_reload = Time.now return if ! reload_check reset! self.scripts.each do |f| debug_log "reload #{f}" load f end end
[ "def", "reload_stale", "reload_check", "=", "should_reload?", "self", ".", "last_reload", "=", "Time", ".", "now", "return", "if", "!", "reload_check", "reset!", "self", ".", "scripts", ".", "each", "do", "|", "f", "|", "debug_log", "\"reload #{f}\"", "load", ...
reload scripts if needed
[ "reload", "scripts", "if", "needed" ]
0b5333c368b307772a41b4bc77b208d5c3f9196b
https://github.com/muffinista/gopher2000/blob/0b5333c368b307772a41b4bc77b208d5c3f9196b/lib/gopher2000/base.rb#L77-L88
train
muffinista/gopher2000
lib/gopher2000/base.rb
Gopher.Application.mount
def mount(path, opts = {}, klass = Gopher::Handlers::DirectoryHandler) debug_log "MOUNT #{path} #{opts.inspect}" opts[:mount_point] = path handler = klass.new(opts) handler.application = self # # add a route for the mounted class # route(globify(path)) do # when...
ruby
def mount(path, opts = {}, klass = Gopher::Handlers::DirectoryHandler) debug_log "MOUNT #{path} #{opts.inspect}" opts[:mount_point] = path handler = klass.new(opts) handler.application = self # # add a route for the mounted class # route(globify(path)) do # when...
[ "def", "mount", "(", "path", ",", "opts", "=", "{", "}", ",", "klass", "=", "Gopher", "::", "Handlers", "::", "DirectoryHandler", ")", "debug_log", "\"MOUNT #{path} #{opts.inspect}\"", "opts", "[", ":mount_point", "]", "=", "path", "handler", "=", "klass", "...
mount a directory for browsing via gopher @param [Hash] path A hash specifying the path your route will answer to, and the filesystem path to use '/route' => '/home/path/etc' @param [Hash] opts a hash of options for the mount. Primarily this is a filter, which will restrict the list files outputted. example: :filter...
[ "mount", "a", "directory", "for", "browsing", "via", "gopher" ]
0b5333c368b307772a41b4bc77b208d5c3f9196b
https://github.com/muffinista/gopher2000/blob/0b5333c368b307772a41b4bc77b208d5c3f9196b/lib/gopher2000/base.rb#L101-L116
train
muffinista/gopher2000
lib/gopher2000/base.rb
Gopher.Application.lookup
def lookup(selector) unless routes.nil? routes.each do |pattern, keys, block| if match = pattern.match(selector) match = match.to_a url = match.shift params = to_params_hash(keys, match) # # @todo think about this # ...
ruby
def lookup(selector) unless routes.nil? routes.each do |pattern, keys, block| if match = pattern.match(selector) match = match.to_a url = match.shift params = to_params_hash(keys, match) # # @todo think about this # ...
[ "def", "lookup", "(", "selector", ")", "unless", "routes", ".", "nil?", "routes", ".", "each", "do", "|", "pattern", ",", "keys", ",", "block", "|", "if", "match", "=", "pattern", ".", "match", "(", "selector", ")", "match", "=", "match", ".", "to_a"...
lookup an incoming path @param [String] selector the selector path of the incoming request
[ "lookup", "an", "incoming", "path" ]
0b5333c368b307772a41b4bc77b208d5c3f9196b
https://github.com/muffinista/gopher2000/blob/0b5333c368b307772a41b4bc77b208d5c3f9196b/lib/gopher2000/base.rb#L163-L188
train
muffinista/gopher2000
lib/gopher2000/base.rb
Gopher.Application.dispatch
def dispatch(req) debug_log(req) response = Response.new @request = req if ! @request.valid? response.body = handle_invalid_request response.code = :error else begin debug_log("do lookup for #{@request.selector}") @params, block = lookup(@reque...
ruby
def dispatch(req) debug_log(req) response = Response.new @request = req if ! @request.valid? response.body = handle_invalid_request response.code = :error else begin debug_log("do lookup for #{@request.selector}") @params, block = lookup(@reque...
[ "def", "dispatch", "(", "req", ")", "debug_log", "(", "req", ")", "response", "=", "Response", ".", "new", "@request", "=", "req", "if", "!", "@request", ".", "valid?", "response", ".", "body", "=", "handle_invalid_request", "response", ".", "code", "=", ...
find and run the first route which matches the incoming request @param [Request] req Gopher::Request object
[ "find", "and", "run", "the", "first", "route", "which", "matches", "the", "incoming", "request" ]
0b5333c368b307772a41b4bc77b208d5c3f9196b
https://github.com/muffinista/gopher2000/blob/0b5333c368b307772a41b4bc77b208d5c3f9196b/lib/gopher2000/base.rb#L195-L230
train
muffinista/gopher2000
lib/gopher2000/base.rb
Gopher.Application.find_template
def find_template(t) x = menus[t] if x return x, Gopher::Rendering::Menu end x = text_templates[t] if x return x, Gopher::Rendering::Text end end
ruby
def find_template(t) x = menus[t] if x return x, Gopher::Rendering::Menu end x = text_templates[t] if x return x, Gopher::Rendering::Text end end
[ "def", "find_template", "(", "t", ")", "x", "=", "menus", "[", "t", "]", "if", "x", "return", "x", ",", "Gopher", "::", "Rendering", "::", "Menu", "end", "x", "=", "text_templates", "[", "t", "]", "if", "x", "return", "x", ",", "Gopher", "::", "R...
find a template @param [String/Symbol] t name of the template @return template block and the class context it should use
[ "find", "a", "template" ]
0b5333c368b307772a41b4bc77b208d5c3f9196b
https://github.com/muffinista/gopher2000/blob/0b5333c368b307772a41b4bc77b208d5c3f9196b/lib/gopher2000/base.rb#L301-L310
train
muffinista/gopher2000
lib/gopher2000/base.rb
Gopher.Application.render
def render(template, *arguments) # # find the right renderer we need # block, handler = find_template(template) raise TemplateNotFound if block.nil? ctx = handler.new(self) ctx.params = @params ctx.request = @request ctx.instance_exec(*arguments, &block) end
ruby
def render(template, *arguments) # # find the right renderer we need # block, handler = find_template(template) raise TemplateNotFound if block.nil? ctx = handler.new(self) ctx.params = @params ctx.request = @request ctx.instance_exec(*arguments, &block) end
[ "def", "render", "(", "template", ",", "*", "arguments", ")", "block", ",", "handler", "=", "find_template", "(", "template", ")", "raise", "TemplateNotFound", "if", "block", ".", "nil?", "ctx", "=", "handler", ".", "new", "(", "self", ")", "ctx", ".", ...
Find the desired template and call it within the proper context @param [String/Symbol] template name of the template to render @param [Array] arguments optional arguments to be passed to template @return result of rendering
[ "Find", "the", "desired", "template", "and", "call", "it", "within", "the", "proper", "context" ]
0b5333c368b307772a41b4bc77b208d5c3f9196b
https://github.com/muffinista/gopher2000/blob/0b5333c368b307772a41b4bc77b208d5c3f9196b/lib/gopher2000/base.rb#L318-L331
train
muffinista/gopher2000
lib/gopher2000/base.rb
Gopher.Application.compile!
def compile!(path, &block) method_name = path route_method = Application.generate_method(method_name, &block) pattern, keys = compile path [ pattern, keys, route_method ] end
ruby
def compile!(path, &block) method_name = path route_method = Application.generate_method(method_name, &block) pattern, keys = compile path [ pattern, keys, route_method ] end
[ "def", "compile!", "(", "path", ",", "&", "block", ")", "method_name", "=", "path", "route_method", "=", "Application", ".", "generate_method", "(", "method_name", ",", "&", "block", ")", "pattern", ",", "keys", "=", "compile", "path", "[", "pattern", ",",...
compile a route
[ "compile", "a", "route" ]
0b5333c368b307772a41b4bc77b208d5c3f9196b
https://github.com/muffinista/gopher2000/blob/0b5333c368b307772a41b4bc77b208d5c3f9196b/lib/gopher2000/base.rb#L402-L408
train
muffinista/gopher2000
lib/gopher2000/base.rb
Gopher.Application.init_access_log
def init_access_log return if access_log_dest.nil? log = ::Logging.logger['access_log'] pattern = ::Logging.layouts.pattern(:pattern => ACCESS_LOG_PATTERN) log.add_appenders( ::Logging.appenders.rolling_file(access_log_dest, :level => :debug, :age => 'daily', ...
ruby
def init_access_log return if access_log_dest.nil? log = ::Logging.logger['access_log'] pattern = ::Logging.layouts.pattern(:pattern => ACCESS_LOG_PATTERN) log.add_appenders( ::Logging.appenders.rolling_file(access_log_dest, :level => :debug, :age => 'daily', ...
[ "def", "init_access_log", "return", "if", "access_log_dest", ".", "nil?", "log", "=", "::", "Logging", ".", "logger", "[", "'access_log'", "]", "pattern", "=", "::", "Logging", ".", "layouts", ".", "pattern", "(", ":pattern", "=>", "ACCESS_LOG_PATTERN", ")", ...
initialize a Logger for tracking hits to the server
[ "initialize", "a", "Logger", "for", "tracking", "hits", "to", "the", "server" ]
0b5333c368b307772a41b4bc77b208d5c3f9196b
https://github.com/muffinista/gopher2000/blob/0b5333c368b307772a41b4bc77b208d5c3f9196b/lib/gopher2000/base.rb#L514-L528
train
muffinista/gopher2000
lib/gopher2000/base.rb
Gopher.Application.access_log
def access_log(request, response) return if access_log_dest.nil? @@access_logger ||= init_access_log code = response.respond_to?(:code) ? response.code.to_s : "success" size = response.respond_to?(:size) ? response.size : response.length output = [request.ip_address, request.selector, req...
ruby
def access_log(request, response) return if access_log_dest.nil? @@access_logger ||= init_access_log code = response.respond_to?(:code) ? response.code.to_s : "success" size = response.respond_to?(:size) ? response.size : response.length output = [request.ip_address, request.selector, req...
[ "def", "access_log", "(", "request", ",", "response", ")", "return", "if", "access_log_dest", ".", "nil?", "@@access_logger", "||=", "init_access_log", "code", "=", "response", ".", "respond_to?", "(", ":code", ")", "?", "response", ".", "code", ".", "to_s", ...
write out an entry to our access log
[ "write", "out", "an", "entry", "to", "our", "access", "log" ]
0b5333c368b307772a41b4bc77b208d5c3f9196b
https://github.com/muffinista/gopher2000/blob/0b5333c368b307772a41b4bc77b208d5c3f9196b/lib/gopher2000/base.rb#L533-L542
train
muffinista/gopher2000
lib/gopher2000/base.rb
Gopher.Application.to_params_hash
def to_params_hash(keys,values) hash = {} keys.size.times { |i| hash[ keys[i].to_sym ] = values[i] } hash end
ruby
def to_params_hash(keys,values) hash = {} keys.size.times { |i| hash[ keys[i].to_sym ] = values[i] } hash end
[ "def", "to_params_hash", "(", "keys", ",", "values", ")", "hash", "=", "{", "}", "keys", ".", "size", ".", "times", "{", "|", "i", "|", "hash", "[", "keys", "[", "i", "]", ".", "to_sym", "]", "=", "values", "[", "i", "]", "}", "hash", "end" ]
zip up two arrays of keys and values from an incoming request
[ "zip", "up", "two", "arrays", "of", "keys", "and", "values", "from", "an", "incoming", "request" ]
0b5333c368b307772a41b4bc77b208d5c3f9196b
https://github.com/muffinista/gopher2000/blob/0b5333c368b307772a41b4bc77b208d5c3f9196b/lib/gopher2000/base.rb#L548-L552
train
muffinista/gopher2000
lib/gopher2000/dispatcher.rb
Gopher.Dispatcher.call!
def call!(request) operation = proc { app.dispatch(request) } callback = proc {|result| send_response result close_connection_after_writing } # # if we don't want to block on slow calls, use EM#defer # @see http://eventmachine.rubyforge.org/EventMachine...
ruby
def call!(request) operation = proc { app.dispatch(request) } callback = proc {|result| send_response result close_connection_after_writing } # # if we don't want to block on slow calls, use EM#defer # @see http://eventmachine.rubyforge.org/EventMachine...
[ "def", "call!", "(", "request", ")", "operation", "=", "proc", "{", "app", ".", "dispatch", "(", "request", ")", "}", "callback", "=", "proc", "{", "|", "result", "|", "send_response", "result", "close_connection_after_writing", "}", "if", "app", ".", "non...
generate a request object from an incoming selector, and dispatch it to the app @param [Request] request Request object to handle @return Response object
[ "generate", "a", "request", "object", "from", "an", "incoming", "selector", "and", "dispatch", "it", "to", "the", "app" ]
0b5333c368b307772a41b4bc77b208d5c3f9196b
https://github.com/muffinista/gopher2000/blob/0b5333c368b307772a41b4bc77b208d5c3f9196b/lib/gopher2000/dispatcher.rb#L46-L64
train
muffinista/gopher2000
lib/gopher2000/dispatcher.rb
Gopher.Dispatcher.send_response
def send_response(response) case response when Gopher::Response then send_response(response.body) when String then send_data(response + end_of_transmission) when StringIO then send_data(response.read + end_of_transmission) when File while chunk = response.read(8192) do se...
ruby
def send_response(response) case response when Gopher::Response then send_response(response.body) when String then send_data(response + end_of_transmission) when StringIO then send_data(response.read + end_of_transmission) when File while chunk = response.read(8192) do se...
[ "def", "send_response", "(", "response", ")", "case", "response", "when", "Gopher", "::", "Response", "then", "send_response", "(", "response", ".", "body", ")", "when", "String", "then", "send_data", "(", "response", "+", "end_of_transmission", ")", "when", "...
send the response back to the client @param [Response] response object
[ "send", "the", "response", "back", "to", "the", "client" ]
0b5333c368b307772a41b4bc77b208d5c3f9196b
https://github.com/muffinista/gopher2000/blob/0b5333c368b307772a41b4bc77b208d5c3f9196b/lib/gopher2000/dispatcher.rb#L70-L81
train
appsignal/appsignal-ruby
lib/appsignal/auth_check.rb
Appsignal.AuthCheck.perform_with_result
def perform_with_result status = perform result = case status when "200" "AppSignal has confirmed authorization!" when "401" "API key not valid with AppSignal..." else "Could not confirm authorization: " \ "#{status.nil? ? "nil" : sta...
ruby
def perform_with_result status = perform result = case status when "200" "AppSignal has confirmed authorization!" when "401" "API key not valid with AppSignal..." else "Could not confirm authorization: " \ "#{status.nil? ? "nil" : sta...
[ "def", "perform_with_result", "status", "=", "perform", "result", "=", "case", "status", "when", "\"200\"", "\"AppSignal has confirmed authorization!\"", "when", "\"401\"", "\"API key not valid with AppSignal...\"", "else", "\"Could not confirm authorization: \"", "\"#{status.nil? ...
Perform push api validation request and return a descriptive response tuple. @return [Array<String/nil, String>] response tuple. - First value is the response status code. - Second value is a description of the response and the exception error message if an exception occured.
[ "Perform", "push", "api", "validation", "request", "and", "return", "a", "descriptive", "response", "tuple", "." ]
23a07f6f01857a967921adb83deb98b07d160629
https://github.com/appsignal/appsignal-ruby/blob/23a07f6f01857a967921adb83deb98b07d160629/lib/appsignal/auth_check.rb#L48-L65
train
appsignal/appsignal-ruby
lib/appsignal/config.rb
Appsignal.Config.maintain_backwards_compatibility
def maintain_backwards_compatibility(configuration) configuration.tap do |config| DEPRECATED_CONFIG_KEY_MAPPING.each do |old_key, new_key| old_config_value = config.delete(old_key) next unless old_config_value deprecation_message \ "Old configuration key found. Pl...
ruby
def maintain_backwards_compatibility(configuration) configuration.tap do |config| DEPRECATED_CONFIG_KEY_MAPPING.each do |old_key, new_key| old_config_value = config.delete(old_key) next unless old_config_value deprecation_message \ "Old configuration key found. Pl...
[ "def", "maintain_backwards_compatibility", "(", "configuration", ")", "configuration", ".", "tap", "do", "|", "config", "|", "DEPRECATED_CONFIG_KEY_MAPPING", ".", "each", "do", "|", "old_key", ",", "new_key", "|", "old_config_value", "=", "config", ".", "delete", ...
Maintain backwards compatibility with config files generated by earlier versions of the gem Used by {#load_from_disk}. No compatibility for env variables or initial config currently.
[ "Maintain", "backwards", "compatibility", "with", "config", "files", "generated", "by", "earlier", "versions", "of", "the", "gem" ]
23a07f6f01857a967921adb83deb98b07d160629
https://github.com/appsignal/appsignal-ruby/blob/23a07f6f01857a967921adb83deb98b07d160629/lib/appsignal/config.rb#L283-L305
train
appsignal/appsignal-ruby
lib/appsignal/transaction.rb
Appsignal.Transaction.background_queue_start
def background_queue_start env = environment return unless env queue_start = env[:queue_start] return unless queue_start (queue_start.to_f * 1000.0).to_i end
ruby
def background_queue_start env = environment return unless env queue_start = env[:queue_start] return unless queue_start (queue_start.to_f * 1000.0).to_i end
[ "def", "background_queue_start", "env", "=", "environment", "return", "unless", "env", "queue_start", "=", "env", "[", ":queue_start", "]", "return", "unless", "queue_start", "(", "queue_start", ".", "to_f", "*", "1000.0", ")", ".", "to_i", "end" ]
Returns calculated background queue start time in milliseconds, based on environment values. @return [nil] if no {#environment} is present. @return [nil] if there is no `:queue_start` in the {#environment}. @return [Integer]
[ "Returns", "calculated", "background", "queue", "start", "time", "in", "milliseconds", "based", "on", "environment", "values", "." ]
23a07f6f01857a967921adb83deb98b07d160629
https://github.com/appsignal/appsignal-ruby/blob/23a07f6f01857a967921adb83deb98b07d160629/lib/appsignal/transaction.rb#L340-L347
train
appsignal/appsignal-ruby
lib/appsignal/transaction.rb
Appsignal.Transaction.http_queue_start
def http_queue_start env = environment return unless env env_var = env["HTTP_X_QUEUE_START".freeze] || env["HTTP_X_REQUEST_START".freeze] return unless env_var cleaned_value = env_var.tr("^0-9".freeze, "".freeze) return if cleaned_value.empty? value = cleaned_value.to_i ...
ruby
def http_queue_start env = environment return unless env env_var = env["HTTP_X_QUEUE_START".freeze] || env["HTTP_X_REQUEST_START".freeze] return unless env_var cleaned_value = env_var.tr("^0-9".freeze, "".freeze) return if cleaned_value.empty? value = cleaned_value.to_i ...
[ "def", "http_queue_start", "env", "=", "environment", "return", "unless", "env", "env_var", "=", "env", "[", "\"HTTP_X_QUEUE_START\"", ".", "freeze", "]", "||", "env", "[", "\"HTTP_X_REQUEST_START\"", ".", "freeze", "]", "return", "unless", "env_var", "cleaned_val...
Returns HTTP queue start time in milliseconds. @return [nil] if no queue start time is found. @return [nil] if begin time is too low to be plausible. @return [Integer] queue start in milliseconds.
[ "Returns", "HTTP", "queue", "start", "time", "in", "milliseconds", "." ]
23a07f6f01857a967921adb83deb98b07d160629
https://github.com/appsignal/appsignal-ruby/blob/23a07f6f01857a967921adb83deb98b07d160629/lib/appsignal/transaction.rb#L354-L373
train
appsignal/appsignal-ruby
lib/appsignal/transaction.rb
Appsignal.Transaction.sanitized_environment
def sanitized_environment env = environment return if env.empty? {}.tap do |out| Appsignal.config[:request_headers].each do |key| out[key] = env[key] if env[key] end end end
ruby
def sanitized_environment env = environment return if env.empty? {}.tap do |out| Appsignal.config[:request_headers].each do |key| out[key] = env[key] if env[key] end end end
[ "def", "sanitized_environment", "env", "=", "environment", "return", "if", "env", ".", "empty?", "{", "}", ".", "tap", "do", "|", "out", "|", "Appsignal", ".", "config", "[", ":request_headers", "]", ".", "each", "do", "|", "key", "|", "out", "[", "key...
Returns sanitized environment for a transaction. The environment of a transaction can contain a lot of information, not all of it useful for debugging. @return [nil] if no environment is present. @return [Hash<String, Object>]
[ "Returns", "sanitized", "environment", "for", "a", "transaction", "." ]
23a07f6f01857a967921adb83deb98b07d160629
https://github.com/appsignal/appsignal-ruby/blob/23a07f6f01857a967921adb83deb98b07d160629/lib/appsignal/transaction.rb#L401-L410
train
appsignal/appsignal-ruby
lib/appsignal/transaction.rb
Appsignal.Transaction.sanitized_session_data
def sanitized_session_data return if Appsignal.config[:skip_session_data] || !request.respond_to?(:session) session = request.session return unless session Appsignal::Utils::HashSanitizer.sanitize( session.to_hash, Appsignal.config[:filter_session_data] ) end
ruby
def sanitized_session_data return if Appsignal.config[:skip_session_data] || !request.respond_to?(:session) session = request.session return unless session Appsignal::Utils::HashSanitizer.sanitize( session.to_hash, Appsignal.config[:filter_session_data] ) end
[ "def", "sanitized_session_data", "return", "if", "Appsignal", ".", "config", "[", ":skip_session_data", "]", "||", "!", "request", ".", "respond_to?", "(", ":session", ")", "session", "=", "request", ".", "session", "return", "unless", "session", "Appsignal", ":...
Returns sanitized session data. The session data is sanitized by the {Appsignal::Utils::HashSanitizer}. @return [nil] if `:skip_session_data` config is set to `true`. @return [nil] if the {#request} object doesn't respond to `#session`. @return [nil] if the {#request} session data is `nil`. @return [Hash<String,...
[ "Returns", "sanitized", "session", "data", "." ]
23a07f6f01857a967921adb83deb98b07d160629
https://github.com/appsignal/appsignal-ruby/blob/23a07f6f01857a967921adb83deb98b07d160629/lib/appsignal/transaction.rb#L420-L429
train
d0z0/redis_analytics
lib/redis_analytics/visit.rb
RedisAnalytics.Visit.for_each_time_range
def for_each_time_range(t) RedisAnalytics.redis_key_timestamps.map{|x, y| t.strftime(x)}.each do |ts| yield(ts) end end
ruby
def for_each_time_range(t) RedisAnalytics.redis_key_timestamps.map{|x, y| t.strftime(x)}.each do |ts| yield(ts) end end
[ "def", "for_each_time_range", "(", "t", ")", "RedisAnalytics", ".", "redis_key_timestamps", ".", "map", "{", "|", "x", ",", "y", "|", "t", ".", "strftime", "(", "x", ")", "}", ".", "each", "do", "|", "ts", "|", "yield", "(", "ts", ")", "end", "end"...
This class represents one unique visit User may have never visited the site User may have visited before but his visit is expired Everything counted here is unique for a visit helpers
[ "This", "class", "represents", "one", "unique", "visit", "User", "may", "have", "never", "visited", "the", "site", "User", "may", "have", "visited", "before", "but", "his", "visit", "is", "expired", "Everything", "counted", "here", "is", "unique", "for", "a"...
f29c9db9b7425f0ee80bdd8cf572295e79d3d2bd
https://github.com/d0z0/redis_analytics/blob/f29c9db9b7425f0ee80bdd8cf572295e79d3d2bd/lib/redis_analytics/visit.rb#L11-L15
train
d0z0/redis_analytics
lib/redis_analytics/visit.rb
RedisAnalytics.Visit.record
def record if @current_visit_seq track("visit_time", @t.to_i - @last_visit_end_time.to_i) else @current_visit_seq ||= counter("visits") track("visits", 1) # track core 'visit' metric if @first_visit_seq track("repeat_visits", 1) else @first_visit_s...
ruby
def record if @current_visit_seq track("visit_time", @t.to_i - @last_visit_end_time.to_i) else @current_visit_seq ||= counter("visits") track("visits", 1) # track core 'visit' metric if @first_visit_seq track("repeat_visits", 1) else @first_visit_s...
[ "def", "record", "if", "@current_visit_seq", "track", "(", "\"visit_time\"", ",", "@t", ".", "to_i", "-", "@last_visit_end_time", ".", "to_i", ")", "else", "@current_visit_seq", "||=", "counter", "(", "\"visits\"", ")", "track", "(", "\"visits\"", ",", "1", ")...
method used in analytics.rb to initialize visit called from analytics.rb
[ "method", "used", "in", "analytics", ".", "rb", "to", "initialize", "visit", "called", "from", "analytics", ".", "rb" ]
f29c9db9b7425f0ee80bdd8cf572295e79d3d2bd
https://github.com/d0z0/redis_analytics/blob/f29c9db9b7425f0ee80bdd8cf572295e79d3d2bd/lib/redis_analytics/visit.rb#L45-L64
train
7even/vkontakte_api
lib/vkontakte_api/configuration.rb
VkontakteApi.Configuration.reset
def reset @adapter = DEFAULT_ADAPTER @http_verb = DEFAULT_HTTP_VERB @faraday_options = {} @max_retries = DEFAULT_MAX_RETRIES @logger = ::Logger.new(STDOUT) @log_requests = DEFAULT_LOGGER_OPTIONS[:requests] @log_errors = DEFAULT_LOGGER_OPTIONS[...
ruby
def reset @adapter = DEFAULT_ADAPTER @http_verb = DEFAULT_HTTP_VERB @faraday_options = {} @max_retries = DEFAULT_MAX_RETRIES @logger = ::Logger.new(STDOUT) @log_requests = DEFAULT_LOGGER_OPTIONS[:requests] @log_errors = DEFAULT_LOGGER_OPTIONS[...
[ "def", "reset", "@adapter", "=", "DEFAULT_ADAPTER", "@http_verb", "=", "DEFAULT_HTTP_VERB", "@faraday_options", "=", "{", "}", "@max_retries", "=", "DEFAULT_MAX_RETRIES", "@logger", "=", "::", "Logger", ".", "new", "(", "STDOUT", ")", "@log_requests", "=", "DEFAUL...
Reset all configuration options to defaults.
[ "Reset", "all", "configuration", "options", "to", "defaults", "." ]
daa4a9126d816926d31421bdcfd31538ac25d83b
https://github.com/7even/vkontakte_api/blob/daa4a9126d816926d31421bdcfd31538ac25d83b/lib/vkontakte_api/configuration.rb#L58-L68
train
7even/vkontakte_api
lib/vkontakte_api/method.rb
VkontakteApi.Method.call
def call(args = {}, &block) response = API.call(full_name, args, token) Result.process(response, type, block) end
ruby
def call(args = {}, &block) response = API.call(full_name, args, token) Result.process(response, type, block) end
[ "def", "call", "(", "args", "=", "{", "}", ",", "&", "block", ")", "response", "=", "API", ".", "call", "(", "full_name", ",", "args", ",", "token", ")", "Result", ".", "process", "(", "response", ",", "type", ",", "block", ")", "end" ]
Calling the API method. It delegates the network request to `API.call` and result processing to `Result.process`. @param [Hash] args Arguments for the API method.
[ "Calling", "the", "API", "method", ".", "It", "delegates", "the", "network", "request", "to", "API", ".", "call", "and", "result", "processing", "to", "Result", ".", "process", "." ]
daa4a9126d816926d31421bdcfd31538ac25d83b
https://github.com/7even/vkontakte_api/blob/daa4a9126d816926d31421bdcfd31538ac25d83b/lib/vkontakte_api/method.rb#L12-L15
train
7even/vkontakte_api
lib/vkontakte_api/authorization.rb
VkontakteApi.Authorization.authorization_url
def authorization_url(options = {}) type = options.delete(:type) || :site # redirect_uri passed in options overrides the global setting options[:redirect_uri] ||= VkontakteApi.redirect_uri options[:scope] = VkontakteApi::Utils.flatten_argument(options[:scope]) if options[:scope] cas...
ruby
def authorization_url(options = {}) type = options.delete(:type) || :site # redirect_uri passed in options overrides the global setting options[:redirect_uri] ||= VkontakteApi.redirect_uri options[:scope] = VkontakteApi::Utils.flatten_argument(options[:scope]) if options[:scope] cas...
[ "def", "authorization_url", "(", "options", "=", "{", "}", ")", "type", "=", "options", ".", "delete", "(", ":type", ")", "||", ":site", "options", "[", ":redirect_uri", "]", "||=", "VkontakteApi", ".", "redirect_uri", "options", "[", ":scope", "]", "=", ...
URL for redirecting the user to VK where he gives the application all the requested access rights. @option options [Symbol] :type The type of authorization being used (`:site` and `:client` supported). @option options [String] :redirect_uri URL for redirecting the user back to the application (overrides the global co...
[ "URL", "for", "redirecting", "the", "user", "to", "VK", "where", "he", "gives", "the", "application", "all", "the", "requested", "access", "rights", "." ]
daa4a9126d816926d31421bdcfd31538ac25d83b
https://github.com/7even/vkontakte_api/blob/daa4a9126d816926d31421bdcfd31538ac25d83b/lib/vkontakte_api/authorization.rb#L24-L38
train
cxn03651/write_xlsx
lib/write_xlsx/chart.rb
Writexlsx.Chart.add_series
def add_series(params) # Check that the required input has been specified. unless params.has_key?(:values) raise "Must specify ':values' in add_series" end if @requires_category != 0 && !params.has_key?(:categories) raise "Must specify ':categories' in add_series for this chart...
ruby
def add_series(params) # Check that the required input has been specified. unless params.has_key?(:values) raise "Must specify ':values' in add_series" end if @requires_category != 0 && !params.has_key?(:categories) raise "Must specify ':categories' in add_series for this chart...
[ "def", "add_series", "(", "params", ")", "unless", "params", ".", "has_key?", "(", ":values", ")", "raise", "\"Must specify ':values' in add_series\"", "end", "if", "@requires_category", "!=", "0", "&&", "!", "params", ".", "has_key?", "(", ":categories", ")", "...
Add a series and it's properties to a chart.
[ "Add", "a", "series", "and", "it", "s", "properties", "to", "a", "chart", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/chart.rb#L247-L285
train
cxn03651/write_xlsx
lib/write_xlsx/chart.rb
Writexlsx.Chart.set_size
def set_size(params = {}) @width = params[:width] if params[:width] @height = params[:height] if params[:height] @x_scale = params[:x_scale] if params[:x_scale] @y_scale = params[:y_scale] if params[:y_scale] @x_offset = params[:x_offset] if params[:x_offset] @y_offset ...
ruby
def set_size(params = {}) @width = params[:width] if params[:width] @height = params[:height] if params[:height] @x_scale = params[:x_scale] if params[:x_scale] @y_scale = params[:y_scale] if params[:y_scale] @x_offset = params[:x_offset] if params[:x_offset] @y_offset ...
[ "def", "set_size", "(", "params", "=", "{", "}", ")", "@width", "=", "params", "[", ":width", "]", "if", "params", "[", ":width", "]", "@height", "=", "params", "[", ":height", "]", "if", "params", "[", ":height", "]", "@x_scale", "=", "params", "[",...
Set dimensions for scale for the chart.
[ "Set", "dimensions", "for", "scale", "for", "the", "chart", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/chart.rb#L392-L399
train
cxn03651/write_xlsx
lib/write_xlsx/chart.rb
Writexlsx.Chart.set_up_down_bars
def set_up_down_bars(params = {}) # Map border to line. [:up, :down].each do |up_down| if params[up_down] params[up_down][:line] = params[up_down][:border] if params[up_down][:border] else params[up_down] = {} end end # Set the up and down bar propert...
ruby
def set_up_down_bars(params = {}) # Map border to line. [:up, :down].each do |up_down| if params[up_down] params[up_down][:line] = params[up_down][:border] if params[up_down][:border] else params[up_down] = {} end end # Set the up and down bar propert...
[ "def", "set_up_down_bars", "(", "params", "=", "{", "}", ")", "[", ":up", ",", ":down", "]", ".", "each", "do", "|", "up_down", "|", "if", "params", "[", "up_down", "]", "params", "[", "up_down", "]", "[", ":line", "]", "=", "params", "[", "up_down...
Set properties for the chart up-down bars.
[ "Set", "properties", "for", "the", "chart", "up", "-", "down", "bars", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/chart.rb#L415-L430
train
cxn03651/write_xlsx
lib/write_xlsx/chart.rb
Writexlsx.Chart.convert_font_args
def convert_font_args(params) return unless params font = params_to_font(params) # Convert font size units. font[:_size] *= 100 if font[:_size] && font[:_size] != 0 # Convert rotation into 60,000ths of a degree. if ptrue?(font[:_rotation]) font[:_rotation] = 60_000 * font[:...
ruby
def convert_font_args(params) return unless params font = params_to_font(params) # Convert font size units. font[:_size] *= 100 if font[:_size] && font[:_size] != 0 # Convert rotation into 60,000ths of a degree. if ptrue?(font[:_rotation]) font[:_rotation] = 60_000 * font[:...
[ "def", "convert_font_args", "(", "params", ")", "return", "unless", "params", "font", "=", "params_to_font", "(", "params", ")", "font", "[", ":_size", "]", "*=", "100", "if", "font", "[", ":_size", "]", "&&", "font", "[", ":_size", "]", "!=", "0", "if...
Convert user defined font values into private hash values.
[ "Convert", "user", "defined", "font", "values", "into", "private", "hash", "values", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/chart.rb#L513-L526
train
cxn03651/write_xlsx
lib/write_xlsx/chart.rb
Writexlsx.Chart.process_names
def process_names(name = nil, name_formula = nil) # :nodoc: # Name looks like a formula, use it to set name_formula. if name.respond_to?(:to_ary) cell = xl_rowcol_to_cell(name[1], name[2], 1, 1) name_formula = "#{quote_sheetname(name[0])}!#{cell}" name = '' elsif name &...
ruby
def process_names(name = nil, name_formula = nil) # :nodoc: # Name looks like a formula, use it to set name_formula. if name.respond_to?(:to_ary) cell = xl_rowcol_to_cell(name[1], name[2], 1, 1) name_formula = "#{quote_sheetname(name[0])}!#{cell}" name = '' elsif name &...
[ "def", "process_names", "(", "name", "=", "nil", ",", "name_formula", "=", "nil", ")", "if", "name", ".", "respond_to?", "(", ":to_ary", ")", "cell", "=", "xl_rowcol_to_cell", "(", "name", "[", "1", "]", ",", "name", "[", "2", "]", ",", "1", ",", "...
Switch name and name_formula parameters if required.
[ "Switch", "name", "and", "name_formula", "parameters", "if", "required", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/chart.rb#L546-L559
train
cxn03651/write_xlsx
lib/write_xlsx/chart.rb
Writexlsx.Chart.get_data_type
def get_data_type(data) # :nodoc: # Check for no data in the series. return 'none' unless data return 'none' if data.empty? return 'multi_str' if data.first.kind_of?(Array) # If the token isn't a number assume it is a string. data.each do |token| next unless token re...
ruby
def get_data_type(data) # :nodoc: # Check for no data in the series. return 'none' unless data return 'none' if data.empty? return 'multi_str' if data.first.kind_of?(Array) # If the token isn't a number assume it is a string. data.each do |token| next unless token re...
[ "def", "get_data_type", "(", "data", ")", "return", "'none'", "unless", "data", "return", "'none'", "if", "data", ".", "empty?", "return", "'multi_str'", "if", "data", ".", "first", ".", "kind_of?", "(", "Array", ")", "data", ".", "each", "do", "|", "tok...
Find the overall type of the data associated with a series. TODO. Need to handle date type.
[ "Find", "the", "overall", "type", "of", "the", "data", "associated", "with", "a", "series", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/chart.rb#L649-L663
train
cxn03651/write_xlsx
lib/write_xlsx/chart.rb
Writexlsx.Chart.color
def color(color_code) # :nodoc: if color_code and color_code =~ /^#[0-9a-fA-F]{6}$/ # Convert a HTML style #RRGGBB color. color_code.sub(/^#/, '').upcase else index = Format.color(color_code) raise "Unknown color '#{color_code}' used in chart formatting." unless index ...
ruby
def color(color_code) # :nodoc: if color_code and color_code =~ /^#[0-9a-fA-F]{6}$/ # Convert a HTML style #RRGGBB color. color_code.sub(/^#/, '').upcase else index = Format.color(color_code) raise "Unknown color '#{color_code}' used in chart formatting." unless index ...
[ "def", "color", "(", "color_code", ")", "if", "color_code", "and", "color_code", "=~", "/", "/", "color_code", ".", "sub", "(", "/", "/", ",", "''", ")", ".", "upcase", "else", "index", "=", "Format", ".", "color", "(", "color_code", ")", "raise", "\...
Convert the user specified colour index or string to a rgb colour.
[ "Convert", "the", "user", "specified", "colour", "index", "or", "string", "to", "a", "rgb", "colour", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/chart.rb#L668-L677
train
cxn03651/write_xlsx
lib/write_xlsx/chart.rb
Writexlsx.Chart.get_font_style_attributes
def get_font_style_attributes(font) return [] unless font attributes = [] attributes << ['sz', font[:_size]] if ptrue?(font[:_size]) attributes << ['b', font[:_bold]] if font[:_bold] attributes << ['i', font[:_italic]] if font[:_italic] attributes << ['u', 'sng'] ...
ruby
def get_font_style_attributes(font) return [] unless font attributes = [] attributes << ['sz', font[:_size]] if ptrue?(font[:_size]) attributes << ['b', font[:_bold]] if font[:_bold] attributes << ['i', font[:_italic]] if font[:_italic] attributes << ['u', 'sng'] ...
[ "def", "get_font_style_attributes", "(", "font", ")", "return", "[", "]", "unless", "font", "attributes", "=", "[", "]", "attributes", "<<", "[", "'sz'", ",", "font", "[", ":_size", "]", "]", "if", "ptrue?", "(", "font", "[", ":_size", "]", ")", "attri...
Get the font style attributes from a font hash.
[ "Get", "the", "font", "style", "attributes", "from", "a", "font", "hash", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/chart.rb#L719-L733
train
cxn03651/write_xlsx
lib/write_xlsx/chart.rb
Writexlsx.Chart.get_font_latin_attributes
def get_font_latin_attributes(font) return [] unless font attributes = [] attributes << ['typeface', font[:_name]] if ptrue?(font[:_name]) attributes << ['pitchFamily', font[:_pitch_family]] if font[:_pitch_family] attributes << ['charset', font[:_charset]] if font[:_c...
ruby
def get_font_latin_attributes(font) return [] unless font attributes = [] attributes << ['typeface', font[:_name]] if ptrue?(font[:_name]) attributes << ['pitchFamily', font[:_pitch_family]] if font[:_pitch_family] attributes << ['charset', font[:_charset]] if font[:_c...
[ "def", "get_font_latin_attributes", "(", "font", ")", "return", "[", "]", "unless", "font", "attributes", "=", "[", "]", "attributes", "<<", "[", "'typeface'", ",", "font", "[", ":_name", "]", "]", "if", "ptrue?", "(", "font", "[", ":_name", "]", ")", ...
Get the font latin attributes from a font hash.
[ "Get", "the", "font", "latin", "attributes", "from", "a", "font", "hash", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/chart.rb#L738-L747
train
cxn03651/write_xlsx
lib/write_xlsx/chart.rb
Writexlsx.Chart.write_series_name
def write_series_name(series) # :nodoc: if series.name_formula write_tx_formula(series.name_formula, series.name_id) elsif series.name write_tx_value(series.name) end end
ruby
def write_series_name(series) # :nodoc: if series.name_formula write_tx_formula(series.name_formula, series.name_id) elsif series.name write_tx_value(series.name) end end
[ "def", "write_series_name", "(", "series", ")", "if", "series", ".", "name_formula", "write_tx_formula", "(", "series", ".", "name_formula", ",", "series", ".", "name_id", ")", "elsif", "series", ".", "name", "write_tx_value", "(", "series", ".", "name", ")", ...
Write the series name.
[ "Write", "the", "series", "name", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/chart.rb#L1074-L1080
train
cxn03651/write_xlsx
lib/write_xlsx/chart.rb
Writexlsx.Chart.write_axis_font
def write_axis_font(font) # :nodoc: return unless font @writer.tag_elements('c:txPr') do write_a_body_pr(font[:_rotation]) write_a_lst_style @writer.tag_elements('a:p') do write_a_p_pr_rich(font) write_a_end_para_rpr end end end
ruby
def write_axis_font(font) # :nodoc: return unless font @writer.tag_elements('c:txPr') do write_a_body_pr(font[:_rotation]) write_a_lst_style @writer.tag_elements('a:p') do write_a_p_pr_rich(font) write_a_end_para_rpr end end end
[ "def", "write_axis_font", "(", "font", ")", "return", "unless", "font", "@writer", ".", "tag_elements", "(", "'c:txPr'", ")", "do", "write_a_body_pr", "(", "font", "[", ":_rotation", "]", ")", "write_a_lst_style", "@writer", ".", "tag_elements", "(", "'a:p'", ...
Write the axis font elements.
[ "Write", "the", "axis", "font", "elements", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/chart.rb#L2504-L2515
train
cxn03651/write_xlsx
lib/write_xlsx/chart.rb
Writexlsx.Chart.write_error_bars
def write_error_bars(error_bars) return unless ptrue?(error_bars) if error_bars[:_x_error_bars] write_err_bars('x', error_bars[:_x_error_bars]) end if error_bars[:_y_error_bars] write_err_bars('y', error_bars[:_y_error_bars]) end end
ruby
def write_error_bars(error_bars) return unless ptrue?(error_bars) if error_bars[:_x_error_bars] write_err_bars('x', error_bars[:_x_error_bars]) end if error_bars[:_y_error_bars] write_err_bars('y', error_bars[:_y_error_bars]) end end
[ "def", "write_error_bars", "(", "error_bars", ")", "return", "unless", "ptrue?", "(", "error_bars", ")", "if", "error_bars", "[", ":_x_error_bars", "]", "write_err_bars", "(", "'x'", ",", "error_bars", "[", ":_x_error_bars", "]", ")", "end", "if", "error_bars", ...
Write the X and Y error bars.
[ "Write", "the", "X", "and", "Y", "error", "bars", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/chart.rb#L2534-L2543
train
cxn03651/write_xlsx
lib/write_xlsx/chart.rb
Writexlsx.Chart.write_custom_error
def write_custom_error(error_bars) if ptrue?(error_bars.plus_values) write_custom_error_base('c:plus', error_bars.plus_values, error_bars.plus_data) write_custom_error_base('c:minus', error_bars.minus_values, error_bars.minus_data) end end
ruby
def write_custom_error(error_bars) if ptrue?(error_bars.plus_values) write_custom_error_base('c:plus', error_bars.plus_values, error_bars.plus_data) write_custom_error_base('c:minus', error_bars.minus_values, error_bars.minus_data) end end
[ "def", "write_custom_error", "(", "error_bars", ")", "if", "ptrue?", "(", "error_bars", ".", "plus_values", ")", "write_custom_error_base", "(", "'c:plus'", ",", "error_bars", ".", "plus_values", ",", "error_bars", ".", "plus_data", ")", "write_custom_error_base", "...
Write the custom error bars type.
[ "Write", "the", "custom", "error", "bars", "type", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/chart.rb#L2620-L2625
train
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.protect
def protect(password = nil, options = {}) check_parameter(options, protect_default_settings.keys, 'protect') @protect = protect_default_settings.merge(options) # Set the password after the user defined values. @protect[:password] = sprintf("%X", encode_password(password)) if password &&...
ruby
def protect(password = nil, options = {}) check_parameter(options, protect_default_settings.keys, 'protect') @protect = protect_default_settings.merge(options) # Set the password after the user defined values. @protect[:password] = sprintf("%X", encode_password(password)) if password &&...
[ "def", "protect", "(", "password", "=", "nil", ",", "options", "=", "{", "}", ")", "check_parameter", "(", "options", ",", "protect_default_settings", ".", "keys", ",", "'protect'", ")", "@protect", "=", "protect_default_settings", ".", "merge", "(", "options"...
Set the worksheet protection flags to prevent modification of worksheet objects. The protect() method is used to protect a worksheet from modification: worksheet.protect The protect() method also has the effect of enabling a cell's locked and hidden properties if they have been set. A locked cell cannot be ...
[ "Set", "the", "worksheet", "protection", "flags", "to", "prevent", "modification", "of", "worksheet", "objects", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L602-L609
train
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.set_header
def set_header(string = '', margin = 0.3, options = {}) raise 'Header string must be less than 255 characters' if string.length >= 255 # Replace the Excel placeholder &[Picture] with the internal &G. @page_setup.header = string.gsub(/&\[Picture\]/, '&G') if string.size >= 255 raise 'Hea...
ruby
def set_header(string = '', margin = 0.3, options = {}) raise 'Header string must be less than 255 characters' if string.length >= 255 # Replace the Excel placeholder &[Picture] with the internal &G. @page_setup.header = string.gsub(/&\[Picture\]/, '&G') if string.size >= 255 raise 'Hea...
[ "def", "set_header", "(", "string", "=", "''", ",", "margin", "=", "0.3", ",", "options", "=", "{", "}", ")", "raise", "'Header string must be less than 255 characters'", "if", "string", ".", "length", ">=", "255", "@page_setup", ".", "header", "=", "string", ...
Set the page header caption and optional margin. Headers and footers are generated using a string which is a combination of plain text and control characters. The margin parameter is optional. The available control character are: Control Category Description ======= ==...
[ "Set", "the", "page", "header", "caption", "and", "optional", "margin", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L1198-L1239
train
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.set_footer
def set_footer(string = '', margin = 0.3, options = {}) raise 'Footer string must be less than 255 characters' if string.length >= 255 @page_setup.footer = string.dup # Replace the Excel placeholder &[Picture] with the internal &G. @page_setup.footer = string.gsub(/&\[Picture\]/...
ruby
def set_footer(string = '', margin = 0.3, options = {}) raise 'Footer string must be less than 255 characters' if string.length >= 255 @page_setup.footer = string.dup # Replace the Excel placeholder &[Picture] with the internal &G. @page_setup.footer = string.gsub(/&\[Picture\]/...
[ "def", "set_footer", "(", "string", "=", "''", ",", "margin", "=", "0.3", ",", "options", "=", "{", "}", ")", "raise", "'Footer string must be less than 255 characters'", "if", "string", ".", "length", ">=", "255", "@page_setup", ".", "footer", "=", "string", ...
Set the page footer caption and optional margin. The syntax of the set_footer() method is the same as set_header()
[ "Set", "the", "page", "footer", "caption", "and", "optional", "margin", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L1246-L1290
train
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.repeat_rows
def repeat_rows(row_min, row_max = nil) row_max ||= row_min # Convert to 1 based. row_min += 1 row_max += 1 area = "$#{row_min}:$#{row_max}" # Build up the print titles "Sheet1!$1:$2" sheetname = quote_sheetname(@name) @page_setup.repeat_rows = "#{sheetname}!#{area}" ...
ruby
def repeat_rows(row_min, row_max = nil) row_max ||= row_min # Convert to 1 based. row_min += 1 row_max += 1 area = "$#{row_min}:$#{row_max}" # Build up the print titles "Sheet1!$1:$2" sheetname = quote_sheetname(@name) @page_setup.repeat_rows = "#{sheetname}!#{area}" ...
[ "def", "repeat_rows", "(", "row_min", ",", "row_max", "=", "nil", ")", "row_max", "||=", "row_min", "row_min", "+=", "1", "row_max", "+=", "1", "area", "=", "\"$#{row_min}:$#{row_max}\"", "sheetname", "=", "quote_sheetname", "(", "@name", ")", "@page_setup", "...
Set the number of rows to repeat at the top of each printed page. For large Excel documents it is often desirable to have the first row or rows of the worksheet print out at the top of each page. This can be achieved by using the repeat_rows() method. The parameters first_row and last_row are zero based. The last_...
[ "Set", "the", "number", "of", "rows", "to", "repeat", "at", "the", "top", "of", "each", "printed", "page", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L1482-L1494
train
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.print_across
def print_across(across = true) if across @page_setup.across = true @page_setup.page_setup_changed = true else @page_setup.across = false end end
ruby
def print_across(across = true) if across @page_setup.across = true @page_setup.page_setup_changed = true else @page_setup.across = false end end
[ "def", "print_across", "(", "across", "=", "true", ")", "if", "across", "@page_setup", ".", "across", "=", "true", "@page_setup", ".", "page_setup_changed", "=", "true", "else", "@page_setup", ".", "across", "=", "false", "end", "end" ]
Set the order in which pages are printed. The print_across method is used to change the default print direction. This is referred to by Excel as the sheet "page order". worksheet.print_across The default page order is shown below for a worksheet that extends over 4 pages. The order is called "down then acro...
[ "Set", "the", "order", "in", "which", "pages", "are", "printed", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L1685-L1692
train
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.filter_column
def filter_column(col, expression) raise "Must call autofilter before filter_column" unless @autofilter_area col = prepare_filter_column(col) tokens = extract_filter_tokens(expression) unless tokens.size == 3 || tokens.size == 7 raise "Incorrect number of tokens in expression '#{expre...
ruby
def filter_column(col, expression) raise "Must call autofilter before filter_column" unless @autofilter_area col = prepare_filter_column(col) tokens = extract_filter_tokens(expression) unless tokens.size == 3 || tokens.size == 7 raise "Incorrect number of tokens in expression '#{expre...
[ "def", "filter_column", "(", "col", ",", "expression", ")", "raise", "\"Must call autofilter before filter_column\"", "unless", "@autofilter_area", "col", "=", "prepare_filter_column", "(", "col", ")", "tokens", "=", "extract_filter_tokens", "(", "expression", ")", "unl...
Set the column filter criteria. The filter_column method can be used to filter columns in a autofilter range based on simple conditions. NOTE: It isn't sufficient to just specify the filter condition. You must also hide any rows that don't match the filter condition. Rows are hidden using the set_row() +visible+...
[ "Set", "the", "column", "filter", "criteria", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L5389-L5417
train
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.filter_column_list
def filter_column_list(col, *tokens) tokens.flatten! raise "Incorrect number of arguments to filter_column_list" if tokens.empty? raise "Must call autofilter before filter_column_list" unless @autofilter_area col = prepare_filter_column(col) @filter_cols[col] = tokens @filter_type[...
ruby
def filter_column_list(col, *tokens) tokens.flatten! raise "Incorrect number of arguments to filter_column_list" if tokens.empty? raise "Must call autofilter before filter_column_list" unless @autofilter_area col = prepare_filter_column(col) @filter_cols[col] = tokens @filter_type[...
[ "def", "filter_column_list", "(", "col", ",", "*", "tokens", ")", "tokens", ".", "flatten!", "raise", "\"Incorrect number of arguments to filter_column_list\"", "if", "tokens", ".", "empty?", "raise", "\"Must call autofilter before filter_column_list\"", "unless", "@autofilte...
Set the column filter criteria in Excel 2007 list style. Prior to Excel 2007 it was only possible to have either 1 or 2 filter conditions such as the ones shown above in the filter_column method. Excel 2007 introduced a new list style filter where it is possible to specify 1 or more 'or' style criteria. For examp...
[ "Set", "the", "column", "filter", "criteria", "in", "Excel", "2007", "list", "style", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L5462-L5472
train
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.set_h_pagebreaks
def set_h_pagebreaks(*args) breaks = args.collect do |brk| Array(brk) end.flatten @page_setup.hbreaks += breaks end
ruby
def set_h_pagebreaks(*args) breaks = args.collect do |brk| Array(brk) end.flatten @page_setup.hbreaks += breaks end
[ "def", "set_h_pagebreaks", "(", "*", "args", ")", "breaks", "=", "args", ".", "collect", "do", "|", "brk", "|", "Array", "(", "brk", ")", "end", ".", "flatten", "@page_setup", ".", "hbreaks", "+=", "breaks", "end" ]
Store the horizontal page breaks on a worksheet. Add horizontal page breaks to a worksheet. A page break causes all the data that follows it to be printed on the next page. Horizontal page breaks act between rows. To create a page break between rows 20 and 21 you must specify the break at row 21. However in zero i...
[ "Store", "the", "horizontal", "page", "breaks", "on", "a", "worksheet", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L5498-L5503
train
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.get_range_data
def get_range_data(row_start, col_start, row_end, col_end) # :nodoc: # TODO. Check for worksheet limits. # Iterate through the table data. data = [] (row_start .. row_end).each do |row_num| # Store nil if row doesn't exist. if !@cell_data_table[row_num] data << nil ...
ruby
def get_range_data(row_start, col_start, row_end, col_end) # :nodoc: # TODO. Check for worksheet limits. # Iterate through the table data. data = [] (row_start .. row_end).each do |row_num| # Store nil if row doesn't exist. if !@cell_data_table[row_num] data << nil ...
[ "def", "get_range_data", "(", "row_start", ",", "col_start", ",", "row_end", ",", "col_end", ")", "data", "=", "[", "]", "(", "row_start", "..", "row_end", ")", ".", "each", "do", "|", "row_num", "|", "if", "!", "@cell_data_table", "[", "row_num", "]", ...
Returns a range of data from the worksheet _table to be used in chart cached data. Strings are returned as SST ids and decoded in the workbook. Return nils for data that doesn't exist since Excel can chart series with data missing.
[ "Returns", "a", "range", "of", "data", "from", "the", "worksheet", "_table", "to", "be", "used", "in", "chart", "cached", "data", ".", "Strings", "are", "returned", "as", "SST", "ids", "and", "decoded", "in", "the", "workbook", ".", "Return", "nils", "fo...
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L5646-L5669
train
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.position_object_pixels
def position_object_pixels(col_start, row_start, x1, y1, width, height) #:nodoc: # Calculate the absolute x offset of the top-left vertex. if @col_size_changed x_abs = (0 .. col_start-1).inject(0) {|sum, col| sum += size_col(col)} else # Optimisation for when the column widths haven't ...
ruby
def position_object_pixels(col_start, row_start, x1, y1, width, height) #:nodoc: # Calculate the absolute x offset of the top-left vertex. if @col_size_changed x_abs = (0 .. col_start-1).inject(0) {|sum, col| sum += size_col(col)} else # Optimisation for when the column widths haven't ...
[ "def", "position_object_pixels", "(", "col_start", ",", "row_start", ",", "x1", ",", "y1", ",", "width", ",", "height", ")", "if", "@col_size_changed", "x_abs", "=", "(", "0", "..", "col_start", "-", "1", ")", ".", "inject", "(", "0", ")", "{", "|", ...
Calculate the vertices that define the position of a graphical object within the worksheet in pixels. +------------+------------+ | A | B | +-----+------------+------------+ | |(x1,y1) | | | 1 |(A1)._______|______ | | | | | ...
[ "Calculate", "the", "vertices", "that", "define", "the", "position", "of", "a", "graphical", "object", "within", "the", "worksheet", "in", "pixels", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L5718-L5762
train
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.prepare_vml_objects
def prepare_vml_objects(vml_data_id, vml_shape_id, vml_drawing_id, comment_id) set_external_vml_links(vml_drawing_id) set_external_comment_links(comment_id) if has_comments? # The VML o:idmap data id contains a comma separated range when there is # more than one 1024 block of comments, like thi...
ruby
def prepare_vml_objects(vml_data_id, vml_shape_id, vml_drawing_id, comment_id) set_external_vml_links(vml_drawing_id) set_external_comment_links(comment_id) if has_comments? # The VML o:idmap data id contains a comma separated range when there is # more than one 1024 block of comments, like thi...
[ "def", "prepare_vml_objects", "(", "vml_data_id", ",", "vml_shape_id", ",", "vml_drawing_id", ",", "comment_id", ")", "set_external_vml_links", "(", "vml_drawing_id", ")", "set_external_comment_links", "(", "comment_id", ")", "if", "has_comments?", "data", "=", "\"#{vml...
Turn the HoH that stores the comments into an array for easier handling and set the external links for comments and buttons.
[ "Turn", "the", "HoH", "that", "stores", "the", "comments", "into", "an", "array", "for", "easier", "handling", "and", "set", "the", "external", "links", "for", "comments", "and", "buttons", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L5846-L5858
train
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.prepare_tables
def prepare_tables(table_id) if tables_count > 0 id = table_id tables.each do |table| table.prepare(id) # Store the link used for the rels file. @external_table_links << ['/table', "../tables/table#{id}.xml"] id += 1 end end tables_count...
ruby
def prepare_tables(table_id) if tables_count > 0 id = table_id tables.each do |table| table.prepare(id) # Store the link used for the rels file. @external_table_links << ['/table', "../tables/table#{id}.xml"] id += 1 end end tables_count...
[ "def", "prepare_tables", "(", "table_id", ")", "if", "tables_count", ">", "0", "id", "=", "table_id", "tables", ".", "each", "do", "|", "table", "|", "table", ".", "prepare", "(", "id", ")", "@external_table_links", "<<", "[", "'/table'", ",", "\"../tables...
Set the table ids for the worksheet tables.
[ "Set", "the", "table", "ids", "for", "the", "worksheet", "tables", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L5871-L5883
train
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.write_formatted_blank_to_area
def write_formatted_blank_to_area(row_first, row_last, col_first, col_last, format) (row_first .. row_last).each do |row| (col_first .. col_last).each do |col| next if row == row_first && col == col_first write_blank(row, col, format) end end end
ruby
def write_formatted_blank_to_area(row_first, row_last, col_first, col_last, format) (row_first .. row_last).each do |row| (col_first .. col_last).each do |col| next if row == row_first && col == col_first write_blank(row, col, format) end end end
[ "def", "write_formatted_blank_to_area", "(", "row_first", ",", "row_last", ",", "col_first", ",", "col_last", ",", "format", ")", "(", "row_first", "..", "row_last", ")", ".", "each", "do", "|", "row", "|", "(", "col_first", "..", "col_last", ")", ".", "ea...
Pad out the rest of the area with formatted blank cells.
[ "Pad", "out", "the", "rest", "of", "the", "area", "with", "formatted", "blank", "cells", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L5998-L6005
train
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.parse_filter_tokens
def parse_filter_tokens(expression, tokens) #:nodoc: operators = { '==' => 2, '=' => 2, '=~' => 2, 'eq' => 2, '!=' => 5, '!~' => 5, 'ne' => 5, '<>' => 5, '<' => 1, '<=' => 3, '>' => 4, '>=' => 6, } ...
ruby
def parse_filter_tokens(expression, tokens) #:nodoc: operators = { '==' => 2, '=' => 2, '=~' => 2, 'eq' => 2, '!=' => 5, '!~' => 5, 'ne' => 5, '<>' => 5, '<' => 1, '<=' => 3, '>' => 4, '>=' => 6, } ...
[ "def", "parse_filter_tokens", "(", "expression", ",", "tokens", ")", "operators", "=", "{", "'=='", "=>", "2", ",", "'='", "=>", "2", ",", "'=~'", "=>", "2", ",", "'eq'", "=>", "2", ",", "'!='", "=>", "5", ",", "'!~'", "=>", "5", ",", "'ne'", "=>...
Parse the 3 tokens of a filter expression and return the operator and token.
[ "Parse", "the", "3", "tokens", "of", "a", "filter", "expression", "and", "return", "the", "operator", "and", "token", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L6078-L6164
train
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.position_object_emus
def position_object_emus(col_start, row_start, x1, y1, width, height, x_dpi = 96, y_dpi = 96) #:nodoc: col_start, row_start, x1, y1, col_end, row_end, x2, y2, x_abs, y_abs = position_object_pixels(col_start, row_start, x1, y1, width, height) # Convert the pixel values to EMUs. See above. x1 ...
ruby
def position_object_emus(col_start, row_start, x1, y1, width, height, x_dpi = 96, y_dpi = 96) #:nodoc: col_start, row_start, x1, y1, col_end, row_end, x2, y2, x_abs, y_abs = position_object_pixels(col_start, row_start, x1, y1, width, height) # Convert the pixel values to EMUs. See above. x1 ...
[ "def", "position_object_emus", "(", "col_start", ",", "row_start", ",", "x1", ",", "y1", ",", "width", ",", "height", ",", "x_dpi", "=", "96", ",", "y_dpi", "=", "96", ")", "col_start", ",", "row_start", ",", "x1", ",", "y1", ",", "col_end", ",", "ro...
Calculate the vertices that define the position of a graphical object within the worksheet in EMUs. The vertices are expressed as English Metric Units (EMUs). There are 12,700 EMUs per point. Therefore, 12,700 * 3 /4 = 9,525 EMUs per pixel.
[ "Calculate", "the", "vertices", "that", "define", "the", "position", "of", "a", "graphical", "object", "within", "the", "worksheet", "in", "EMUs", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L6212-L6225
train
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.size_col
def size_col(col) #:nodoc: # Look up the cell value to see if it has been changed. if @col_sizes[col] width = @col_sizes[col] # Convert to pixels. if width == 0 pixels = 0 elsif width < 1 pixels = (width * (MAX_DIGIT_WIDTH + PADDING) + 0.5).to_i e...
ruby
def size_col(col) #:nodoc: # Look up the cell value to see if it has been changed. if @col_sizes[col] width = @col_sizes[col] # Convert to pixels. if width == 0 pixels = 0 elsif width < 1 pixels = (width * (MAX_DIGIT_WIDTH + PADDING) + 0.5).to_i e...
[ "def", "size_col", "(", "col", ")", "if", "@col_sizes", "[", "col", "]", "width", "=", "@col_sizes", "[", "col", "]", "if", "width", "==", "0", "pixels", "=", "0", "elsif", "width", "<", "1", "pixels", "=", "(", "width", "*", "(", "MAX_DIGIT_WIDTH", ...
Convert the width of a cell from user's units to pixels. Excel rounds the column width to the nearest pixel. If the width hasn't been set by the user we use the default value. If the column is hidden it has a value of zero.
[ "Convert", "the", "width", "of", "a", "cell", "from", "user", "s", "units", "to", "pixels", ".", "Excel", "rounds", "the", "column", "width", "to", "the", "nearest", "pixel", ".", "If", "the", "width", "hasn", "t", "been", "set", "by", "the", "user", ...
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L6232-L6249
train
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.size_row
def size_row(row) #:nodoc: # Look up the cell value to see if it has been changed if @row_sizes[row] height = @row_sizes[row] if height == 0 pixels = 0 else pixels = (4 / 3.0 * height).to_i end else pixels = (4 / 3.0 * @default_row_height).t...
ruby
def size_row(row) #:nodoc: # Look up the cell value to see if it has been changed if @row_sizes[row] height = @row_sizes[row] if height == 0 pixels = 0 else pixels = (4 / 3.0 * height).to_i end else pixels = (4 / 3.0 * @default_row_height).t...
[ "def", "size_row", "(", "row", ")", "if", "@row_sizes", "[", "row", "]", "height", "=", "@row_sizes", "[", "row", "]", "if", "height", "==", "0", "pixels", "=", "0", "else", "pixels", "=", "(", "4", "/", "3.0", "*", "height", ")", ".", "to_i", "e...
Convert the height of a cell from user's units to pixels. If the height hasn't been set by the user we use the default value. If the row is hidden it has a value of zero.
[ "Convert", "the", "height", "of", "a", "cell", "from", "user", "s", "units", "to", "pixels", ".", "If", "the", "height", "hasn", "t", "been", "set", "by", "the", "user", "we", "use", "the", "default", "value", ".", "If", "the", "row", "is", "hidden",...
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L6256-L6270
train
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.prepare_shape
def prepare_shape(index, drawing_id) shape = @shapes[index] # Create a Drawing object to use with worksheet unless one already exists. unless drawing? @drawing = Drawing.new @drawing.embedded = 1 @external_drawing_links << ['/drawing', "../drawings/drawing#{drawing_id}.xml"] ...
ruby
def prepare_shape(index, drawing_id) shape = @shapes[index] # Create a Drawing object to use with worksheet unless one already exists. unless drawing? @drawing = Drawing.new @drawing.embedded = 1 @external_drawing_links << ['/drawing', "../drawings/drawing#{drawing_id}.xml"] ...
[ "def", "prepare_shape", "(", "index", ",", "drawing_id", ")", "shape", "=", "@shapes", "[", "index", "]", "unless", "drawing?", "@drawing", "=", "Drawing", ".", "new", "@drawing", ".", "embedded", "=", "1", "@external_drawing_links", "<<", "[", "'/drawing'", ...
Set up drawing shapes
[ "Set", "up", "drawing", "shapes" ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L6410-L6427
train
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.button_params
def button_params(row, col, params) button = Writexlsx::Package::Button.new button_number = 1 + @buttons_array.size # Set the button caption. caption = params[:caption] || "Button #{button_number}" button.font = { :_caption => caption } # Set the macro name. if params[:macr...
ruby
def button_params(row, col, params) button = Writexlsx::Package::Button.new button_number = 1 + @buttons_array.size # Set the button caption. caption = params[:caption] || "Button #{button_number}" button.font = { :_caption => caption } # Set the macro name. if params[:macr...
[ "def", "button_params", "(", "row", ",", "col", ",", "params", ")", "button", "=", "Writexlsx", "::", "Package", "::", "Button", ".", "new", "button_number", "=", "1", "+", "@buttons_array", ".", "size", "caption", "=", "params", "[", ":caption", "]", "|...
This method handles the parameters passed to insert_button as well as calculating the comment object position and vertices.
[ "This", "method", "handles", "the", "parameters", "passed", "to", "insert_button", "as", "well", "as", "calculating", "the", "comment", "object", "position", "and", "vertices", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L6434-L6492
train
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.write_rows
def write_rows #:nodoc: calculate_spans (@dim_rowmin .. @dim_rowmax).each do |row_num| # Skip row if it doesn't contain row formatting or cell data. next if not_contain_formatting_or_data?(row_num) span_index = row_num / 16 span = @row_spans[span_index] # Wri...
ruby
def write_rows #:nodoc: calculate_spans (@dim_rowmin .. @dim_rowmax).each do |row_num| # Skip row if it doesn't contain row formatting or cell data. next if not_contain_formatting_or_data?(row_num) span_index = row_num / 16 span = @row_spans[span_index] # Wri...
[ "def", "write_rows", "calculate_spans", "(", "@dim_rowmin", "..", "@dim_rowmax", ")", ".", "each", "do", "|", "row_num", "|", "next", "if", "not_contain_formatting_or_data?", "(", "row_num", ")", "span_index", "=", "row_num", "/", "16", "span", "=", "@row_spans"...
Write out the worksheet data as a series of rows and cells.
[ "Write", "out", "the", "worksheet", "data", "as", "a", "series", "of", "rows", "and", "cells", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L6761-L6784
train
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.calculate_x_split_width
def calculate_x_split_width(width) #:nodoc: # Convert to pixels. if width < 1 pixels = int(width * 12 + 0.5) else pixels = (width * MAX_DIGIT_WIDTH + 0.5).to_i + PADDING end # Convert to points. points = pixels * 3 / 4 # Convert to twips (twentieths of a point...
ruby
def calculate_x_split_width(width) #:nodoc: # Convert to pixels. if width < 1 pixels = int(width * 12 + 0.5) else pixels = (width * MAX_DIGIT_WIDTH + 0.5).to_i + PADDING end # Convert to points. points = pixels * 3 / 4 # Convert to twips (twentieths of a point...
[ "def", "calculate_x_split_width", "(", "width", ")", "if", "width", "<", "1", "pixels", "=", "int", "(", "width", "*", "12", "+", "0.5", ")", "else", "pixels", "=", "(", "width", "*", "MAX_DIGIT_WIDTH", "+", "0.5", ")", ".", "to_i", "+", "PADDING", "...
Convert column width from user units to pane split width.
[ "Convert", "column", "width", "from", "user", "units", "to", "pane", "split", "width", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L6937-L6953
train
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.write_autofilters
def write_autofilters #:nodoc: col1, col2 = @filter_range (col1 .. col2).each do |col| # Skip if column doesn't have an active filter. next unless @filter_cols[col] # Retrieve the filter tokens and write the autofilter records. tokens = @filter_cols[col] type = @f...
ruby
def write_autofilters #:nodoc: col1, col2 = @filter_range (col1 .. col2).each do |col| # Skip if column doesn't have an active filter. next unless @filter_cols[col] # Retrieve the filter tokens and write the autofilter records. tokens = @filter_cols[col] type = @f...
[ "def", "write_autofilters", "col1", ",", "col2", "=", "@filter_range", "(", "col1", "..", "col2", ")", ".", "each", "do", "|", "col", "|", "next", "unless", "@filter_cols", "[", "col", "]", "tokens", "=", "@filter_cols", "[", "col", "]", "type", "=", "...
Function to iterate through the columns that form part of an autofilter range and write the appropriate filters.
[ "Function", "to", "iterate", "through", "the", "columns", "that", "form", "part", "of", "an", "autofilter", "range", "and", "write", "the", "appropriate", "filters", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L7108-L7122
train
cxn03651/write_xlsx
lib/write_xlsx/shape.rb
Writexlsx.Shape.calc_position_emus
def calc_position_emus(worksheet) c_start, r_start, xx1, yy1, c_end, r_end, xx2, yy2, x_abslt, y_abslt = worksheet.position_object_pixels( @column_start, @row_start, @x_offset, @y_of...
ruby
def calc_position_emus(worksheet) c_start, r_start, xx1, yy1, c_end, r_end, xx2, yy2, x_abslt, y_abslt = worksheet.position_object_pixels( @column_start, @row_start, @x_offset, @y_of...
[ "def", "calc_position_emus", "(", "worksheet", ")", "c_start", ",", "r_start", ",", "xx1", ",", "yy1", ",", "c_end", ",", "r_end", ",", "xx2", ",", "yy2", ",", "x_abslt", ",", "y_abslt", "=", "worksheet", ".", "position_object_pixels", "(", "@column_start", ...
Calculate the vertices that define the position of a shape object within the worksheet in EMUs. Save the vertices with the object. The vertices are expressed as English Metric Units (EMUs). There are 12,700 EMUs per point. Therefore, 12,700 * 3 /4 = 9,525 EMUs per pixel.
[ "Calculate", "the", "vertices", "that", "define", "the", "position", "of", "a", "shape", "object", "within", "the", "worksheet", "in", "EMUs", ".", "Save", "the", "vertices", "with", "the", "object", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/shape.rb#L156-L184
train
cxn03651/write_xlsx
lib/write_xlsx/shape.rb
Writexlsx.Shape.auto_locate_connectors
def auto_locate_connectors(shapes, shape_hash) # Valid connector shapes. connector_shapes = { :straightConnector => 1, :Connector => 1, :bentConnector => 1, :curvedConnector => 1, :line => 1 } shape_base = @type.chop.to_sym # Re...
ruby
def auto_locate_connectors(shapes, shape_hash) # Valid connector shapes. connector_shapes = { :straightConnector => 1, :Connector => 1, :bentConnector => 1, :curvedConnector => 1, :line => 1 } shape_base = @type.chop.to_sym # Re...
[ "def", "auto_locate_connectors", "(", "shapes", ",", "shape_hash", ")", "connector_shapes", "=", "{", ":straightConnector", "=>", "1", ",", ":Connector", "=>", "1", ",", ":bentConnector", "=>", "1", ",", ":curvedConnector", "=>", "1", ",", ":line", "=>", "1", ...
Re-size connector shapes if they are connected to other shapes.
[ "Re", "-", "size", "connector", "shapes", "if", "they", "are", "connected", "to", "other", "shapes", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/shape.rb#L201-L282
train
cxn03651/write_xlsx
lib/write_xlsx/shape.rb
Writexlsx.Shape.validate
def validate(index) unless %w[l ctr r just].include?(@align) raise "Shape #{index} (#{@type}) alignment (#{@align}) not in ['l', 'ctr', 'r', 'just']\n" end unless %w[t ctr b].include?(@valign) raise "Shape #{index} (#{@type}) vertical alignment (#{@valign}) not in ['t', 'ctr', 'v']\n"...
ruby
def validate(index) unless %w[l ctr r just].include?(@align) raise "Shape #{index} (#{@type}) alignment (#{@align}) not in ['l', 'ctr', 'r', 'just']\n" end unless %w[t ctr b].include?(@valign) raise "Shape #{index} (#{@type}) vertical alignment (#{@valign}) not in ['t', 'ctr', 'v']\n"...
[ "def", "validate", "(", "index", ")", "unless", "%w[", "l", "ctr", "r", "just", "]", ".", "include?", "(", "@align", ")", "raise", "\"Shape #{index} (#{@type}) alignment (#{@align}) not in ['l', 'ctr', 'r', 'just']\\n\"", "end", "unless", "%w[", "t", "ctr", "b", "]"...
Check shape attributes to ensure they are valid.
[ "Check", "shape", "attributes", "to", "ensure", "they", "are", "valid", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/shape.rb#L287-L295
train
cxn03651/write_xlsx
lib/write_xlsx/format.rb
Writexlsx.Format.copy
def copy(other) reserve = [ :xf_index, :dxf_index, :xdf_format_indices, :palette ] (instance_variables - reserve).each do |v| instance_variable_set(v, other.instance_variable_get(v)) end end
ruby
def copy(other) reserve = [ :xf_index, :dxf_index, :xdf_format_indices, :palette ] (instance_variables - reserve).each do |v| instance_variable_set(v, other.instance_variable_get(v)) end end
[ "def", "copy", "(", "other", ")", "reserve", "=", "[", ":xf_index", ",", ":dxf_index", ",", ":xdf_format_indices", ",", ":palette", "]", "(", "instance_variables", "-", "reserve", ")", ".", "each", "do", "|", "v", "|", "instance_variable_set", "(", "v", ",...
Copy the attributes of another Format object.
[ "Copy", "the", "attributes", "of", "another", "Format", "object", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/format.rb#L248-L258
train
cxn03651/write_xlsx
lib/write_xlsx/utility.rb
Writexlsx.Utility.layout_properties
def layout_properties(args, is_text = false) return unless ptrue?(args) properties = is_text ? [:x, :y] : [:x, :y, :width, :height] # Check for valid properties. args.keys.each do |key| unless properties.include?(key.to_sym) raise "Property '#{key}' not allowed in layout op...
ruby
def layout_properties(args, is_text = false) return unless ptrue?(args) properties = is_text ? [:x, :y] : [:x, :y, :width, :height] # Check for valid properties. args.keys.each do |key| unless properties.include?(key.to_sym) raise "Property '#{key}' not allowed in layout op...
[ "def", "layout_properties", "(", "args", ",", "is_text", "=", "false", ")", "return", "unless", "ptrue?", "(", "args", ")", "properties", "=", "is_text", "?", "[", ":x", ",", ":y", "]", ":", "[", ":x", ",", ":y", ",", ":width", ",", ":height", "]", ...
Convert user defined layout properties to the format required internally.
[ "Convert", "user", "defined", "layout", "properties", "to", "the", "format", "required", "internally", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/utility.rb#L365-L386
train
cxn03651/write_xlsx
lib/write_xlsx/utility.rb
Writexlsx.Utility.pixels_to_points
def pixels_to_points(vertices) col_start, row_start, x1, y1, col_end, row_end, x2, y2, left, top, width, height = vertices.flatten left *= 0.75 top *= 0.75 width *= 0.75 height *= 0.75 [left, top, width, height] end
ruby
def pixels_to_points(vertices) col_start, row_start, x1, y1, col_end, row_end, x2, y2, left, top, width, height = vertices.flatten left *= 0.75 top *= 0.75 width *= 0.75 height *= 0.75 [left, top, width, height] end
[ "def", "pixels_to_points", "(", "vertices", ")", "col_start", ",", "row_start", ",", "x1", ",", "y1", ",", "col_end", ",", "row_end", ",", "x2", ",", "y2", ",", "left", ",", "top", ",", "width", ",", "height", "=", "vertices", ".", "flatten", "left", ...
Convert vertices from pixels to points.
[ "Convert", "vertices", "from", "pixels", "to", "points", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/utility.rb#L391-L402
train
cxn03651/write_xlsx
lib/write_xlsx/sparkline.rb
Writexlsx.Sparkline.write_spark_color
def write_spark_color(element, color) # :nodoc: attr = [] attr << ['rgb', color[:_rgb]] if color[:_rgb] attr << ['theme', color[:_theme]] if color[:_theme] attr << ['tint', color[:_tint]] if color[:_tint] @writer.empty_tag(element, attr) end
ruby
def write_spark_color(element, color) # :nodoc: attr = [] attr << ['rgb', color[:_rgb]] if color[:_rgb] attr << ['theme', color[:_theme]] if color[:_theme] attr << ['tint', color[:_tint]] if color[:_tint] @writer.empty_tag(element, attr) end
[ "def", "write_spark_color", "(", "element", ",", "color", ")", "attr", "=", "[", "]", "attr", "<<", "[", "'rgb'", ",", "color", "[", ":_rgb", "]", "]", "if", "color", "[", ":_rgb", "]", "attr", "<<", "[", "'theme'", ",", "color", "[", ":_theme", "]...
Helper function for the sparkline color functions below.
[ "Helper", "function", "for", "the", "sparkline", "color", "functions", "below", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/sparkline.rb#L272-L280
train
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.assemble_xml_file
def assemble_xml_file #:nodoc: return unless @writer # Prepare format object for passing to Style.rb. prepare_format_properties write_xml_declaration do # Write the root workbook element. write_workbook do # Write the XLSX file version. write_file_version...
ruby
def assemble_xml_file #:nodoc: return unless @writer # Prepare format object for passing to Style.rb. prepare_format_properties write_xml_declaration do # Write the root workbook element. write_workbook do # Write the XLSX file version. write_file_version...
[ "def", "assemble_xml_file", "return", "unless", "@writer", "prepare_format_properties", "write_xml_declaration", "do", "write_workbook", "do", "write_file_version", "write_workbook_pr", "write_book_views", "@worksheets", ".", "write_sheets", "(", "@writer", ")", "write_defined_...
user must not use. it is internal method.
[ "user", "must", "not", "use", ".", "it", "is", "internal", "method", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L257-L290
train
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.add_format
def add_format(property_hash = {}) properties = {} if @excel2003_style properties.update(:font => 'Arial', :size => 10, :theme => -1) end properties.update(property_hash) format = Format.new(@formats, properties) @formats.formats.push(format) # Store format reference ...
ruby
def add_format(property_hash = {}) properties = {} if @excel2003_style properties.update(:font => 'Arial', :size => 10, :theme => -1) end properties.update(property_hash) format = Format.new(@formats, properties) @formats.formats.push(format) # Store format reference ...
[ "def", "add_format", "(", "property_hash", "=", "{", "}", ")", "properties", "=", "{", "}", "if", "@excel2003_style", "properties", ".", "update", "(", ":font", "=>", "'Arial'", ",", ":size", "=>", "10", ",", ":theme", "=>", "-", "1", ")", "end", "prop...
The +add_format+ method can be used to create new Format objects which are used to apply formatting to a cell. You can either define the properties at creation time via a hash of property values or later via method calls. format1 = workbook.add_format(property_hash) # Set properties at creation format2 = ...
[ "The", "+", "add_format", "+", "method", "can", "be", "used", "to", "create", "new", "Format", "objects", "which", "are", "used", "to", "apply", "formatting", "to", "a", "cell", ".", "You", "can", "either", "define", "the", "properties", "at", "creation", ...
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L427-L439
train
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.add_shape
def add_shape(properties = {}) shape = Shape.new(properties) shape.palette = @palette @shapes ||= [] @shapes << shape #Store shape reference. shape end
ruby
def add_shape(properties = {}) shape = Shape.new(properties) shape.palette = @palette @shapes ||= [] @shapes << shape #Store shape reference. shape end
[ "def", "add_shape", "(", "properties", "=", "{", "}", ")", "shape", "=", "Shape", ".", "new", "(", "properties", ")", "shape", ".", "palette", "=", "@palette", "@shapes", "||=", "[", "]", "@shapes", "<<", "shape", "shape", "end" ]
The +add_shape+ method can be used to create new shapes that may be inserted into a worksheet. You can either define the properties at creation time via a hash of property values or later via method calls. # Set properties at creation. plus = workbook.add_shape( :type => 'plus', ...
[ "The", "+", "add_shape", "+", "method", "can", "be", "used", "to", "create", "new", "shapes", "that", "may", "be", "inserted", "into", "a", "worksheet", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L675-L682
train
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.set_properties
def set_properties(params) # Ignore if no args were passed. return -1 if params.empty? # List of valid input parameters. valid = { :title => 1, :subject => 1, :author => 1, :keywords => 1, :comments => 1, :last_author => 1, ...
ruby
def set_properties(params) # Ignore if no args were passed. return -1 if params.empty? # List of valid input parameters. valid = { :title => 1, :subject => 1, :author => 1, :keywords => 1, :comments => 1, :last_author => 1, ...
[ "def", "set_properties", "(", "params", ")", "return", "-", "1", "if", "params", ".", "empty?", "valid", "=", "{", ":title", "=>", "1", ",", ":subject", "=>", "1", ",", ":author", "=>", "1", ",", ":keywords", "=>", "1", ",", ":comments", "=>", "1", ...
The set_properties method can be used to set the document properties of the Excel file created by WriteXLSX. These properties are visible when you use the Office Button -> Prepare -> Properties option in Excel and are also available to external applications that read or index windows files. The properties should ...
[ "The", "set_properties", "method", "can", "be", "used", "to", "set", "the", "document", "properties", "of", "the", "Excel", "file", "created", "by", "WriteXLSX", ".", "These", "properties", "are", "visible", "when", "you", "use", "the", "Office", "Button", "...
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L782-L810
train
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.set_custom_color
def set_custom_color(index, red = 0, green = 0, blue = 0) # Match a HTML #xxyyzz style parameter if red =~ /^#(\w\w)(\w\w)(\w\w)/ red = $1.hex green = $2.hex blue = $3.hex end # Check that the colour index is the right range if index < 8 || index > 64 ra...
ruby
def set_custom_color(index, red = 0, green = 0, blue = 0) # Match a HTML #xxyyzz style parameter if red =~ /^#(\w\w)(\w\w)(\w\w)/ red = $1.hex green = $2.hex blue = $3.hex end # Check that the colour index is the right range if index < 8 || index > 64 ra...
[ "def", "set_custom_color", "(", "index", ",", "red", "=", "0", ",", "green", "=", "0", ",", "blue", "=", "0", ")", "if", "red", "=~", "/", "\\w", "\\w", "\\w", "\\w", "\\w", "\\w", "/", "red", "=", "$1", ".", "hex", "green", "=", "$2", ".", "...
Change the RGB components of the elements in the colour palette. The set_custom_color method can be used to override one of the built-in palette values with a more suitable colour. The value for +index+ should be in the range 8..63, see "COLOURS IN EXCEL". The default named colours use the following indices: ...
[ "Change", "the", "RGB", "components", "of", "the", "elements", "in", "the", "colour", "palette", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L927-L956
train
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.store_workbook
def store_workbook #:nodoc: # Add a default worksheet if non have been added. add_worksheet if @worksheets.empty? # Ensure that at least one worksheet has been selected. @worksheets.visible_first.select if @activesheet == 0 # Set the active sheet. @activesheet = @worksheets.visible...
ruby
def store_workbook #:nodoc: # Add a default worksheet if non have been added. add_worksheet if @worksheets.empty? # Ensure that at least one worksheet has been selected. @worksheets.visible_first.select if @activesheet == 0 # Set the active sheet. @activesheet = @worksheets.visible...
[ "def", "store_workbook", "add_worksheet", "if", "@worksheets", ".", "empty?", "@worksheets", ".", "visible_first", ".", "select", "if", "@activesheet", "==", "0", "@activesheet", "=", "@worksheets", ".", "visible_first", ".", "index", "if", "@activesheet", "==", "...
Assemble worksheets into a workbook.
[ "Assemble", "worksheets", "into", "a", "workbook", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L1291-L1327
train
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.prepare_formats
def prepare_formats #:nodoc: @formats.formats.each do |format| xf_index = format.xf_index dxf_index = format.dxf_index @xf_formats[xf_index] = format if xf_index @dxf_formats[dxf_index] = format if dxf_index end end
ruby
def prepare_formats #:nodoc: @formats.formats.each do |format| xf_index = format.xf_index dxf_index = format.dxf_index @xf_formats[xf_index] = format if xf_index @dxf_formats[dxf_index] = format if dxf_index end end
[ "def", "prepare_formats", "@formats", ".", "formats", ".", "each", "do", "|", "format", "|", "xf_index", "=", "format", ".", "xf_index", "dxf_index", "=", "format", ".", "dxf_index", "@xf_formats", "[", "xf_index", "]", "=", "format", "if", "xf_index", "@dxf...
Iterate through the XF Format objects and separate them into XF and DXF formats.
[ "Iterate", "through", "the", "XF", "Format", "objects", "and", "separate", "them", "into", "XF", "and", "DXF", "formats", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L1371-L1379
train
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.prepare_fonts
def prepare_fonts #:nodoc: fonts = {} @xf_formats.each { |format| format.set_font_info(fonts) } @font_count = fonts.size # For the DXF formats we only need to check if the properties have changed. @dxf_formats.each do |format| # The only font properties that can change for a DXF...
ruby
def prepare_fonts #:nodoc: fonts = {} @xf_formats.each { |format| format.set_font_info(fonts) } @font_count = fonts.size # For the DXF formats we only need to check if the properties have changed. @dxf_formats.each do |format| # The only font properties that can change for a DXF...
[ "def", "prepare_fonts", "fonts", "=", "{", "}", "@xf_formats", ".", "each", "{", "|", "format", "|", "format", ".", "set_font_info", "(", "fonts", ")", "}", "@font_count", "=", "fonts", ".", "size", "@dxf_formats", ".", "each", "do", "|", "format", "|", ...
Iterate through the XF Format objects and give them an index to non-default font elements.
[ "Iterate", "through", "the", "XF", "Format", "objects", "and", "give", "them", "an", "index", "to", "non", "-", "default", "font", "elements", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L1385-L1400
train
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.prepare_num_formats
def prepare_num_formats #:nodoc: num_formats = {} index = 164 num_format_count = 0 (@xf_formats + @dxf_formats).each do |format| num_format = format.num_format # Check if num_format is an index to a built-in number format. # Also check for a string of ze...
ruby
def prepare_num_formats #:nodoc: num_formats = {} index = 164 num_format_count = 0 (@xf_formats + @dxf_formats).each do |format| num_format = format.num_format # Check if num_format is an index to a built-in number format. # Also check for a string of ze...
[ "def", "prepare_num_formats", "num_formats", "=", "{", "}", "index", "=", "164", "num_format_count", "=", "0", "(", "@xf_formats", "+", "@dxf_formats", ")", ".", "each", "do", "|", "format", "|", "num_format", "=", "format", ".", "num_format", "if", "num_for...
Iterate through the XF Format objects and give them an index to non-default number format elements. User defined records start from index 0xA4.
[ "Iterate", "through", "the", "XF", "Format", "objects", "and", "give", "them", "an", "index", "to", "non", "-", "default", "number", "format", "elements", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L1408-L1441
train
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.prepare_borders
def prepare_borders #:nodoc: borders = {} @xf_formats.each { |format| format.set_border_info(borders) } @border_count = borders.size # For the DXF formats we only need to check if the properties have changed. @dxf_formats.each do |format| key = format.get_border_key form...
ruby
def prepare_borders #:nodoc: borders = {} @xf_formats.each { |format| format.set_border_info(borders) } @border_count = borders.size # For the DXF formats we only need to check if the properties have changed. @dxf_formats.each do |format| key = format.get_border_key form...
[ "def", "prepare_borders", "borders", "=", "{", "}", "@xf_formats", ".", "each", "{", "|", "format", "|", "format", ".", "set_border_info", "(", "borders", ")", "}", "@border_count", "=", "borders", ".", "size", "@dxf_formats", ".", "each", "do", "|", "form...
Iterate through the XF Format objects and give them an index to non-default border elements.
[ "Iterate", "through", "the", "XF", "Format", "objects", "and", "give", "them", "an", "index", "to", "non", "-", "default", "border", "elements", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L1447-L1459
train
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.prepare_fills
def prepare_fills #:nodoc: fills = {} index = 2 # Start from 2. See above. # Add the default fills. fills['0:0:0'] = 0 fills['17:0:0'] = 1 # Store the DXF colors separately since them may be reversed below. @dxf_formats.each do |format| if format.pattern != 0 || ...
ruby
def prepare_fills #:nodoc: fills = {} index = 2 # Start from 2. See above. # Add the default fills. fills['0:0:0'] = 0 fills['17:0:0'] = 1 # Store the DXF colors separately since them may be reversed below. @dxf_formats.each do |format| if format.pattern != 0 || ...
[ "def", "prepare_fills", "fills", "=", "{", "}", "index", "=", "2", "fills", "[", "'0:0:0'", "]", "=", "0", "fills", "[", "'17:0:0'", "]", "=", "1", "@dxf_formats", ".", "each", "do", "|", "format", "|", "if", "format", ".", "pattern", "!=", "0", "|...
Iterate through the XF Format objects and give them an index to non-default fill elements. The user defined fill properties start from 2 since there are 2 default fills: patternType="none" and patternType="gray125".
[ "Iterate", "through", "the", "XF", "Format", "objects", "and", "give", "them", "an", "index", "to", "non", "-", "default", "fill", "elements", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L1468-L1521
train
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.prepare_defined_names
def prepare_defined_names #:nodoc: @worksheets.each do |sheet| # Check for Print Area settings. if sheet.autofilter_area @defined_names << [ '_xlnm._FilterDatabase', sheet.index, sheet.autofilter_area,...
ruby
def prepare_defined_names #:nodoc: @worksheets.each do |sheet| # Check for Print Area settings. if sheet.autofilter_area @defined_names << [ '_xlnm._FilterDatabase', sheet.index, sheet.autofilter_area,...
[ "def", "prepare_defined_names", "@worksheets", ".", "each", "do", "|", "sheet", "|", "if", "sheet", ".", "autofilter_area", "@defined_names", "<<", "[", "'_xlnm._FilterDatabase'", ",", "sheet", ".", "index", ",", "sheet", ".", "autofilter_area", ",", "1", "]", ...
Iterate through the worksheets and store any defined names in addition to any user defined names. Stores the defined names for the Workbook.xml and the named ranges for App.xml.
[ "Iterate", "through", "the", "worksheets", "and", "store", "any", "defined", "names", "in", "addition", "to", "any", "user", "defined", "names", ".", "Stores", "the", "defined", "names", "for", "the", "Workbook", ".", "xml", "and", "the", "named", "ranges", ...
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L1536-L1572
train
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.prepare_vml_objects
def prepare_vml_objects #:nodoc: comment_id = 0 vml_drawing_id = 0 vml_data_id = 1 vml_header_id = 0 vml_shape_id = 1024 comment_files = 0 has_button = false @worksheets.each do |sheet| next if !sheet.has_vml? && !sheet.has_header_vml? if ...
ruby
def prepare_vml_objects #:nodoc: comment_id = 0 vml_drawing_id = 0 vml_data_id = 1 vml_header_id = 0 vml_shape_id = 1024 comment_files = 0 has_button = false @worksheets.each do |sheet| next if !sheet.has_vml? && !sheet.has_header_vml? if ...
[ "def", "prepare_vml_objects", "comment_id", "=", "0", "vml_drawing_id", "=", "0", "vml_data_id", "=", "1", "vml_header_id", "=", "0", "vml_shape_id", "=", "1024", "comment_files", "=", "0", "has_button", "=", "false", "@worksheets", ".", "each", "do", "|", "sh...
Iterate through the worksheets and set up the VML objects.
[ "Iterate", "through", "the", "worksheets", "and", "set", "up", "the", "VML", "objects", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L1577-L1626
train
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.extract_named_ranges
def extract_named_ranges(defined_names) #:nodoc: named_ranges = [] defined_names.each do |defined_name| name, index, range = defined_name # Skip autoFilter ranges. next if name == '_xlnm._FilterDatabase' # We are only interested in defined names with ranges. if ran...
ruby
def extract_named_ranges(defined_names) #:nodoc: named_ranges = [] defined_names.each do |defined_name| name, index, range = defined_name # Skip autoFilter ranges. next if name == '_xlnm._FilterDatabase' # We are only interested in defined names with ranges. if ran...
[ "def", "extract_named_ranges", "(", "defined_names", ")", "named_ranges", "=", "[", "]", "defined_names", ".", "each", "do", "|", "defined_name", "|", "name", ",", "index", ",", "range", "=", "defined_name", "next", "if", "name", "==", "'_xlnm._FilterDatabase'",...
Extract the named ranges from the sorted list of defined names. These are used in the App.xml file.
[ "Extract", "the", "named", "ranges", "from", "the", "sorted", "list", "of", "defined", "names", ".", "These", "are", "used", "in", "the", "App", ".", "xml", "file", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L1770-L1796
train
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.prepare_drawings
def prepare_drawings #:nodoc: chart_ref_id = 0 image_ref_id = 0 drawing_id = 0 @worksheets.each do |sheet| chart_count = sheet.charts.size image_count = sheet.images.size shape_count = sheet.shapes.size header_image_count = sheet.header_images.size foote...
ruby
def prepare_drawings #:nodoc: chart_ref_id = 0 image_ref_id = 0 drawing_id = 0 @worksheets.each do |sheet| chart_count = sheet.charts.size image_count = sheet.images.size shape_count = sheet.shapes.size header_image_count = sheet.header_images.size foote...
[ "def", "prepare_drawings", "chart_ref_id", "=", "0", "image_ref_id", "=", "0", "drawing_id", "=", "0", "@worksheets", ".", "each", "do", "|", "sheet", "|", "chart_count", "=", "sheet", ".", "charts", ".", "size", "image_count", "=", "sheet", ".", "images", ...
Iterate through the worksheets and set up any chart or image drawings.
[ "Iterate", "through", "the", "worksheets", "and", "set", "up", "any", "chart", "or", "image", "drawings", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L1801-L1880
train
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.get_image_properties
def get_image_properties(filename) # Note the image_id, and previous_images mechanism isn't currently used. x_dpi = 96 y_dpi = 96 # Open the image file and import the data. data = File.binread(filename) if data.unpack('x A3')[0] == 'PNG' # Test for PNGs. type, width,...
ruby
def get_image_properties(filename) # Note the image_id, and previous_images mechanism isn't currently used. x_dpi = 96 y_dpi = 96 # Open the image file and import the data. data = File.binread(filename) if data.unpack('x A3')[0] == 'PNG' # Test for PNGs. type, width,...
[ "def", "get_image_properties", "(", "filename", ")", "x_dpi", "=", "96", "y_dpi", "=", "96", "data", "=", "File", ".", "binread", "(", "filename", ")", "if", "data", ".", "unpack", "(", "'x A3'", ")", "[", "0", "]", "==", "'PNG'", "type", ",", "width...
Extract information from the image file such as dimension, type, filename, and extension. Also keep track of previously seen images to optimise out any duplicates.
[ "Extract", "information", "from", "the", "image", "file", "such", "as", "dimension", "type", "filename", "and", "extension", ".", "Also", "keep", "track", "of", "previously", "seen", "images", "to", "optimise", "out", "any", "duplicates", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L1887-L1914
train
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.process_png
def process_png(data) type = 'png' width = 0 height = 0 x_dpi = 96 y_dpi = 96 offset = 8 data_length = data.size # Search through the image data to read the height and width in th the # IHDR element. Also read the DPI in the pHYs element. while offset <...
ruby
def process_png(data) type = 'png' width = 0 height = 0 x_dpi = 96 y_dpi = 96 offset = 8 data_length = data.size # Search through the image data to read the height and width in th the # IHDR element. Also read the DPI in the pHYs element. while offset <...
[ "def", "process_png", "(", "data", ")", "type", "=", "'png'", "width", "=", "0", "height", "=", "0", "x_dpi", "=", "96", "y_dpi", "=", "96", "offset", "=", "8", "data_length", "=", "data", ".", "size", "while", "offset", "<", "data_length", "length", ...
Extract width and height information from a PNG file.
[ "Extract", "width", "and", "height", "information", "from", "a", "PNG", "file", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L1919-L1958
train
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.process_bmp
def process_bmp(data, filename) #:nodoc: type = 'bmp' # Check that the file is big enough to be a bitmap. raise "#{filename} doesn't contain enough data." if data.bytesize <= 0x36 # Read the bitmap width and height. Verify the sizes. width, height = data.unpack("x18 V2") ...
ruby
def process_bmp(data, filename) #:nodoc: type = 'bmp' # Check that the file is big enough to be a bitmap. raise "#{filename} doesn't contain enough data." if data.bytesize <= 0x36 # Read the bitmap width and height. Verify the sizes. width, height = data.unpack("x18 V2") ...
[ "def", "process_bmp", "(", "data", ",", "filename", ")", "type", "=", "'bmp'", "raise", "\"#{filename} doesn't contain enough data.\"", "if", "data", ".", "bytesize", "<=", "0x36", "width", ",", "height", "=", "data", ".", "unpack", "(", "\"x18 V2\"", ")", "ra...
Extract width and height information from a BMP file.
[ "Extract", "width", "and", "height", "information", "from", "a", "BMP", "file", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L2001-L2021
train
aws/aws-xray-sdk-ruby
lib/aws-xray-sdk/configuration.rb
XRay.Configuration.daemon_address=
def daemon_address=(v) v = ENV[DaemonConfig::DAEMON_ADDRESS_KEY] || v config = DaemonConfig.new(addr: v) emitter.daemon_config = config sampler.daemon_config = config if sampler.respond_to?(:daemon_config=) end
ruby
def daemon_address=(v) v = ENV[DaemonConfig::DAEMON_ADDRESS_KEY] || v config = DaemonConfig.new(addr: v) emitter.daemon_config = config sampler.daemon_config = config if sampler.respond_to?(:daemon_config=) end
[ "def", "daemon_address", "=", "(", "v", ")", "v", "=", "ENV", "[", "DaemonConfig", "::", "DAEMON_ADDRESS_KEY", "]", "||", "v", "config", "=", "DaemonConfig", ".", "new", "(", "addr", ":", "v", ")", "emitter", ".", "daemon_config", "=", "config", "sampler...
setting daemon address for components communicate with X-Ray daemon.
[ "setting", "daemon", "address", "for", "components", "communicate", "with", "X", "-", "Ray", "daemon", "." ]
5134f203a0a0c7681e137aa6045ad64fc645c8fe
https://github.com/aws/aws-xray-sdk-ruby/blob/5134f203a0a0c7681e137aa6045ad64fc645c8fe/lib/aws-xray-sdk/configuration.rb#L43-L48
train
aws/aws-xray-sdk-ruby
lib/aws-xray-sdk/model/subsegment.rb
XRay.Subsegment.all_children_count
def all_children_count size = subsegments.count subsegments.each { |v| size += v.all_children_count } size end
ruby
def all_children_count size = subsegments.count subsegments.each { |v| size += v.all_children_count } size end
[ "def", "all_children_count", "size", "=", "subsegments", ".", "count", "subsegments", ".", "each", "{", "|", "v", "|", "size", "+=", "v", ".", "all_children_count", "}", "size", "end" ]
Returns the number of its direct and indirect children. This is useful when we remove the reference to a subsegment and need to keep remaining subsegment size accurate.
[ "Returns", "the", "number", "of", "its", "direct", "and", "indirect", "children", ".", "This", "is", "useful", "when", "we", "remove", "the", "reference", "to", "a", "subsegment", "and", "need", "to", "keep", "remaining", "subsegment", "size", "accurate", "....
5134f203a0a0c7681e137aa6045ad64fc645c8fe
https://github.com/aws/aws-xray-sdk-ruby/blob/5134f203a0a0c7681e137aa6045ad64fc645c8fe/lib/aws-xray-sdk/model/subsegment.rb#L52-L56
train
aws/aws-xray-sdk-ruby
lib/aws-xray-sdk/sampling/local/sampler.rb
XRay.LocalSampler.sample_request?
def sample_request?(sampling_req) sample = sample? return sample if sampling_req.nil? || sampling_req.empty? @custom_rules ||= [] @custom_rules.each do |c| return should_sample?(c) if c.applies?(sampling_req) end # use previously made decision based on default rule # if...
ruby
def sample_request?(sampling_req) sample = sample? return sample if sampling_req.nil? || sampling_req.empty? @custom_rules ||= [] @custom_rules.each do |c| return should_sample?(c) if c.applies?(sampling_req) end # use previously made decision based on default rule # if...
[ "def", "sample_request?", "(", "sampling_req", ")", "sample", "=", "sample?", "return", "sample", "if", "sampling_req", ".", "nil?", "||", "sampling_req", ".", "empty?", "@custom_rules", "||=", "[", "]", "@custom_rules", ".", "each", "do", "|", "c", "|", "re...
Return True if the sampler decide to sample based on input information and sampling rules. It will first check if any custom rule should be applied, if not it falls back to the default sampling rule. All arugments are extracted from incoming requests by X-Ray middleware to perform path based sampling.
[ "Return", "True", "if", "the", "sampler", "decide", "to", "sample", "based", "on", "input", "information", "and", "sampling", "rules", ".", "It", "will", "first", "check", "if", "any", "custom", "rule", "should", "be", "applied", "if", "not", "it", "falls"...
5134f203a0a0c7681e137aa6045ad64fc645c8fe
https://github.com/aws/aws-xray-sdk-ruby/blob/5134f203a0a0c7681e137aa6045ad64fc645c8fe/lib/aws-xray-sdk/sampling/local/sampler.rb#L56-L66
train
aws/aws-xray-sdk-ruby
lib/aws-xray-sdk/recorder.rb
XRay.Recorder.begin_segment
def begin_segment(name, trace_id: nil, parent_id: nil, sampled: nil) seg_name = name || config.name raise SegmentNameMissingError if seg_name.to_s.empty? # sampling decision comes from outside has higher precedence. sample = sampled.nil? ? config.sample? : sampled if sample segmen...
ruby
def begin_segment(name, trace_id: nil, parent_id: nil, sampled: nil) seg_name = name || config.name raise SegmentNameMissingError if seg_name.to_s.empty? # sampling decision comes from outside has higher precedence. sample = sampled.nil? ? config.sample? : sampled if sample segmen...
[ "def", "begin_segment", "(", "name", ",", "trace_id", ":", "nil", ",", "parent_id", ":", "nil", ",", "sampled", ":", "nil", ")", "seg_name", "=", "name", "||", "config", ".", "name", "raise", "SegmentNameMissingError", "if", "seg_name", ".", "to_s", ".", ...
Begin a segment for the current context. The recorder only keeps one segment at a time. Create a second one without closing existing one will overwrite the existing one. @return [Segment] thew newly created segment.
[ "Begin", "a", "segment", "for", "the", "current", "context", ".", "The", "recorder", "only", "keeps", "one", "segment", "at", "a", "time", ".", "Create", "a", "second", "one", "without", "closing", "existing", "one", "will", "overwrite", "the", "existing", ...
5134f203a0a0c7681e137aa6045ad64fc645c8fe
https://github.com/aws/aws-xray-sdk-ruby/blob/5134f203a0a0c7681e137aa6045ad64fc645c8fe/lib/aws-xray-sdk/recorder.rb#L27-L41
train
aws/aws-xray-sdk-ruby
lib/aws-xray-sdk/recorder.rb
XRay.Recorder.end_segment
def end_segment(end_time: nil) segment = current_segment return unless segment segment.close end_time: end_time context.clear! emitter.send_entity entity: segment if segment.ready_to_send? end
ruby
def end_segment(end_time: nil) segment = current_segment return unless segment segment.close end_time: end_time context.clear! emitter.send_entity entity: segment if segment.ready_to_send? end
[ "def", "end_segment", "(", "end_time", ":", "nil", ")", "segment", "=", "current_segment", "return", "unless", "segment", "segment", ".", "close", "end_time", ":", "end_time", "context", ".", "clear!", "emitter", ".", "send_entity", "entity", ":", "segment", "...
End the current segment and send it to X-Ray daemon if it is ready.
[ "End", "the", "current", "segment", "and", "send", "it", "to", "X", "-", "Ray", "daemon", "if", "it", "is", "ready", "." ]
5134f203a0a0c7681e137aa6045ad64fc645c8fe
https://github.com/aws/aws-xray-sdk-ruby/blob/5134f203a0a0c7681e137aa6045ad64fc645c8fe/lib/aws-xray-sdk/recorder.rb#L51-L57
train
aws/aws-xray-sdk-ruby
lib/aws-xray-sdk/recorder.rb
XRay.Recorder.begin_subsegment
def begin_subsegment(name, namespace: nil, segment: nil) entity = segment || current_entity return unless entity if entity.sampled subsegment = Subsegment.new name: name, segment: entity.segment, namespace: namespace else subsegment = DummySubsegment.new name: name, segment: enti...
ruby
def begin_subsegment(name, namespace: nil, segment: nil) entity = segment || current_entity return unless entity if entity.sampled subsegment = Subsegment.new name: name, segment: entity.segment, namespace: namespace else subsegment = DummySubsegment.new name: name, segment: enti...
[ "def", "begin_subsegment", "(", "name", ",", "namespace", ":", "nil", ",", "segment", ":", "nil", ")", "entity", "=", "segment", "||", "current_entity", "return", "unless", "entity", "if", "entity", ".", "sampled", "subsegment", "=", "Subsegment", ".", "new"...
Begin a new subsegment and add it to be the child of the current active subsegment or segment. Also tie the new created subsegment to the current context. Its sampling decision will follow its parent. @return [Subsegment] the newly created subsegment. It could be `nil` if no active entity can be found and `contex...
[ "Begin", "a", "new", "subsegment", "and", "add", "it", "to", "be", "the", "child", "of", "the", "current", "active", "subsegment", "or", "segment", ".", "Also", "tie", "the", "new", "created", "subsegment", "to", "the", "current", "context", ".", "Its", ...
5134f203a0a0c7681e137aa6045ad64fc645c8fe
https://github.com/aws/aws-xray-sdk-ruby/blob/5134f203a0a0c7681e137aa6045ad64fc645c8fe/lib/aws-xray-sdk/recorder.rb#L64-L77
train
aws/aws-xray-sdk-ruby
lib/aws-xray-sdk/recorder.rb
XRay.Recorder.end_subsegment
def end_subsegment(end_time: nil) entity = current_entity return unless entity.is_a?(Subsegment) entity.close end_time: end_time # update current context if entity.parent.closed? context.clear! else context.store_entity entity: entity.parent end # check if...
ruby
def end_subsegment(end_time: nil) entity = current_entity return unless entity.is_a?(Subsegment) entity.close end_time: end_time # update current context if entity.parent.closed? context.clear! else context.store_entity entity: entity.parent end # check if...
[ "def", "end_subsegment", "(", "end_time", ":", "nil", ")", "entity", "=", "current_entity", "return", "unless", "entity", ".", "is_a?", "(", "Subsegment", ")", "entity", ".", "close", "end_time", ":", "end_time", "if", "entity", ".", "parent", ".", "closed?"...
End the current active subsegment. It also send the entire segment if this subsegment is the last one open or stream out subsegments of its parent segment if the stream threshold is breached.
[ "End", "the", "current", "active", "subsegment", ".", "It", "also", "send", "the", "entire", "segment", "if", "this", "subsegment", "is", "the", "last", "one", "open", "or", "stream", "out", "subsegments", "of", "its", "parent", "segment", "if", "the", "st...
5134f203a0a0c7681e137aa6045ad64fc645c8fe
https://github.com/aws/aws-xray-sdk-ruby/blob/5134f203a0a0c7681e137aa6045ad64fc645c8fe/lib/aws-xray-sdk/recorder.rb#L89-L107
train