id
int32
0
24.9k
repo
stringlengths
5
58
path
stringlengths
9
168
func_name
stringlengths
9
130
original_string
stringlengths
66
10.5k
language
stringclasses
1 value
code
stringlengths
66
10.5k
code_tokens
list
docstring
stringlengths
8
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
94
266
11,900
chef/chef-zero
lib/chef_zero/rest_base.rb
ChefZero.RestBase.json_response
def json_response(response_code, data, options = {}) options = { pretty: true }.merge(options) do_pretty_json = !!options.delete(:pretty) # make sure we have a proper Boolean. json = FFI_Yajl::Encoder.encode(data, pretty: do_pretty_json) already_json_response(response_code, json, options) end
ruby
def json_response(response_code, data, options = {}) options = { pretty: true }.merge(options) do_pretty_json = !!options.delete(:pretty) # make sure we have a proper Boolean. json = FFI_Yajl::Encoder.encode(data, pretty: do_pretty_json) already_json_response(response_code, json, options) end
[ "def", "json_response", "(", "response_code", ",", "data", ",", "options", "=", "{", "}", ")", "options", "=", "{", "pretty", ":", "true", "}", ".", "merge", "(", "options", ")", "do_pretty_json", "=", "!", "!", "options", ".", "delete", "(", ":pretty", ")", "# make sure we have a proper Boolean.", "json", "=", "FFI_Yajl", "::", "Encoder", ".", "encode", "(", "data", ",", "pretty", ":", "do_pretty_json", ")", "already_json_response", "(", "response_code", ",", "json", ",", "options", ")", "end" ]
Serializes `data` to JSON and returns an Array with the response code, HTTP headers and JSON body. @param [Fixnum] response_code HTTP response code @param [Hash] data The data for the response body as a Hash @param [Hash] options @option options [Hash] :headers (see #already_json_response) @option options [Boolean] :pretty (true) Pretty-format the JSON @option options [Fixnum] :request_version (see #already_json_response) @option options [Fixnum] :response_version (see #already_json_response) @return (see #already_json_response)
[ "Serializes", "data", "to", "JSON", "and", "returns", "an", "Array", "with", "the", "response", "code", "HTTP", "headers", "and", "JSON", "body", "." ]
5873d906942770a34f0cf0fed05973ec3240a275
https://github.com/chef/chef-zero/blob/5873d906942770a34f0cf0fed05973ec3240a275/lib/chef_zero/rest_base.rb#L223-L228
11,901
chef/chef-zero
lib/chef_zero/rest_base.rb
ChefZero.RestBase.already_json_response
def already_json_response(response_code, json_text, options = {}) version_header = FFI_Yajl::Encoder.encode( "min_version" => MIN_API_VERSION.to_s, "max_version" => MAX_API_VERSION.to_s, "request_version" => options[:request_version] || DEFAULT_REQUEST_VERSION.to_s, "response_version" => options[:response_version] || DEFAULT_RESPONSE_VERSION.to_s ) headers = { "Content-Type" => "application/json", "X-Ops-Server-API-Version" => version_header, } headers.merge!(options[:headers]) if options[:headers] [ response_code, headers, json_text ] end
ruby
def already_json_response(response_code, json_text, options = {}) version_header = FFI_Yajl::Encoder.encode( "min_version" => MIN_API_VERSION.to_s, "max_version" => MAX_API_VERSION.to_s, "request_version" => options[:request_version] || DEFAULT_REQUEST_VERSION.to_s, "response_version" => options[:response_version] || DEFAULT_RESPONSE_VERSION.to_s ) headers = { "Content-Type" => "application/json", "X-Ops-Server-API-Version" => version_header, } headers.merge!(options[:headers]) if options[:headers] [ response_code, headers, json_text ] end
[ "def", "already_json_response", "(", "response_code", ",", "json_text", ",", "options", "=", "{", "}", ")", "version_header", "=", "FFI_Yajl", "::", "Encoder", ".", "encode", "(", "\"min_version\"", "=>", "MIN_API_VERSION", ".", "to_s", ",", "\"max_version\"", "=>", "MAX_API_VERSION", ".", "to_s", ",", "\"request_version\"", "=>", "options", "[", ":request_version", "]", "||", "DEFAULT_REQUEST_VERSION", ".", "to_s", ",", "\"response_version\"", "=>", "options", "[", ":response_version", "]", "||", "DEFAULT_RESPONSE_VERSION", ".", "to_s", ")", "headers", "=", "{", "\"Content-Type\"", "=>", "\"application/json\"", ",", "\"X-Ops-Server-API-Version\"", "=>", "version_header", ",", "}", "headers", ".", "merge!", "(", "options", "[", ":headers", "]", ")", "if", "options", "[", ":headers", "]", "[", "response_code", ",", "headers", ",", "json_text", "]", "end" ]
Returns an Array with the response code, HTTP headers, and JSON body. @param [Fixnum] response_code The HTTP response code @param [String] json_text The JSON body for the response @param [Hash] options @option options [Hash] :headers ({}) HTTP headers (may override default headers) @option options [Fixnum] :request_version (0) Request API version @option options [Fixnum] :response_version (0) Response API version @return [Array(Fixnum, Hash{String => String}, String)]
[ "Returns", "an", "Array", "with", "the", "response", "code", "HTTP", "headers", "and", "JSON", "body", "." ]
5873d906942770a34f0cf0fed05973ec3240a275
https://github.com/chef/chef-zero/blob/5873d906942770a34f0cf0fed05973ec3240a275/lib/chef_zero/rest_base.rb#L255-L270
11,902
chef/chef-zero
lib/chef_zero/rest_base.rb
ChefZero.RestBase.build_uri
def build_uri(base_uri, rest_path) if server.options[:single_org] # Strip off /organizations/chef if we are in single org mode if rest_path[0..1] != [ "organizations", server.options[:single_org] ] raise "Unexpected URL #{rest_path[0..1]} passed to build_uri in single org mode" end return self.class.build_uri(base_uri, rest_path[2..-1]) end self.class.build_uri(base_uri, rest_path) end
ruby
def build_uri(base_uri, rest_path) if server.options[:single_org] # Strip off /organizations/chef if we are in single org mode if rest_path[0..1] != [ "organizations", server.options[:single_org] ] raise "Unexpected URL #{rest_path[0..1]} passed to build_uri in single org mode" end return self.class.build_uri(base_uri, rest_path[2..-1]) end self.class.build_uri(base_uri, rest_path) end
[ "def", "build_uri", "(", "base_uri", ",", "rest_path", ")", "if", "server", ".", "options", "[", ":single_org", "]", "# Strip off /organizations/chef if we are in single org mode", "if", "rest_path", "[", "0", "..", "1", "]", "!=", "[", "\"organizations\"", ",", "server", ".", "options", "[", ":single_org", "]", "]", "raise", "\"Unexpected URL #{rest_path[0..1]} passed to build_uri in single org mode\"", "end", "return", "self", ".", "class", ".", "build_uri", "(", "base_uri", ",", "rest_path", "[", "2", "..", "-", "1", "]", ")", "end", "self", ".", "class", ".", "build_uri", "(", "base_uri", ",", "rest_path", ")", "end" ]
To be called from inside rest endpoints
[ "To", "be", "called", "from", "inside", "rest", "endpoints" ]
5873d906942770a34f0cf0fed05973ec3240a275
https://github.com/chef/chef-zero/blob/5873d906942770a34f0cf0fed05973ec3240a275/lib/chef_zero/rest_base.rb#L273-L284
11,903
forward3d/rbhive
lib/rbhive/t_c_l_i_connection.rb
RBHive.TCLIConnection.parse_sasl_params
def parse_sasl_params(sasl_params) # Symbilize keys in a hash if sasl_params.kind_of?(Hash) return sasl_params.inject({}) do |memo,(k,v)| memo[k.to_sym] = v; memo end end return nil end
ruby
def parse_sasl_params(sasl_params) # Symbilize keys in a hash if sasl_params.kind_of?(Hash) return sasl_params.inject({}) do |memo,(k,v)| memo[k.to_sym] = v; memo end end return nil end
[ "def", "parse_sasl_params", "(", "sasl_params", ")", "# Symbilize keys in a hash", "if", "sasl_params", ".", "kind_of?", "(", "Hash", ")", "return", "sasl_params", ".", "inject", "(", "{", "}", ")", "do", "|", "memo", ",", "(", "k", ",", "v", ")", "|", "memo", "[", "k", ".", "to_sym", "]", "=", "v", ";", "memo", "end", "end", "return", "nil", "end" ]
Processes SASL connection params and returns a hash with symbol keys or a nil
[ "Processes", "SASL", "connection", "params", "and", "returns", "a", "hash", "with", "symbol", "keys", "or", "a", "nil" ]
a630b57332f2face03501da3ecad2905c78056fa
https://github.com/forward3d/rbhive/blob/a630b57332f2face03501da3ecad2905c78056fa/lib/rbhive/t_c_l_i_connection.rb#L135-L144
11,904
forward3d/rbhive
lib/rbhive/t_c_l_i_connection.rb
RBHive.TCLIConnection.async_state
def async_state(handles) response = @client.GetOperationStatus( Hive2::Thrift::TGetOperationStatusReq.new(operationHandle: prepare_operation_handle(handles)) ) case response.operationState when Hive2::Thrift::TOperationState::FINISHED_STATE return :finished when Hive2::Thrift::TOperationState::INITIALIZED_STATE return :initialized when Hive2::Thrift::TOperationState::RUNNING_STATE return :running when Hive2::Thrift::TOperationState::CANCELED_STATE return :cancelled when Hive2::Thrift::TOperationState::CLOSED_STATE return :closed when Hive2::Thrift::TOperationState::ERROR_STATE return :error when Hive2::Thrift::TOperationState::UKNOWN_STATE return :unknown when Hive2::Thrift::TOperationState::PENDING_STATE return :pending when nil raise "No operation state found for handles - has the session been closed?" else return :state_not_in_protocol end end
ruby
def async_state(handles) response = @client.GetOperationStatus( Hive2::Thrift::TGetOperationStatusReq.new(operationHandle: prepare_operation_handle(handles)) ) case response.operationState when Hive2::Thrift::TOperationState::FINISHED_STATE return :finished when Hive2::Thrift::TOperationState::INITIALIZED_STATE return :initialized when Hive2::Thrift::TOperationState::RUNNING_STATE return :running when Hive2::Thrift::TOperationState::CANCELED_STATE return :cancelled when Hive2::Thrift::TOperationState::CLOSED_STATE return :closed when Hive2::Thrift::TOperationState::ERROR_STATE return :error when Hive2::Thrift::TOperationState::UKNOWN_STATE return :unknown when Hive2::Thrift::TOperationState::PENDING_STATE return :pending when nil raise "No operation state found for handles - has the session been closed?" else return :state_not_in_protocol end end
[ "def", "async_state", "(", "handles", ")", "response", "=", "@client", ".", "GetOperationStatus", "(", "Hive2", "::", "Thrift", "::", "TGetOperationStatusReq", ".", "new", "(", "operationHandle", ":", "prepare_operation_handle", "(", "handles", ")", ")", ")", "case", "response", ".", "operationState", "when", "Hive2", "::", "Thrift", "::", "TOperationState", "::", "FINISHED_STATE", "return", ":finished", "when", "Hive2", "::", "Thrift", "::", "TOperationState", "::", "INITIALIZED_STATE", "return", ":initialized", "when", "Hive2", "::", "Thrift", "::", "TOperationState", "::", "RUNNING_STATE", "return", ":running", "when", "Hive2", "::", "Thrift", "::", "TOperationState", "::", "CANCELED_STATE", "return", ":cancelled", "when", "Hive2", "::", "Thrift", "::", "TOperationState", "::", "CLOSED_STATE", "return", ":closed", "when", "Hive2", "::", "Thrift", "::", "TOperationState", "::", "ERROR_STATE", "return", ":error", "when", "Hive2", "::", "Thrift", "::", "TOperationState", "::", "UKNOWN_STATE", "return", ":unknown", "when", "Hive2", "::", "Thrift", "::", "TOperationState", "::", "PENDING_STATE", "return", ":pending", "when", "nil", "raise", "\"No operation state found for handles - has the session been closed?\"", "else", "return", ":state_not_in_protocol", "end", "end" ]
Map states to symbols
[ "Map", "states", "to", "symbols" ]
a630b57332f2face03501da3ecad2905c78056fa
https://github.com/forward3d/rbhive/blob/a630b57332f2face03501da3ecad2905c78056fa/lib/rbhive/t_c_l_i_connection.rb#L237-L264
11,905
forward3d/rbhive
lib/rbhive/t_c_l_i_connection.rb
RBHive.TCLIConnection.async_fetch
def async_fetch(handles, max_rows = 100) # Can't get data from an unfinished query unless async_is_complete?(handles) raise "Can't perform fetch on a query in state: #{async_state(handles)}" end # Fetch and fetch_rows(prepare_operation_handle(handles), :first, max_rows) end
ruby
def async_fetch(handles, max_rows = 100) # Can't get data from an unfinished query unless async_is_complete?(handles) raise "Can't perform fetch on a query in state: #{async_state(handles)}" end # Fetch and fetch_rows(prepare_operation_handle(handles), :first, max_rows) end
[ "def", "async_fetch", "(", "handles", ",", "max_rows", "=", "100", ")", "# Can't get data from an unfinished query", "unless", "async_is_complete?", "(", "handles", ")", "raise", "\"Can't perform fetch on a query in state: #{async_state(handles)}\"", "end", "# Fetch and", "fetch_rows", "(", "prepare_operation_handle", "(", "handles", ")", ",", ":first", ",", "max_rows", ")", "end" ]
Async fetch results from an async execute
[ "Async", "fetch", "results", "from", "an", "async", "execute" ]
a630b57332f2face03501da3ecad2905c78056fa
https://github.com/forward3d/rbhive/blob/a630b57332f2face03501da3ecad2905c78056fa/lib/rbhive/t_c_l_i_connection.rb#L267-L275
11,906
forward3d/rbhive
lib/rbhive/t_c_l_i_connection.rb
RBHive.TCLIConnection.fetch_rows
def fetch_rows(op_handle, orientation = :first, max_rows = 1000) fetch_req = prepare_fetch_results(op_handle, orientation, max_rows) fetch_results = @client.FetchResults(fetch_req) raise_error_if_failed!(fetch_results) rows = fetch_results.results.rows TCLIResultSet.new(rows, TCLISchemaDefinition.new(get_schema_for(op_handle), rows.first)) end
ruby
def fetch_rows(op_handle, orientation = :first, max_rows = 1000) fetch_req = prepare_fetch_results(op_handle, orientation, max_rows) fetch_results = @client.FetchResults(fetch_req) raise_error_if_failed!(fetch_results) rows = fetch_results.results.rows TCLIResultSet.new(rows, TCLISchemaDefinition.new(get_schema_for(op_handle), rows.first)) end
[ "def", "fetch_rows", "(", "op_handle", ",", "orientation", "=", ":first", ",", "max_rows", "=", "1000", ")", "fetch_req", "=", "prepare_fetch_results", "(", "op_handle", ",", "orientation", ",", "max_rows", ")", "fetch_results", "=", "@client", ".", "FetchResults", "(", "fetch_req", ")", "raise_error_if_failed!", "(", "fetch_results", ")", "rows", "=", "fetch_results", ".", "results", ".", "rows", "TCLIResultSet", ".", "new", "(", "rows", ",", "TCLISchemaDefinition", ".", "new", "(", "get_schema_for", "(", "op_handle", ")", ",", "rows", ".", "first", ")", ")", "end" ]
Pull rows from the query result
[ "Pull", "rows", "from", "the", "query", "result" ]
a630b57332f2face03501da3ecad2905c78056fa
https://github.com/forward3d/rbhive/blob/a630b57332f2face03501da3ecad2905c78056fa/lib/rbhive/t_c_l_i_connection.rb#L300-L306
11,907
forward3d/rbhive
lib/rbhive/t_c_l_i_connection.rb
RBHive.TCLIConnection.raise_error_if_failed!
def raise_error_if_failed!(result) return if result.status.statusCode == 0 error_message = result.status.errorMessage || 'Execution failed!' raise RBHive::TCLIConnectionError.new(error_message) end
ruby
def raise_error_if_failed!(result) return if result.status.statusCode == 0 error_message = result.status.errorMessage || 'Execution failed!' raise RBHive::TCLIConnectionError.new(error_message) end
[ "def", "raise_error_if_failed!", "(", "result", ")", "return", "if", "result", ".", "status", ".", "statusCode", "==", "0", "error_message", "=", "result", ".", "status", ".", "errorMessage", "||", "'Execution failed!'", "raise", "RBHive", "::", "TCLIConnectionError", ".", "new", "(", "error_message", ")", "end" ]
Raises an exception if given operation result is a failure
[ "Raises", "an", "exception", "if", "given", "operation", "result", "is", "a", "failure" ]
a630b57332f2face03501da3ecad2905c78056fa
https://github.com/forward3d/rbhive/blob/a630b57332f2face03501da3ecad2905c78056fa/lib/rbhive/t_c_l_i_connection.rb#L433-L437
11,908
heroku/legacy-cli
lib/heroku/command/addons.rb
Heroku::Command.Addons.parse_options
def parse_options(args) config = {} deprecated_args = [] flag = /^--/ args.size.times do break if args.empty? peek = args.first next unless peek && (peek.match(flag) || peek.match(/=/)) arg = args.shift peek = args.first key = arg if key.match(/=/) deprecated_args << key unless key.match(flag) key, value = key.split('=', 2) elsif peek.nil? || peek.match(flag) value = true else value = args.shift end value = true if value == 'true' config[key.sub(flag, '')] = value if !deprecated_args.empty? out_string = deprecated_args.map{|a| "--#{a}"}.join(' ') display("Warning: non-unix style params have been deprecated, use #{out_string} instead") end end config end
ruby
def parse_options(args) config = {} deprecated_args = [] flag = /^--/ args.size.times do break if args.empty? peek = args.first next unless peek && (peek.match(flag) || peek.match(/=/)) arg = args.shift peek = args.first key = arg if key.match(/=/) deprecated_args << key unless key.match(flag) key, value = key.split('=', 2) elsif peek.nil? || peek.match(flag) value = true else value = args.shift end value = true if value == 'true' config[key.sub(flag, '')] = value if !deprecated_args.empty? out_string = deprecated_args.map{|a| "--#{a}"}.join(' ') display("Warning: non-unix style params have been deprecated, use #{out_string} instead") end end config end
[ "def", "parse_options", "(", "args", ")", "config", "=", "{", "}", "deprecated_args", "=", "[", "]", "flag", "=", "/", "/", "args", ".", "size", ".", "times", "do", "break", "if", "args", ".", "empty?", "peek", "=", "args", ".", "first", "next", "unless", "peek", "&&", "(", "peek", ".", "match", "(", "flag", ")", "||", "peek", ".", "match", "(", "/", "/", ")", ")", "arg", "=", "args", ".", "shift", "peek", "=", "args", ".", "first", "key", "=", "arg", "if", "key", ".", "match", "(", "/", "/", ")", "deprecated_args", "<<", "key", "unless", "key", ".", "match", "(", "flag", ")", "key", ",", "value", "=", "key", ".", "split", "(", "'='", ",", "2", ")", "elsif", "peek", ".", "nil?", "||", "peek", ".", "match", "(", "flag", ")", "value", "=", "true", "else", "value", "=", "args", ".", "shift", "end", "value", "=", "true", "if", "value", "==", "'true'", "config", "[", "key", ".", "sub", "(", "flag", ",", "''", ")", "]", "=", "value", "if", "!", "deprecated_args", ".", "empty?", "out_string", "=", "deprecated_args", ".", "map", "{", "|", "a", "|", "\"--#{a}\"", "}", ".", "join", "(", "' '", ")", "display", "(", "\"Warning: non-unix style params have been deprecated, use #{out_string} instead\"", ")", "end", "end", "config", "end" ]
this will clean up when we officially deprecate
[ "this", "will", "clean", "up", "when", "we", "officially", "deprecate" ]
6f18521a258394bfb79e6b36f7160ad8559a8e16
https://github.com/heroku/legacy-cli/blob/6f18521a258394bfb79e6b36f7160ad8559a8e16/lib/heroku/command/addons.rb#L414-L444
11,909
heroku/legacy-cli
lib/heroku/helpers.rb
Heroku.Helpers.line_formatter
def line_formatter(array) if array.any? {|item| item.is_a?(Array)} cols = [] array.each do |item| if item.is_a?(Array) item.each_with_index { |val,idx| cols[idx] = [cols[idx]||0, (val || '').length].max } end end cols.map { |col| "%-#{col}s" }.join(" ") else "%s" end end
ruby
def line_formatter(array) if array.any? {|item| item.is_a?(Array)} cols = [] array.each do |item| if item.is_a?(Array) item.each_with_index { |val,idx| cols[idx] = [cols[idx]||0, (val || '').length].max } end end cols.map { |col| "%-#{col}s" }.join(" ") else "%s" end end
[ "def", "line_formatter", "(", "array", ")", "if", "array", ".", "any?", "{", "|", "item", "|", "item", ".", "is_a?", "(", "Array", ")", "}", "cols", "=", "[", "]", "array", ".", "each", "do", "|", "item", "|", "if", "item", ".", "is_a?", "(", "Array", ")", "item", ".", "each_with_index", "{", "|", "val", ",", "idx", "|", "cols", "[", "idx", "]", "=", "[", "cols", "[", "idx", "]", "||", "0", ",", "(", "val", "||", "''", ")", ".", "length", "]", ".", "max", "}", "end", "end", "cols", ".", "map", "{", "|", "col", "|", "\"%-#{col}s\"", "}", ".", "join", "(", "\" \"", ")", "else", "\"%s\"", "end", "end" ]
produces a printf formatter line for an array of items if an individual line item is an array, it will create columns that are lined-up line_formatter(["foo", "barbaz"]) # => "%-6s" line_formatter(["foo", "barbaz"], ["bar", "qux"]) # => "%-3s %-6s"
[ "produces", "a", "printf", "formatter", "line", "for", "an", "array", "of", "items", "if", "an", "individual", "line", "item", "is", "an", "array", "it", "will", "create", "columns", "that", "are", "lined", "-", "up" ]
6f18521a258394bfb79e6b36f7160ad8559a8e16
https://github.com/heroku/legacy-cli/blob/6f18521a258394bfb79e6b36f7160ad8559a8e16/lib/heroku/helpers.rb#L403-L415
11,910
randym/axlsx
lib/axlsx/drawing/str_data.rb
Axlsx.StrData.data=
def data=(values=[]) @tag_name = values.first.is_a?(Cell) ? :strCache : :strLit values.each do |value| v = value.is_a?(Cell) ? value.value : value @pt << @type.new(:v => v) end end
ruby
def data=(values=[]) @tag_name = values.first.is_a?(Cell) ? :strCache : :strLit values.each do |value| v = value.is_a?(Cell) ? value.value : value @pt << @type.new(:v => v) end end
[ "def", "data", "=", "(", "values", "=", "[", "]", ")", "@tag_name", "=", "values", ".", "first", ".", "is_a?", "(", "Cell", ")", "?", ":strCache", ":", ":strLit", "values", ".", "each", "do", "|", "value", "|", "v", "=", "value", ".", "is_a?", "(", "Cell", ")", "?", "value", ".", "value", ":", "value", "@pt", "<<", "@type", ".", "new", "(", ":v", "=>", "v", ")", "end", "end" ]
creates a new StrVal object @option options [Array] :data @option options [String] :tag_name Creates the val objects for this data set. I am not overly confident this is going to play nicely with time and data types. @param [Array] values An array of cells or values.
[ "creates", "a", "new", "StrVal", "object" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/drawing/str_data.rb#L22-L28
11,911
randym/axlsx
lib/axlsx/workbook/worksheet/pivot_table.rb
Axlsx.PivotTable.relationships
def relationships r = Relationships.new r << Relationship.new(cache_definition, PIVOT_TABLE_CACHE_DEFINITION_R, "../#{cache_definition.pn}") r end
ruby
def relationships r = Relationships.new r << Relationship.new(cache_definition, PIVOT_TABLE_CACHE_DEFINITION_R, "../#{cache_definition.pn}") r end
[ "def", "relationships", "r", "=", "Relationships", ".", "new", "r", "<<", "Relationship", ".", "new", "(", "cache_definition", ",", "PIVOT_TABLE_CACHE_DEFINITION_R", ",", "\"../#{cache_definition.pn}\"", ")", "r", "end" ]
The relationships for this pivot table. @return [Relationships]
[ "The", "relationships", "for", "this", "pivot", "table", "." ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/pivot_table.rb#L161-L165
11,912
randym/axlsx
lib/axlsx/workbook/worksheet/data_bar.rb
Axlsx.DataBar.color=
def color=(v) @color = v if v.is_a? Color self.color.rgb = v if v.is_a? String @color end
ruby
def color=(v) @color = v if v.is_a? Color self.color.rgb = v if v.is_a? String @color end
[ "def", "color", "=", "(", "v", ")", "@color", "=", "v", "if", "v", ".", "is_a?", "Color", "self", ".", "color", ".", "rgb", "=", "v", "if", "v", ".", "is_a?", "String", "@color", "end" ]
Sets the color for the data bars. @param [Color|String] v The color object, or rgb string value to apply
[ "Sets", "the", "color", "for", "the", "data", "bars", "." ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/data_bar.rb#L100-L104
11,913
randym/axlsx
lib/axlsx/workbook/worksheet/data_bar.rb
Axlsx.DataBar.to_xml_string
def to_xml_string(str="") serialized_tag('dataBar', str) do value_objects.to_xml_string(str) self.color.to_xml_string(str) end end
ruby
def to_xml_string(str="") serialized_tag('dataBar', str) do value_objects.to_xml_string(str) self.color.to_xml_string(str) end end
[ "def", "to_xml_string", "(", "str", "=", "\"\"", ")", "serialized_tag", "(", "'dataBar'", ",", "str", ")", "do", "value_objects", ".", "to_xml_string", "(", "str", ")", "self", ".", "color", ".", "to_xml_string", "(", "str", ")", "end", "end" ]
Serialize this object to an xml string @param [String] str @return [String]
[ "Serialize", "this", "object", "to", "an", "xml", "string" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/data_bar.rb#L109-L114
11,914
randym/axlsx
lib/axlsx/package.rb
Axlsx.Package.serialize
def serialize(output, confirm_valid=false) return false unless !confirm_valid || self.validate.empty? Relationship.clear_cached_instances Zip::OutputStream.open(output) do |zip| write_parts(zip) end true end
ruby
def serialize(output, confirm_valid=false) return false unless !confirm_valid || self.validate.empty? Relationship.clear_cached_instances Zip::OutputStream.open(output) do |zip| write_parts(zip) end true end
[ "def", "serialize", "(", "output", ",", "confirm_valid", "=", "false", ")", "return", "false", "unless", "!", "confirm_valid", "||", "self", ".", "validate", ".", "empty?", "Relationship", ".", "clear_cached_instances", "Zip", "::", "OutputStream", ".", "open", "(", "output", ")", "do", "|", "zip", "|", "write_parts", "(", "zip", ")", "end", "true", "end" ]
Serialize your workbook to disk as an xlsx document. @param [String] output The name of the file you want to serialize your package to @param [Boolean] confirm_valid Validate the package prior to serialization. @return [Boolean] False if confirm_valid and validation errors exist. True if the package was serialized @note A tremendous amount of effort has gone into ensuring that you cannot create invalid xlsx documents. confirm_valid should be used in the rare case that you cannot open the serialized file. @see Package#validate @example # This is how easy it is to create a valid xlsx file. Of course you might want to add a sheet or two, and maybe some data, styles and charts. # Take a look at the README for an example of how to do it! #serialize to a file p = Axlsx::Package.new # ......add cool stuff to your workbook...... p.serialize("example.xlsx") # Serialize to a stream s = p.to_stream() File.open('example_streamed.xlsx', 'w') { |f| f.write(s.read) }
[ "Serialize", "your", "workbook", "to", "disk", "as", "an", "xlsx", "document", "." ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/package.rb#L101-L108
11,915
randym/axlsx
lib/axlsx/package.rb
Axlsx.Package.to_stream
def to_stream(confirm_valid=false) return false unless !confirm_valid || self.validate.empty? Relationship.clear_cached_instances zip = write_parts(Zip::OutputStream.new(StringIO.new, true)) stream = zip.close_buffer stream.rewind stream end
ruby
def to_stream(confirm_valid=false) return false unless !confirm_valid || self.validate.empty? Relationship.clear_cached_instances zip = write_parts(Zip::OutputStream.new(StringIO.new, true)) stream = zip.close_buffer stream.rewind stream end
[ "def", "to_stream", "(", "confirm_valid", "=", "false", ")", "return", "false", "unless", "!", "confirm_valid", "||", "self", ".", "validate", ".", "empty?", "Relationship", ".", "clear_cached_instances", "zip", "=", "write_parts", "(", "Zip", "::", "OutputStream", ".", "new", "(", "StringIO", ".", "new", ",", "true", ")", ")", "stream", "=", "zip", ".", "close_buffer", "stream", ".", "rewind", "stream", "end" ]
Serialize your workbook to a StringIO instance @param [Boolean] confirm_valid Validate the package prior to serialization. @return [StringIO|Boolean] False if confirm_valid and validation errors exist. rewound string IO if not.
[ "Serialize", "your", "workbook", "to", "a", "StringIO", "instance" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/package.rb#L114-L121
11,916
randym/axlsx
lib/axlsx/package.rb
Axlsx.Package.write_parts
def write_parts(zip) p = parts p.each do |part| unless part[:doc].nil? zip.put_next_entry(zip_entry_for_part(part)) part[:doc].to_xml_string(zip) end unless part[:path].nil? zip.put_next_entry(zip_entry_for_part(part)) zip.write IO.read(part[:path]) end end zip end
ruby
def write_parts(zip) p = parts p.each do |part| unless part[:doc].nil? zip.put_next_entry(zip_entry_for_part(part)) part[:doc].to_xml_string(zip) end unless part[:path].nil? zip.put_next_entry(zip_entry_for_part(part)) zip.write IO.read(part[:path]) end end zip end
[ "def", "write_parts", "(", "zip", ")", "p", "=", "parts", "p", ".", "each", "do", "|", "part", "|", "unless", "part", "[", ":doc", "]", ".", "nil?", "zip", ".", "put_next_entry", "(", "zip_entry_for_part", "(", "part", ")", ")", "part", "[", ":doc", "]", ".", "to_xml_string", "(", "zip", ")", "end", "unless", "part", "[", ":path", "]", ".", "nil?", "zip", ".", "put_next_entry", "(", "zip_entry_for_part", "(", "part", ")", ")", "zip", ".", "write", "IO", ".", "read", "(", "part", "[", ":path", "]", ")", "end", "end", "zip", "end" ]
Writes the package parts to a zip archive. @param [Zip::OutputStream] zip @return [Zip::OutputStream]
[ "Writes", "the", "package", "parts", "to", "a", "zip", "archive", "." ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/package.rb#L161-L174
11,917
randym/axlsx
lib/axlsx/package.rb
Axlsx.Package.parts
def parts parts = [ {:entry => RELS_PN, :doc => relationships, :schema => RELS_XSD}, {:entry => "xl/#{STYLES_PN}", :doc => workbook.styles, :schema => SML_XSD}, {:entry => CORE_PN, :doc => @core, :schema => CORE_XSD}, {:entry => APP_PN, :doc => @app, :schema => APP_XSD}, {:entry => WORKBOOK_RELS_PN, :doc => workbook.relationships, :schema => RELS_XSD}, {:entry => CONTENT_TYPES_PN, :doc => content_types, :schema => CONTENT_TYPES_XSD}, {:entry => WORKBOOK_PN, :doc => workbook, :schema => SML_XSD} ] workbook.drawings.each do |drawing| parts << {:entry => "xl/#{drawing.rels_pn}", :doc => drawing.relationships, :schema => RELS_XSD} parts << {:entry => "xl/#{drawing.pn}", :doc => drawing, :schema => DRAWING_XSD} end workbook.tables.each do |table| parts << {:entry => "xl/#{table.pn}", :doc => table, :schema => SML_XSD} end workbook.pivot_tables.each do |pivot_table| cache_definition = pivot_table.cache_definition parts << {:entry => "xl/#{pivot_table.rels_pn}", :doc => pivot_table.relationships, :schema => RELS_XSD} parts << {:entry => "xl/#{pivot_table.pn}", :doc => pivot_table} #, :schema => SML_XSD} parts << {:entry => "xl/#{cache_definition.pn}", :doc => cache_definition} #, :schema => SML_XSD} end workbook.comments.each do|comment| if comment.size > 0 parts << { :entry => "xl/#{comment.pn}", :doc => comment, :schema => SML_XSD } parts << { :entry => "xl/#{comment.vml_drawing.pn}", :doc => comment.vml_drawing, :schema => nil } end end workbook.charts.each do |chart| parts << {:entry => "xl/#{chart.pn}", :doc => chart, :schema => DRAWING_XSD} end workbook.images.each do |image| parts << {:entry => "xl/#{image.pn}", :path => image.image_src} end if use_shared_strings parts << {:entry => "xl/#{SHARED_STRINGS_PN}", :doc => workbook.shared_strings, :schema => SML_XSD} end workbook.worksheets.each do |sheet| parts << {:entry => "xl/#{sheet.rels_pn}", :doc => sheet.relationships, :schema => RELS_XSD} parts << {:entry => "xl/#{sheet.pn}", :doc => sheet, :schema => SML_XSD} end # Sort parts for correct MIME detection parts.sort_by { |part| part[:entry] } end
ruby
def parts parts = [ {:entry => RELS_PN, :doc => relationships, :schema => RELS_XSD}, {:entry => "xl/#{STYLES_PN}", :doc => workbook.styles, :schema => SML_XSD}, {:entry => CORE_PN, :doc => @core, :schema => CORE_XSD}, {:entry => APP_PN, :doc => @app, :schema => APP_XSD}, {:entry => WORKBOOK_RELS_PN, :doc => workbook.relationships, :schema => RELS_XSD}, {:entry => CONTENT_TYPES_PN, :doc => content_types, :schema => CONTENT_TYPES_XSD}, {:entry => WORKBOOK_PN, :doc => workbook, :schema => SML_XSD} ] workbook.drawings.each do |drawing| parts << {:entry => "xl/#{drawing.rels_pn}", :doc => drawing.relationships, :schema => RELS_XSD} parts << {:entry => "xl/#{drawing.pn}", :doc => drawing, :schema => DRAWING_XSD} end workbook.tables.each do |table| parts << {:entry => "xl/#{table.pn}", :doc => table, :schema => SML_XSD} end workbook.pivot_tables.each do |pivot_table| cache_definition = pivot_table.cache_definition parts << {:entry => "xl/#{pivot_table.rels_pn}", :doc => pivot_table.relationships, :schema => RELS_XSD} parts << {:entry => "xl/#{pivot_table.pn}", :doc => pivot_table} #, :schema => SML_XSD} parts << {:entry => "xl/#{cache_definition.pn}", :doc => cache_definition} #, :schema => SML_XSD} end workbook.comments.each do|comment| if comment.size > 0 parts << { :entry => "xl/#{comment.pn}", :doc => comment, :schema => SML_XSD } parts << { :entry => "xl/#{comment.vml_drawing.pn}", :doc => comment.vml_drawing, :schema => nil } end end workbook.charts.each do |chart| parts << {:entry => "xl/#{chart.pn}", :doc => chart, :schema => DRAWING_XSD} end workbook.images.each do |image| parts << {:entry => "xl/#{image.pn}", :path => image.image_src} end if use_shared_strings parts << {:entry => "xl/#{SHARED_STRINGS_PN}", :doc => workbook.shared_strings, :schema => SML_XSD} end workbook.worksheets.each do |sheet| parts << {:entry => "xl/#{sheet.rels_pn}", :doc => sheet.relationships, :schema => RELS_XSD} parts << {:entry => "xl/#{sheet.pn}", :doc => sheet, :schema => SML_XSD} end # Sort parts for correct MIME detection parts.sort_by { |part| part[:entry] } end
[ "def", "parts", "parts", "=", "[", "{", ":entry", "=>", "RELS_PN", ",", ":doc", "=>", "relationships", ",", ":schema", "=>", "RELS_XSD", "}", ",", "{", ":entry", "=>", "\"xl/#{STYLES_PN}\"", ",", ":doc", "=>", "workbook", ".", "styles", ",", ":schema", "=>", "SML_XSD", "}", ",", "{", ":entry", "=>", "CORE_PN", ",", ":doc", "=>", "@core", ",", ":schema", "=>", "CORE_XSD", "}", ",", "{", ":entry", "=>", "APP_PN", ",", ":doc", "=>", "@app", ",", ":schema", "=>", "APP_XSD", "}", ",", "{", ":entry", "=>", "WORKBOOK_RELS_PN", ",", ":doc", "=>", "workbook", ".", "relationships", ",", ":schema", "=>", "RELS_XSD", "}", ",", "{", ":entry", "=>", "CONTENT_TYPES_PN", ",", ":doc", "=>", "content_types", ",", ":schema", "=>", "CONTENT_TYPES_XSD", "}", ",", "{", ":entry", "=>", "WORKBOOK_PN", ",", ":doc", "=>", "workbook", ",", ":schema", "=>", "SML_XSD", "}", "]", "workbook", ".", "drawings", ".", "each", "do", "|", "drawing", "|", "parts", "<<", "{", ":entry", "=>", "\"xl/#{drawing.rels_pn}\"", ",", ":doc", "=>", "drawing", ".", "relationships", ",", ":schema", "=>", "RELS_XSD", "}", "parts", "<<", "{", ":entry", "=>", "\"xl/#{drawing.pn}\"", ",", ":doc", "=>", "drawing", ",", ":schema", "=>", "DRAWING_XSD", "}", "end", "workbook", ".", "tables", ".", "each", "do", "|", "table", "|", "parts", "<<", "{", ":entry", "=>", "\"xl/#{table.pn}\"", ",", ":doc", "=>", "table", ",", ":schema", "=>", "SML_XSD", "}", "end", "workbook", ".", "pivot_tables", ".", "each", "do", "|", "pivot_table", "|", "cache_definition", "=", "pivot_table", ".", "cache_definition", "parts", "<<", "{", ":entry", "=>", "\"xl/#{pivot_table.rels_pn}\"", ",", ":doc", "=>", "pivot_table", ".", "relationships", ",", ":schema", "=>", "RELS_XSD", "}", "parts", "<<", "{", ":entry", "=>", "\"xl/#{pivot_table.pn}\"", ",", ":doc", "=>", "pivot_table", "}", "#, :schema => SML_XSD}", "parts", "<<", "{", ":entry", "=>", "\"xl/#{cache_definition.pn}\"", ",", ":doc", "=>", "cache_definition", "}", "#, :schema => SML_XSD}", "end", "workbook", ".", "comments", ".", "each", "do", "|", "comment", "|", "if", "comment", ".", "size", ">", "0", "parts", "<<", "{", ":entry", "=>", "\"xl/#{comment.pn}\"", ",", ":doc", "=>", "comment", ",", ":schema", "=>", "SML_XSD", "}", "parts", "<<", "{", ":entry", "=>", "\"xl/#{comment.vml_drawing.pn}\"", ",", ":doc", "=>", "comment", ".", "vml_drawing", ",", ":schema", "=>", "nil", "}", "end", "end", "workbook", ".", "charts", ".", "each", "do", "|", "chart", "|", "parts", "<<", "{", ":entry", "=>", "\"xl/#{chart.pn}\"", ",", ":doc", "=>", "chart", ",", ":schema", "=>", "DRAWING_XSD", "}", "end", "workbook", ".", "images", ".", "each", "do", "|", "image", "|", "parts", "<<", "{", ":entry", "=>", "\"xl/#{image.pn}\"", ",", ":path", "=>", "image", ".", "image_src", "}", "end", "if", "use_shared_strings", "parts", "<<", "{", ":entry", "=>", "\"xl/#{SHARED_STRINGS_PN}\"", ",", ":doc", "=>", "workbook", ".", "shared_strings", ",", ":schema", "=>", "SML_XSD", "}", "end", "workbook", ".", "worksheets", ".", "each", "do", "|", "sheet", "|", "parts", "<<", "{", ":entry", "=>", "\"xl/#{sheet.rels_pn}\"", ",", ":doc", "=>", "sheet", ".", "relationships", ",", ":schema", "=>", "RELS_XSD", "}", "parts", "<<", "{", ":entry", "=>", "\"xl/#{sheet.pn}\"", ",", ":doc", "=>", "sheet", ",", ":schema", "=>", "SML_XSD", "}", "end", "# Sort parts for correct MIME detection", "parts", ".", "sort_by", "{", "|", "part", "|", "part", "[", ":entry", "]", "}", "end" ]
The parts of a package @return [Array] An array of hashes that define the entry, document and schema for each part of the package. @private
[ "The", "parts", "of", "a", "package" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/package.rb#L195-L248
11,918
randym/axlsx
lib/axlsx/package.rb
Axlsx.Package.validate_single_doc
def validate_single_doc(schema, doc) schema = Nokogiri::XML::Schema(File.open(schema)) doc = Nokogiri::XML(doc) errors = [] schema.validate(doc).each do |error| errors << error end errors end
ruby
def validate_single_doc(schema, doc) schema = Nokogiri::XML::Schema(File.open(schema)) doc = Nokogiri::XML(doc) errors = [] schema.validate(doc).each do |error| errors << error end errors end
[ "def", "validate_single_doc", "(", "schema", ",", "doc", ")", "schema", "=", "Nokogiri", "::", "XML", "::", "Schema", "(", "File", ".", "open", "(", "schema", ")", ")", "doc", "=", "Nokogiri", "::", "XML", "(", "doc", ")", "errors", "=", "[", "]", "schema", ".", "validate", "(", "doc", ")", ".", "each", "do", "|", "error", "|", "errors", "<<", "error", "end", "errors", "end" ]
Performs xsd validation for a signle document @param [String] schema path to the xsd schema to be used in validation. @param [String] doc The xml text to be validated @return [Array] An array of all validation errors encountered. @private
[ "Performs", "xsd", "validation", "for", "a", "signle", "document" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/package.rb#L256-L264
11,919
randym/axlsx
lib/axlsx/package.rb
Axlsx.Package.content_types
def content_types c_types = base_content_types workbook.drawings.each do |drawing| c_types << Axlsx::Override.new(:PartName => "/xl/#{drawing.pn}", :ContentType => DRAWING_CT) end workbook.charts.each do |chart| c_types << Axlsx::Override.new(:PartName => "/xl/#{chart.pn}", :ContentType => CHART_CT) end workbook.tables.each do |table| c_types << Axlsx::Override.new(:PartName => "/xl/#{table.pn}", :ContentType => TABLE_CT) end workbook.pivot_tables.each do |pivot_table| c_types << Axlsx::Override.new(:PartName => "/xl/#{pivot_table.pn}", :ContentType => PIVOT_TABLE_CT) c_types << Axlsx::Override.new(:PartName => "/xl/#{pivot_table.cache_definition.pn}", :ContentType => PIVOT_TABLE_CACHE_DEFINITION_CT) end workbook.comments.each do |comment| if comment.size > 0 c_types << Axlsx::Override.new(:PartName => "/xl/#{comment.pn}", :ContentType => COMMENT_CT) end end if workbook.comments.size > 0 c_types << Axlsx::Default.new(:Extension => "vml", :ContentType => VML_DRAWING_CT) end workbook.worksheets.each do |sheet| c_types << Axlsx::Override.new(:PartName => "/xl/#{sheet.pn}", :ContentType => WORKSHEET_CT) end exts = workbook.images.map { |image| image.extname.downcase } exts.uniq.each do |ext| ct = if ['jpeg', 'jpg'].include?(ext) JPEG_CT elsif ext == 'gif' GIF_CT elsif ext == 'png' PNG_CT end c_types << Axlsx::Default.new(:ContentType => ct, :Extension => ext ) end if use_shared_strings c_types << Axlsx::Override.new(:PartName => "/xl/#{SHARED_STRINGS_PN}", :ContentType => SHARED_STRINGS_CT) end c_types end
ruby
def content_types c_types = base_content_types workbook.drawings.each do |drawing| c_types << Axlsx::Override.new(:PartName => "/xl/#{drawing.pn}", :ContentType => DRAWING_CT) end workbook.charts.each do |chart| c_types << Axlsx::Override.new(:PartName => "/xl/#{chart.pn}", :ContentType => CHART_CT) end workbook.tables.each do |table| c_types << Axlsx::Override.new(:PartName => "/xl/#{table.pn}", :ContentType => TABLE_CT) end workbook.pivot_tables.each do |pivot_table| c_types << Axlsx::Override.new(:PartName => "/xl/#{pivot_table.pn}", :ContentType => PIVOT_TABLE_CT) c_types << Axlsx::Override.new(:PartName => "/xl/#{pivot_table.cache_definition.pn}", :ContentType => PIVOT_TABLE_CACHE_DEFINITION_CT) end workbook.comments.each do |comment| if comment.size > 0 c_types << Axlsx::Override.new(:PartName => "/xl/#{comment.pn}", :ContentType => COMMENT_CT) end end if workbook.comments.size > 0 c_types << Axlsx::Default.new(:Extension => "vml", :ContentType => VML_DRAWING_CT) end workbook.worksheets.each do |sheet| c_types << Axlsx::Override.new(:PartName => "/xl/#{sheet.pn}", :ContentType => WORKSHEET_CT) end exts = workbook.images.map { |image| image.extname.downcase } exts.uniq.each do |ext| ct = if ['jpeg', 'jpg'].include?(ext) JPEG_CT elsif ext == 'gif' GIF_CT elsif ext == 'png' PNG_CT end c_types << Axlsx::Default.new(:ContentType => ct, :Extension => ext ) end if use_shared_strings c_types << Axlsx::Override.new(:PartName => "/xl/#{SHARED_STRINGS_PN}", :ContentType => SHARED_STRINGS_CT) end c_types end
[ "def", "content_types", "c_types", "=", "base_content_types", "workbook", ".", "drawings", ".", "each", "do", "|", "drawing", "|", "c_types", "<<", "Axlsx", "::", "Override", ".", "new", "(", ":PartName", "=>", "\"/xl/#{drawing.pn}\"", ",", ":ContentType", "=>", "DRAWING_CT", ")", "end", "workbook", ".", "charts", ".", "each", "do", "|", "chart", "|", "c_types", "<<", "Axlsx", "::", "Override", ".", "new", "(", ":PartName", "=>", "\"/xl/#{chart.pn}\"", ",", ":ContentType", "=>", "CHART_CT", ")", "end", "workbook", ".", "tables", ".", "each", "do", "|", "table", "|", "c_types", "<<", "Axlsx", "::", "Override", ".", "new", "(", ":PartName", "=>", "\"/xl/#{table.pn}\"", ",", ":ContentType", "=>", "TABLE_CT", ")", "end", "workbook", ".", "pivot_tables", ".", "each", "do", "|", "pivot_table", "|", "c_types", "<<", "Axlsx", "::", "Override", ".", "new", "(", ":PartName", "=>", "\"/xl/#{pivot_table.pn}\"", ",", ":ContentType", "=>", "PIVOT_TABLE_CT", ")", "c_types", "<<", "Axlsx", "::", "Override", ".", "new", "(", ":PartName", "=>", "\"/xl/#{pivot_table.cache_definition.pn}\"", ",", ":ContentType", "=>", "PIVOT_TABLE_CACHE_DEFINITION_CT", ")", "end", "workbook", ".", "comments", ".", "each", "do", "|", "comment", "|", "if", "comment", ".", "size", ">", "0", "c_types", "<<", "Axlsx", "::", "Override", ".", "new", "(", ":PartName", "=>", "\"/xl/#{comment.pn}\"", ",", ":ContentType", "=>", "COMMENT_CT", ")", "end", "end", "if", "workbook", ".", "comments", ".", "size", ">", "0", "c_types", "<<", "Axlsx", "::", "Default", ".", "new", "(", ":Extension", "=>", "\"vml\"", ",", ":ContentType", "=>", "VML_DRAWING_CT", ")", "end", "workbook", ".", "worksheets", ".", "each", "do", "|", "sheet", "|", "c_types", "<<", "Axlsx", "::", "Override", ".", "new", "(", ":PartName", "=>", "\"/xl/#{sheet.pn}\"", ",", ":ContentType", "=>", "WORKSHEET_CT", ")", "end", "exts", "=", "workbook", ".", "images", ".", "map", "{", "|", "image", "|", "image", ".", "extname", ".", "downcase", "}", "exts", ".", "uniq", ".", "each", "do", "|", "ext", "|", "ct", "=", "if", "[", "'jpeg'", ",", "'jpg'", "]", ".", "include?", "(", "ext", ")", "JPEG_CT", "elsif", "ext", "==", "'gif'", "GIF_CT", "elsif", "ext", "==", "'png'", "PNG_CT", "end", "c_types", "<<", "Axlsx", "::", "Default", ".", "new", "(", ":ContentType", "=>", "ct", ",", ":Extension", "=>", "ext", ")", "end", "if", "use_shared_strings", "c_types", "<<", "Axlsx", "::", "Override", ".", "new", "(", ":PartName", "=>", "\"/xl/#{SHARED_STRINGS_PN}\"", ",", ":ContentType", "=>", "SHARED_STRINGS_CT", ")", "end", "c_types", "end" ]
Appends override objects for drawings, charts, and sheets as they exist in your workbook to the default content types. @return [ContentType] @private
[ "Appends", "override", "objects", "for", "drawings", "charts", "and", "sheets", "as", "they", "exist", "in", "your", "workbook", "to", "the", "default", "content", "types", "." ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/package.rb#L269-L324
11,920
randym/axlsx
lib/axlsx/package.rb
Axlsx.Package.base_content_types
def base_content_types c_types = ContentType.new() c_types << Default.new(:ContentType => RELS_CT, :Extension => RELS_EX) c_types << Default.new(:Extension => XML_EX, :ContentType => XML_CT) c_types << Override.new(:PartName => "/#{APP_PN}", :ContentType => APP_CT) c_types << Override.new(:PartName => "/#{CORE_PN}", :ContentType => CORE_CT) c_types << Override.new(:PartName => "/xl/#{STYLES_PN}", :ContentType => STYLES_CT) c_types << Axlsx::Override.new(:PartName => "/#{WORKBOOK_PN}", :ContentType => WORKBOOK_CT) c_types.lock c_types end
ruby
def base_content_types c_types = ContentType.new() c_types << Default.new(:ContentType => RELS_CT, :Extension => RELS_EX) c_types << Default.new(:Extension => XML_EX, :ContentType => XML_CT) c_types << Override.new(:PartName => "/#{APP_PN}", :ContentType => APP_CT) c_types << Override.new(:PartName => "/#{CORE_PN}", :ContentType => CORE_CT) c_types << Override.new(:PartName => "/xl/#{STYLES_PN}", :ContentType => STYLES_CT) c_types << Axlsx::Override.new(:PartName => "/#{WORKBOOK_PN}", :ContentType => WORKBOOK_CT) c_types.lock c_types end
[ "def", "base_content_types", "c_types", "=", "ContentType", ".", "new", "(", ")", "c_types", "<<", "Default", ".", "new", "(", ":ContentType", "=>", "RELS_CT", ",", ":Extension", "=>", "RELS_EX", ")", "c_types", "<<", "Default", ".", "new", "(", ":Extension", "=>", "XML_EX", ",", ":ContentType", "=>", "XML_CT", ")", "c_types", "<<", "Override", ".", "new", "(", ":PartName", "=>", "\"/#{APP_PN}\"", ",", ":ContentType", "=>", "APP_CT", ")", "c_types", "<<", "Override", ".", "new", "(", ":PartName", "=>", "\"/#{CORE_PN}\"", ",", ":ContentType", "=>", "CORE_CT", ")", "c_types", "<<", "Override", ".", "new", "(", ":PartName", "=>", "\"/xl/#{STYLES_PN}\"", ",", ":ContentType", "=>", "STYLES_CT", ")", "c_types", "<<", "Axlsx", "::", "Override", ".", "new", "(", ":PartName", "=>", "\"/#{WORKBOOK_PN}\"", ",", ":ContentType", "=>", "WORKBOOK_CT", ")", "c_types", ".", "lock", "c_types", "end" ]
Creates the minimum content types for generating a valid xlsx document. @return [ContentType] @private
[ "Creates", "the", "minimum", "content", "types", "for", "generating", "a", "valid", "xlsx", "document", "." ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/package.rb#L329-L339
11,921
randym/axlsx
lib/axlsx/package.rb
Axlsx.Package.relationships
def relationships rels = Axlsx::Relationships.new rels << Relationship.new(self, WORKBOOK_R, WORKBOOK_PN) rels << Relationship.new(self, CORE_R, CORE_PN) rels << Relationship.new(self, APP_R, APP_PN) rels.lock rels end
ruby
def relationships rels = Axlsx::Relationships.new rels << Relationship.new(self, WORKBOOK_R, WORKBOOK_PN) rels << Relationship.new(self, CORE_R, CORE_PN) rels << Relationship.new(self, APP_R, APP_PN) rels.lock rels end
[ "def", "relationships", "rels", "=", "Axlsx", "::", "Relationships", ".", "new", "rels", "<<", "Relationship", ".", "new", "(", "self", ",", "WORKBOOK_R", ",", "WORKBOOK_PN", ")", "rels", "<<", "Relationship", ".", "new", "(", "self", ",", "CORE_R", ",", "CORE_PN", ")", "rels", "<<", "Relationship", ".", "new", "(", "self", ",", "APP_R", ",", "APP_PN", ")", "rels", ".", "lock", "rels", "end" ]
Creates the relationships required for a valid xlsx document @return [Relationships] @private
[ "Creates", "the", "relationships", "required", "for", "a", "valid", "xlsx", "document" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/package.rb#L344-L351
11,922
randym/axlsx
lib/axlsx/drawing/pic.rb
Axlsx.Pic.hyperlink=
def hyperlink=(v, options={}) options[:href] = v if hyperlink.is_a?(Hyperlink) options.each do |o| hyperlink.send("#{o[0]}=", o[1]) if hyperlink.respond_to? "#{o[0]}=" end else @hyperlink = Hyperlink.new(self, options) end hyperlink end
ruby
def hyperlink=(v, options={}) options[:href] = v if hyperlink.is_a?(Hyperlink) options.each do |o| hyperlink.send("#{o[0]}=", o[1]) if hyperlink.respond_to? "#{o[0]}=" end else @hyperlink = Hyperlink.new(self, options) end hyperlink end
[ "def", "hyperlink", "=", "(", "v", ",", "options", "=", "{", "}", ")", "options", "[", ":href", "]", "=", "v", "if", "hyperlink", ".", "is_a?", "(", "Hyperlink", ")", "options", ".", "each", "do", "|", "o", "|", "hyperlink", ".", "send", "(", "\"#{o[0]}=\"", ",", "o", "[", "1", "]", ")", "if", "hyperlink", ".", "respond_to?", "\"#{o[0]}=\"", "end", "else", "@hyperlink", "=", "Hyperlink", ".", "new", "(", "self", ",", "options", ")", "end", "hyperlink", "end" ]
sets or updates a hyperlink for this image. @param [String] v The href value for the hyper link @option options @see Hyperlink#initialize All options available to the Hyperlink class apply - however href will be overridden with the v parameter value.
[ "sets", "or", "updates", "a", "hyperlink", "for", "this", "image", "." ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/drawing/pic.rb#L62-L72
11,923
randym/axlsx
lib/axlsx/drawing/pic.rb
Axlsx.Pic.end_at
def end_at(x, y=nil) use_two_cell_anchor unless @anchor.is_a?(TwoCellAnchor) @anchor.end_at x, y @anchor.to end
ruby
def end_at(x, y=nil) use_two_cell_anchor unless @anchor.is_a?(TwoCellAnchor) @anchor.end_at x, y @anchor.to end
[ "def", "end_at", "(", "x", ",", "y", "=", "nil", ")", "use_two_cell_anchor", "unless", "@anchor", ".", "is_a?", "(", "TwoCellAnchor", ")", "@anchor", ".", "end_at", "x", ",", "y", "@anchor", ".", "to", "end" ]
noop if not using a two cell anchor @param [Integer] x The column @param [Integer] y The row @return [Marker]
[ "noop", "if", "not", "using", "a", "two", "cell", "anchor" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/drawing/pic.rb#L159-L163
11,924
randym/axlsx
lib/axlsx/drawing/pic.rb
Axlsx.Pic.use_one_cell_anchor
def use_one_cell_anchor return if @anchor.is_a?(OneCellAnchor) new_anchor = OneCellAnchor.new(@anchor.drawing, :start_at => [@anchor.from.col, @anchor.from.row]) swap_anchor(new_anchor) end
ruby
def use_one_cell_anchor return if @anchor.is_a?(OneCellAnchor) new_anchor = OneCellAnchor.new(@anchor.drawing, :start_at => [@anchor.from.col, @anchor.from.row]) swap_anchor(new_anchor) end
[ "def", "use_one_cell_anchor", "return", "if", "@anchor", ".", "is_a?", "(", "OneCellAnchor", ")", "new_anchor", "=", "OneCellAnchor", ".", "new", "(", "@anchor", ".", "drawing", ",", ":start_at", "=>", "[", "@anchor", ".", "from", ".", "col", ",", "@anchor", ".", "from", ".", "row", "]", ")", "swap_anchor", "(", "new_anchor", ")", "end" ]
Changes the anchor to a one cell anchor.
[ "Changes", "the", "anchor", "to", "a", "one", "cell", "anchor", "." ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/drawing/pic.rb#L190-L194
11,925
randym/axlsx
lib/axlsx/drawing/pic.rb
Axlsx.Pic.use_two_cell_anchor
def use_two_cell_anchor return if @anchor.is_a?(TwoCellAnchor) new_anchor = TwoCellAnchor.new(@anchor.drawing, :start_at => [@anchor.from.col, @anchor.from.row]) swap_anchor(new_anchor) end
ruby
def use_two_cell_anchor return if @anchor.is_a?(TwoCellAnchor) new_anchor = TwoCellAnchor.new(@anchor.drawing, :start_at => [@anchor.from.col, @anchor.from.row]) swap_anchor(new_anchor) end
[ "def", "use_two_cell_anchor", "return", "if", "@anchor", ".", "is_a?", "(", "TwoCellAnchor", ")", "new_anchor", "=", "TwoCellAnchor", ".", "new", "(", "@anchor", ".", "drawing", ",", ":start_at", "=>", "[", "@anchor", ".", "from", ".", "col", ",", "@anchor", ".", "from", ".", "row", "]", ")", "swap_anchor", "(", "new_anchor", ")", "end" ]
changes the anchor type to a two cell anchor
[ "changes", "the", "anchor", "type", "to", "a", "two", "cell", "anchor" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/drawing/pic.rb#L197-L201
11,926
randym/axlsx
lib/axlsx/drawing/pic.rb
Axlsx.Pic.swap_anchor
def swap_anchor(new_anchor) new_anchor.drawing.anchors.delete(new_anchor) @anchor.drawing.anchors[@anchor.drawing.anchors.index(@anchor)] = new_anchor new_anchor.instance_variable_set "@object", @anchor.object @anchor = new_anchor end
ruby
def swap_anchor(new_anchor) new_anchor.drawing.anchors.delete(new_anchor) @anchor.drawing.anchors[@anchor.drawing.anchors.index(@anchor)] = new_anchor new_anchor.instance_variable_set "@object", @anchor.object @anchor = new_anchor end
[ "def", "swap_anchor", "(", "new_anchor", ")", "new_anchor", ".", "drawing", ".", "anchors", ".", "delete", "(", "new_anchor", ")", "@anchor", ".", "drawing", ".", "anchors", "[", "@anchor", ".", "drawing", ".", "anchors", ".", "index", "(", "@anchor", ")", "]", "=", "new_anchor", "new_anchor", ".", "instance_variable_set", "\"@object\"", ",", "@anchor", ".", "object", "@anchor", "=", "new_anchor", "end" ]
refactoring of swapping code, law of demeter be damned!
[ "refactoring", "of", "swapping", "code", "law", "of", "demeter", "be", "damned!" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/drawing/pic.rb#L204-L209
11,927
randym/axlsx
lib/axlsx/workbook/worksheet/color_scale.rb
Axlsx.ColorScale.add
def add(options={}) value_objects << Cfvo.new(:type => options[:type] || :min, :val => options[:val] || 0) colors << Color.new(:rgb => options[:color] || "FF000000") {:cfvo => value_objects.last, :color => colors.last} end
ruby
def add(options={}) value_objects << Cfvo.new(:type => options[:type] || :min, :val => options[:val] || 0) colors << Color.new(:rgb => options[:color] || "FF000000") {:cfvo => value_objects.last, :color => colors.last} end
[ "def", "add", "(", "options", "=", "{", "}", ")", "value_objects", "<<", "Cfvo", ".", "new", "(", ":type", "=>", "options", "[", ":type", "]", "||", ":min", ",", ":val", "=>", "options", "[", ":val", "]", "||", "0", ")", "colors", "<<", "Color", ".", "new", "(", ":rgb", "=>", "options", "[", ":color", "]", "||", "\"FF000000\"", ")", "{", ":cfvo", "=>", "value_objects", ".", "last", ",", ":color", "=>", "colors", ".", "last", "}", "end" ]
creates a new ColorScale object. @see Cfvo @see Color @example color_scale = Axlsx::ColorScale.new({:type => :num, :val => 0.55, :color => 'fff7696c'}) adds a new cfvo / color pair to the color scale and returns a hash containing a reference to the newly created cfvo and color objects so you can alter the default properties. @return [Hash] a hash with :cfvo and :color keys referencing the newly added objects. @param [Hash] options options for the new cfvo and color objects @option [Symbol] type The type of cfvo you to add @option [Any] val The value of the cfvo to add @option [String] The rgb color for the cfvo
[ "creates", "a", "new", "ColorScale", "object", "." ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/color_scale.rb#L70-L74
11,928
randym/axlsx
lib/axlsx/workbook/worksheet/color_scale.rb
Axlsx.ColorScale.to_xml_string
def to_xml_string(str = '') str << '<colorScale>' value_objects.to_xml_string(str) colors.each { |color| color.to_xml_string(str) } str << '</colorScale>' end
ruby
def to_xml_string(str = '') str << '<colorScale>' value_objects.to_xml_string(str) colors.each { |color| color.to_xml_string(str) } str << '</colorScale>' end
[ "def", "to_xml_string", "(", "str", "=", "''", ")", "str", "<<", "'<colorScale>'", "value_objects", ".", "to_xml_string", "(", "str", ")", "colors", ".", "each", "{", "|", "color", "|", "color", ".", "to_xml_string", "(", "str", ")", "}", "str", "<<", "'</colorScale>'", "end" ]
Serialize this color_scale object data to an xml string @param [String] str @return [String]
[ "Serialize", "this", "color_scale", "object", "data", "to", "an", "xml", "string" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/color_scale.rb#L88-L93
11,929
randym/axlsx
lib/axlsx/workbook/worksheet/color_scale.rb
Axlsx.ColorScale.initialize_default_cfvos
def initialize_default_cfvos(user_cfvos) defaults = self.class.default_cfvos user_cfvos.each_with_index do |cfvo, index| if index < defaults.size cfvo = defaults[index].merge(cfvo) end add cfvo end while colors.size < defaults.size add defaults[colors.size - 1] end end
ruby
def initialize_default_cfvos(user_cfvos) defaults = self.class.default_cfvos user_cfvos.each_with_index do |cfvo, index| if index < defaults.size cfvo = defaults[index].merge(cfvo) end add cfvo end while colors.size < defaults.size add defaults[colors.size - 1] end end
[ "def", "initialize_default_cfvos", "(", "user_cfvos", ")", "defaults", "=", "self", ".", "class", ".", "default_cfvos", "user_cfvos", ".", "each_with_index", "do", "|", "cfvo", ",", "index", "|", "if", "index", "<", "defaults", ".", "size", "cfvo", "=", "defaults", "[", "index", "]", ".", "merge", "(", "cfvo", ")", "end", "add", "cfvo", "end", "while", "colors", ".", "size", "<", "defaults", ".", "size", "add", "defaults", "[", "colors", ".", "size", "-", "1", "]", "end", "end" ]
There has got to be cleaner way of merging these arrays.
[ "There", "has", "got", "to", "be", "cleaner", "way", "of", "merging", "these", "arrays", "." ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/color_scale.rb#L97-L108
11,930
randym/axlsx
lib/axlsx/drawing/axes.rb
Axlsx.Axes.add_axis
def add_axis(name, axis_class) axis = axis_class.new set_cross_axis(axis) axes << [name, axis] end
ruby
def add_axis(name, axis_class) axis = axis_class.new set_cross_axis(axis) axes << [name, axis] end
[ "def", "add_axis", "(", "name", ",", "axis_class", ")", "axis", "=", "axis_class", ".", "new", "set_cross_axis", "(", "axis", ")", "axes", "<<", "[", "name", ",", "axis", "]", "end" ]
Adds an axis to the collection @param [Symbol] name The name of the axis @param [Axis] axis_class The axis class to generate
[ "Adds", "an", "axis", "to", "the", "collection" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/drawing/axes.rb#L44-L48
11,931
randym/axlsx
lib/axlsx/workbook/shared_strings_table.rb
Axlsx.SharedStringsTable.to_xml_string
def to_xml_string(str='') Axlsx::sanitize(@shared_xml_string) str << ('<?xml version="1.0" encoding="UTF-8"?><sst xmlns="' << XML_NS << '"') str << (' count="' << @count.to_s << '" uniqueCount="' << unique_count.to_s << '"') str << (' xml:space="' << xml_space.to_s << '">' << @shared_xml_string << '</sst>') end
ruby
def to_xml_string(str='') Axlsx::sanitize(@shared_xml_string) str << ('<?xml version="1.0" encoding="UTF-8"?><sst xmlns="' << XML_NS << '"') str << (' count="' << @count.to_s << '" uniqueCount="' << unique_count.to_s << '"') str << (' xml:space="' << xml_space.to_s << '">' << @shared_xml_string << '</sst>') end
[ "def", "to_xml_string", "(", "str", "=", "''", ")", "Axlsx", "::", "sanitize", "(", "@shared_xml_string", ")", "str", "<<", "(", "'<?xml version=\"1.0\" encoding=\"UTF-8\"?><sst xmlns=\"'", "<<", "XML_NS", "<<", "'\"'", ")", "str", "<<", "(", "' count=\"'", "<<", "@count", ".", "to_s", "<<", "'\" uniqueCount=\"'", "<<", "unique_count", ".", "to_s", "<<", "'\"'", ")", "str", "<<", "(", "' xml:space=\"'", "<<", "xml_space", ".", "to_s", "<<", "'\">'", "<<", "@shared_xml_string", "<<", "'</sst>'", ")", "end" ]
Creates a new Shared Strings Table agains an array of cells @param [Array] cells This is an array of all of the cells in the workbook @param [Symbol] xml_space The xml:space behavior for the shared string table. Serializes the object @param [String] str @return [String]
[ "Creates", "a", "new", "Shared", "Strings", "Table", "agains", "an", "array", "of", "cells" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/shared_strings_table.rb#L49-L54
11,932
randym/axlsx
lib/axlsx/workbook/shared_strings_table.rb
Axlsx.SharedStringsTable.resolve
def resolve(cells) cells.each do |cell| cell_hash = cell.value if index = @unique_cells[cell_hash] cell.send :ssti=, index else cell.send :ssti=, @index @shared_xml_string << '<si>' << CellSerializer.run_xml_string(cell) << '</si>' @unique_cells[cell_hash] = @index @index += 1 end end end
ruby
def resolve(cells) cells.each do |cell| cell_hash = cell.value if index = @unique_cells[cell_hash] cell.send :ssti=, index else cell.send :ssti=, @index @shared_xml_string << '<si>' << CellSerializer.run_xml_string(cell) << '</si>' @unique_cells[cell_hash] = @index @index += 1 end end end
[ "def", "resolve", "(", "cells", ")", "cells", ".", "each", "do", "|", "cell", "|", "cell_hash", "=", "cell", ".", "value", "if", "index", "=", "@unique_cells", "[", "cell_hash", "]", "cell", ".", "send", ":ssti=", ",", "index", "else", "cell", ".", "send", ":ssti=", ",", "@index", "@shared_xml_string", "<<", "'<si>'", "<<", "CellSerializer", ".", "run_xml_string", "(", "cell", ")", "<<", "'</si>'", "@unique_cells", "[", "cell_hash", "]", "=", "@index", "@index", "+=", "1", "end", "end", "end" ]
Interate over all of the cells in the array. if our unique cells array does not contain a sharable cell, add the cell to our unique cells array and set the ssti attribute on the index of this cell in the shared strings table if a sharable cell already exists in our unique_cells array, set the ssti attribute of the cell and move on. @return [Array] unique cells
[ "Interate", "over", "all", "of", "the", "cells", "in", "the", "array", ".", "if", "our", "unique", "cells", "array", "does", "not", "contain", "a", "sharable", "cell", "add", "the", "cell", "to", "our", "unique", "cells", "array", "and", "set", "the", "ssti", "attribute", "on", "the", "index", "of", "this", "cell", "in", "the", "shared", "strings", "table", "if", "a", "sharable", "cell", "already", "exists", "in", "our", "unique_cells", "array", "set", "the", "ssti", "attribute", "of", "the", "cell", "and", "move", "on", "." ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/shared_strings_table.rb#L63-L75
11,933
randym/axlsx
lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb
Axlsx.WorksheetHyperlinks.to_xml_string
def to_xml_string(str='') return if empty? str << '<hyperlinks>' each { |hyperlink| hyperlink.to_xml_string(str) } str << '</hyperlinks>' end
ruby
def to_xml_string(str='') return if empty? str << '<hyperlinks>' each { |hyperlink| hyperlink.to_xml_string(str) } str << '</hyperlinks>' end
[ "def", "to_xml_string", "(", "str", "=", "''", ")", "return", "if", "empty?", "str", "<<", "'<hyperlinks>'", "each", "{", "|", "hyperlink", "|", "hyperlink", ".", "to_xml_string", "(", "str", ")", "}", "str", "<<", "'</hyperlinks>'", "end" ]
seralize the collection of hyperlinks @return [String]
[ "seralize", "the", "collection", "of", "hyperlinks" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb#L31-L36
11,934
randym/axlsx
lib/axlsx/workbook/workbook.rb
Axlsx.Workbook.sheet_by_name
def sheet_by_name(name) index = @worksheets.index { |sheet| sheet.name == name } @worksheets[index] if index end
ruby
def sheet_by_name(name) index = @worksheets.index { |sheet| sheet.name == name } @worksheets[index] if index end
[ "def", "sheet_by_name", "(", "name", ")", "index", "=", "@worksheets", ".", "index", "{", "|", "sheet", "|", "sheet", ".", "name", "==", "name", "}", "@worksheets", "[", "index", "]", "if", "index", "end" ]
A quick helper to retrive a worksheet by name @param [String] name The name of the sheet you are looking for @return [Worksheet] The sheet found, or nil
[ "A", "quick", "helper", "to", "retrive", "a", "worksheet", "by", "name" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/workbook.rb#L195-L198
11,935
randym/axlsx
lib/axlsx/workbook/workbook.rb
Axlsx.Workbook.insert_worksheet
def insert_worksheet(index=0, options={}) worksheet = Worksheet.new(self, options) @worksheets.delete_at(@worksheets.size - 1) @worksheets.insert(index, worksheet) yield worksheet if block_given? worksheet end
ruby
def insert_worksheet(index=0, options={}) worksheet = Worksheet.new(self, options) @worksheets.delete_at(@worksheets.size - 1) @worksheets.insert(index, worksheet) yield worksheet if block_given? worksheet end
[ "def", "insert_worksheet", "(", "index", "=", "0", ",", "options", "=", "{", "}", ")", "worksheet", "=", "Worksheet", ".", "new", "(", "self", ",", "options", ")", "@worksheets", ".", "delete_at", "(", "@worksheets", ".", "size", "-", "1", ")", "@worksheets", ".", "insert", "(", "index", ",", "worksheet", ")", "yield", "worksheet", "if", "block_given?", "worksheet", "end" ]
inserts a worksheet into this workbook at the position specified. It the index specified is out of range, the worksheet will be added to the end of the worksheets collection @return [Worksheet] @param index The zero based position to insert the newly created worksheet @param [Hash] options Options to pass into the worksheed during initialization. @option options [String] name The name of the worksheet @option options [Hash] page_margins The page margins for the worksheet
[ "inserts", "a", "worksheet", "into", "this", "workbook", "at", "the", "position", "specified", ".", "It", "the", "index", "specified", "is", "out", "of", "range", "the", "worksheet", "will", "be", "added", "to", "the", "end", "of", "the", "worksheets", "collection" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/workbook.rb#L263-L269
11,936
randym/axlsx
lib/axlsx/workbook/workbook.rb
Axlsx.Workbook.relationships
def relationships r = Relationships.new @worksheets.each do |sheet| r << Relationship.new(sheet, WORKSHEET_R, WORKSHEET_PN % (r.size+1)) end pivot_tables.each_with_index do |pivot_table, index| r << Relationship.new(pivot_table.cache_definition, PIVOT_TABLE_CACHE_DEFINITION_R, PIVOT_TABLE_CACHE_DEFINITION_PN % (index+1)) end r << Relationship.new(self, STYLES_R, STYLES_PN) if use_shared_strings r << Relationship.new(self, SHARED_STRINGS_R, SHARED_STRINGS_PN) end r end
ruby
def relationships r = Relationships.new @worksheets.each do |sheet| r << Relationship.new(sheet, WORKSHEET_R, WORKSHEET_PN % (r.size+1)) end pivot_tables.each_with_index do |pivot_table, index| r << Relationship.new(pivot_table.cache_definition, PIVOT_TABLE_CACHE_DEFINITION_R, PIVOT_TABLE_CACHE_DEFINITION_PN % (index+1)) end r << Relationship.new(self, STYLES_R, STYLES_PN) if use_shared_strings r << Relationship.new(self, SHARED_STRINGS_R, SHARED_STRINGS_PN) end r end
[ "def", "relationships", "r", "=", "Relationships", ".", "new", "@worksheets", ".", "each", "do", "|", "sheet", "|", "r", "<<", "Relationship", ".", "new", "(", "sheet", ",", "WORKSHEET_R", ",", "WORKSHEET_PN", "%", "(", "r", ".", "size", "+", "1", ")", ")", "end", "pivot_tables", ".", "each_with_index", "do", "|", "pivot_table", ",", "index", "|", "r", "<<", "Relationship", ".", "new", "(", "pivot_table", ".", "cache_definition", ",", "PIVOT_TABLE_CACHE_DEFINITION_R", ",", "PIVOT_TABLE_CACHE_DEFINITION_PN", "%", "(", "index", "+", "1", ")", ")", "end", "r", "<<", "Relationship", ".", "new", "(", "self", ",", "STYLES_R", ",", "STYLES_PN", ")", "if", "use_shared_strings", "r", "<<", "Relationship", ".", "new", "(", "self", ",", "SHARED_STRINGS_R", ",", "SHARED_STRINGS_PN", ")", "end", "r", "end" ]
The workbook relationships. This is managed automatically by the workbook @return [Relationships]
[ "The", "workbook", "relationships", ".", "This", "is", "managed", "automatically", "by", "the", "workbook" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/workbook.rb#L301-L314
11,937
randym/axlsx
lib/axlsx/workbook/workbook.rb
Axlsx.Workbook.[]
def [](cell_def) sheet_name = cell_def.split('!')[0] if cell_def.match('!') worksheet = self.worksheets.select { |s| s.name == sheet_name }.first raise ArgumentError, 'Unknown Sheet' unless sheet_name && worksheet.is_a?(Worksheet) worksheet[cell_def.gsub(/.+!/,"")] end
ruby
def [](cell_def) sheet_name = cell_def.split('!')[0] if cell_def.match('!') worksheet = self.worksheets.select { |s| s.name == sheet_name }.first raise ArgumentError, 'Unknown Sheet' unless sheet_name && worksheet.is_a?(Worksheet) worksheet[cell_def.gsub(/.+!/,"")] end
[ "def", "[]", "(", "cell_def", ")", "sheet_name", "=", "cell_def", ".", "split", "(", "'!'", ")", "[", "0", "]", "if", "cell_def", ".", "match", "(", "'!'", ")", "worksheet", "=", "self", ".", "worksheets", ".", "select", "{", "|", "s", "|", "s", ".", "name", "==", "sheet_name", "}", ".", "first", "raise", "ArgumentError", ",", "'Unknown Sheet'", "unless", "sheet_name", "&&", "worksheet", ".", "is_a?", "(", "Worksheet", ")", "worksheet", "[", "cell_def", ".", "gsub", "(", "/", "/", ",", "\"\"", ")", "]", "end" ]
returns a range of cells in a worksheet @param [String] cell_def The excel style reference defining the worksheet and cells. The range must specify the sheet to retrieve the cells from. e.g. range('Sheet1!A1:B2') will return an array of four cells [A1, A2, B1, B2] while range('Sheet1!A1') will return a single Cell. @return [Cell, Array]
[ "returns", "a", "range", "of", "cells", "in", "a", "worksheet" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/workbook.rb#L344-L349
11,938
randym/axlsx
lib/axlsx/workbook/workbook.rb
Axlsx.Workbook.to_xml_string
def to_xml_string(str='') add_worksheet(name: 'Sheet1') unless worksheets.size > 0 str << '<?xml version="1.0" encoding="UTF-8"?>' str << ('<workbook xmlns="' << XML_NS << '" xmlns:r="' << XML_NS_R << '">') str << ('<workbookPr date1904="' << @@date1904.to_s << '"/>') views.to_xml_string(str) str << '<sheets>' if is_reversed worksheets.reverse_each { |sheet| sheet.to_sheet_node_xml_string(str) } else worksheets.each { |sheet| sheet.to_sheet_node_xml_string(str) } end str << '</sheets>' defined_names.to_xml_string(str) unless pivot_tables.empty? str << '<pivotCaches>' pivot_tables.each do |pivot_table| str << ('<pivotCache cacheId="' << pivot_table.cache_definition.cache_id.to_s << '" r:id="' << pivot_table.cache_definition.rId << '"/>') end str << '</pivotCaches>' end str << '</workbook>' end
ruby
def to_xml_string(str='') add_worksheet(name: 'Sheet1') unless worksheets.size > 0 str << '<?xml version="1.0" encoding="UTF-8"?>' str << ('<workbook xmlns="' << XML_NS << '" xmlns:r="' << XML_NS_R << '">') str << ('<workbookPr date1904="' << @@date1904.to_s << '"/>') views.to_xml_string(str) str << '<sheets>' if is_reversed worksheets.reverse_each { |sheet| sheet.to_sheet_node_xml_string(str) } else worksheets.each { |sheet| sheet.to_sheet_node_xml_string(str) } end str << '</sheets>' defined_names.to_xml_string(str) unless pivot_tables.empty? str << '<pivotCaches>' pivot_tables.each do |pivot_table| str << ('<pivotCache cacheId="' << pivot_table.cache_definition.cache_id.to_s << '" r:id="' << pivot_table.cache_definition.rId << '"/>') end str << '</pivotCaches>' end str << '</workbook>' end
[ "def", "to_xml_string", "(", "str", "=", "''", ")", "add_worksheet", "(", "name", ":", "'Sheet1'", ")", "unless", "worksheets", ".", "size", ">", "0", "str", "<<", "'<?xml version=\"1.0\" encoding=\"UTF-8\"?>'", "str", "<<", "(", "'<workbook xmlns=\"'", "<<", "XML_NS", "<<", "'\" xmlns:r=\"'", "<<", "XML_NS_R", "<<", "'\">'", ")", "str", "<<", "(", "'<workbookPr date1904=\"'", "<<", "@@date1904", ".", "to_s", "<<", "'\"/>'", ")", "views", ".", "to_xml_string", "(", "str", ")", "str", "<<", "'<sheets>'", "if", "is_reversed", "worksheets", ".", "reverse_each", "{", "|", "sheet", "|", "sheet", ".", "to_sheet_node_xml_string", "(", "str", ")", "}", "else", "worksheets", ".", "each", "{", "|", "sheet", "|", "sheet", ".", "to_sheet_node_xml_string", "(", "str", ")", "}", "end", "str", "<<", "'</sheets>'", "defined_names", ".", "to_xml_string", "(", "str", ")", "unless", "pivot_tables", ".", "empty?", "str", "<<", "'<pivotCaches>'", "pivot_tables", ".", "each", "do", "|", "pivot_table", "|", "str", "<<", "(", "'<pivotCache cacheId=\"'", "<<", "pivot_table", ".", "cache_definition", ".", "cache_id", ".", "to_s", "<<", "'\" r:id=\"'", "<<", "pivot_table", ".", "cache_definition", ".", "rId", "<<", "'\"/>'", ")", "end", "str", "<<", "'</pivotCaches>'", "end", "str", "<<", "'</workbook>'", "end" ]
Serialize the workbook @param [String] str @return [String]
[ "Serialize", "the", "workbook" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/workbook.rb#L354-L376
11,939
randym/axlsx
lib/axlsx/workbook/worksheet/page_margins.rb
Axlsx.PageMargins.set
def set(margins) margins.select do |k, v| next unless [:left, :right, :top, :bottom, :header, :footer].include? k send("#{k}=", v) end end
ruby
def set(margins) margins.select do |k, v| next unless [:left, :right, :top, :bottom, :header, :footer].include? k send("#{k}=", v) end end
[ "def", "set", "(", "margins", ")", "margins", ".", "select", "do", "|", "k", ",", "v", "|", "next", "unless", "[", ":left", ",", ":right", ",", ":top", ",", ":bottom", ",", ":header", ",", ":footer", "]", ".", "include?", "k", "send", "(", "\"#{k}=\"", ",", "v", ")", "end", "end" ]
Set some or all margins at once. @param [Hash] margins the margins to set (possible keys are :left, :right, :top, :bottom, :header and :footer).
[ "Set", "some", "or", "all", "margins", "at", "once", "." ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/page_margins.rb#L68-L73
11,940
randym/axlsx
lib/axlsx/drawing/marker.rb
Axlsx.Marker.coord
def coord(col, row=0) coordinates = parse_coord_args(col, row) self.col = coordinates[0] self.row = coordinates[1] end
ruby
def coord(col, row=0) coordinates = parse_coord_args(col, row) self.col = coordinates[0] self.row = coordinates[1] end
[ "def", "coord", "(", "col", ",", "row", "=", "0", ")", "coordinates", "=", "parse_coord_args", "(", "col", ",", "row", ")", "self", ".", "col", "=", "coordinates", "[", "0", "]", "self", ".", "row", "=", "coordinates", "[", "1", "]", "end" ]
shortcut to set the column, row position for this marker @param col the column for the marker, a Cell object or a string reference like "B7" or an Array. @param row the row of the marker. This is ignored if the col parameter is a Cell or String or Array.
[ "shortcut", "to", "set", "the", "column", "row", "position", "for", "this", "marker" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/drawing/marker.rb#L50-L54
11,941
randym/axlsx
lib/axlsx/drawing/marker.rb
Axlsx.Marker.parse_coord_args
def parse_coord_args(x, y=0) if x.is_a?(String) x, y = *Axlsx::name_to_indices(x) end if x.is_a?(Cell) x, y = *x.pos end if x.is_a?(Array) x, y = *x end [x, y] end
ruby
def parse_coord_args(x, y=0) if x.is_a?(String) x, y = *Axlsx::name_to_indices(x) end if x.is_a?(Cell) x, y = *x.pos end if x.is_a?(Array) x, y = *x end [x, y] end
[ "def", "parse_coord_args", "(", "x", ",", "y", "=", "0", ")", "if", "x", ".", "is_a?", "(", "String", ")", "x", ",", "y", "=", "Axlsx", "::", "name_to_indices", "(", "x", ")", "end", "if", "x", ".", "is_a?", "(", "Cell", ")", "x", ",", "y", "=", "x", ".", "pos", "end", "if", "x", ".", "is_a?", "(", "Array", ")", "x", ",", "y", "=", "x", "end", "[", "x", ",", "y", "]", "end" ]
handles multiple inputs for setting the position of a marker @see Chart#start_at
[ "handles", "multiple", "inputs", "for", "setting", "the", "position", "of", "a", "marker" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/drawing/marker.rb#L68-L79
11,942
randym/axlsx
lib/axlsx/workbook/worksheet/comments.rb
Axlsx.Comments.add_comment
def add_comment(options={}) raise ArgumentError, "Comment require an author" unless options[:author] raise ArgumentError, "Comment requires text" unless options[:text] raise ArgumentError, "Comment requires ref" unless options[:ref] self << Comment.new(self, options) yield last if block_given? last end
ruby
def add_comment(options={}) raise ArgumentError, "Comment require an author" unless options[:author] raise ArgumentError, "Comment requires text" unless options[:text] raise ArgumentError, "Comment requires ref" unless options[:ref] self << Comment.new(self, options) yield last if block_given? last end
[ "def", "add_comment", "(", "options", "=", "{", "}", ")", "raise", "ArgumentError", ",", "\"Comment require an author\"", "unless", "options", "[", ":author", "]", "raise", "ArgumentError", ",", "\"Comment requires text\"", "unless", "options", "[", ":text", "]", "raise", "ArgumentError", ",", "\"Comment requires ref\"", "unless", "options", "[", ":ref", "]", "self", "<<", "Comment", ".", "new", "(", "self", ",", "options", ")", "yield", "last", "if", "block_given?", "last", "end" ]
Creates a new Comments object @param [Worksheet] worksheet The sheet that these comments belong to. Adds a new comment to the worksheet that owns these comments. @note the author, text and ref options are required @option options [String] author The name of the author for this comment @option options [String] text The text for this comment @option options [Stirng|Cell] ref The cell that this comment is attached to.
[ "Creates", "a", "new", "Comments", "object" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/comments.rb#L41-L48
11,943
randym/axlsx
lib/axlsx/workbook/worksheet/rich_text_run.rb
Axlsx.RichTextRun.autowidth
def autowidth(widtharray) return if value.nil? if styles.cellXfs[style].alignment && styles.cellXfs[style].alignment.wrap_text first = true value.to_s.split(/\r?\n/, -1).each do |line| if first first = false else widtharray << 0 end widtharray[-1] += string_width(line, font_size) end else widtharray[-1] += string_width(value.to_s, font_size) end widtharray end
ruby
def autowidth(widtharray) return if value.nil? if styles.cellXfs[style].alignment && styles.cellXfs[style].alignment.wrap_text first = true value.to_s.split(/\r?\n/, -1).each do |line| if first first = false else widtharray << 0 end widtharray[-1] += string_width(line, font_size) end else widtharray[-1] += string_width(value.to_s, font_size) end widtharray end
[ "def", "autowidth", "(", "widtharray", ")", "return", "if", "value", ".", "nil?", "if", "styles", ".", "cellXfs", "[", "style", "]", ".", "alignment", "&&", "styles", ".", "cellXfs", "[", "style", "]", ".", "alignment", ".", "wrap_text", "first", "=", "true", "value", ".", "to_s", ".", "split", "(", "/", "\\r", "\\n", "/", ",", "-", "1", ")", ".", "each", "do", "|", "line", "|", "if", "first", "first", "=", "false", "else", "widtharray", "<<", "0", "end", "widtharray", "[", "-", "1", "]", "+=", "string_width", "(", "line", ",", "font_size", ")", "end", "else", "widtharray", "[", "-", "1", "]", "+=", "string_width", "(", "value", ".", "to_s", ",", "font_size", ")", "end", "widtharray", "end" ]
Tries to work out the width of the longest line in the run @param [Array] widtharray this array is populated with the widths of each line in the run. @return [Array]
[ "Tries", "to", "work", "out", "the", "width", "of", "the", "longest", "line", "in", "the", "run" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/rich_text_run.rb#L163-L179
11,944
randym/axlsx
lib/axlsx/workbook/worksheet/rich_text_run.rb
Axlsx.RichTextRun.to_xml_string
def to_xml_string(str = '') valid = RichTextRun::INLINE_STYLES data = Hash[self.instance_values.map{ |k, v| [k.to_sym, v] }] data = data.select { |key, value| valid.include?(key) && !value.nil? } str << '<r><rPr>' data.keys.each do |key| case key when :font_name str << ('<rFont val="' << font_name << '"/>') when :color str << data[key].to_xml_string else str << ('<' << key.to_s << ' val="' << xml_value(data[key]) << '"/>') end end clean_value = Axlsx::trust_input ? @value.to_s : ::CGI.escapeHTML(Axlsx::sanitize(@value.to_s)) str << ('</rPr><t>' << clean_value << '</t></r>') end
ruby
def to_xml_string(str = '') valid = RichTextRun::INLINE_STYLES data = Hash[self.instance_values.map{ |k, v| [k.to_sym, v] }] data = data.select { |key, value| valid.include?(key) && !value.nil? } str << '<r><rPr>' data.keys.each do |key| case key when :font_name str << ('<rFont val="' << font_name << '"/>') when :color str << data[key].to_xml_string else str << ('<' << key.to_s << ' val="' << xml_value(data[key]) << '"/>') end end clean_value = Axlsx::trust_input ? @value.to_s : ::CGI.escapeHTML(Axlsx::sanitize(@value.to_s)) str << ('</rPr><t>' << clean_value << '</t></r>') end
[ "def", "to_xml_string", "(", "str", "=", "''", ")", "valid", "=", "RichTextRun", "::", "INLINE_STYLES", "data", "=", "Hash", "[", "self", ".", "instance_values", ".", "map", "{", "|", "k", ",", "v", "|", "[", "k", ".", "to_sym", ",", "v", "]", "}", "]", "data", "=", "data", ".", "select", "{", "|", "key", ",", "value", "|", "valid", ".", "include?", "(", "key", ")", "&&", "!", "value", ".", "nil?", "}", "str", "<<", "'<r><rPr>'", "data", ".", "keys", ".", "each", "do", "|", "key", "|", "case", "key", "when", ":font_name", "str", "<<", "(", "'<rFont val=\"'", "<<", "font_name", "<<", "'\"/>'", ")", "when", ":color", "str", "<<", "data", "[", "key", "]", ".", "to_xml_string", "else", "str", "<<", "(", "'<'", "<<", "key", ".", "to_s", "<<", "' val=\"'", "<<", "xml_value", "(", "data", "[", "key", "]", ")", "<<", "'\"/>'", ")", "end", "end", "clean_value", "=", "Axlsx", "::", "trust_input", "?", "@value", ".", "to_s", ":", "::", "CGI", ".", "escapeHTML", "(", "Axlsx", "::", "sanitize", "(", "@value", ".", "to_s", ")", ")", "str", "<<", "(", "'</rPr><t>'", "<<", "clean_value", "<<", "'</t></r>'", ")", "end" ]
Serializes the RichTextRun @param [String] str @return [String]
[ "Serializes", "the", "RichTextRun" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/rich_text_run.rb#L191-L209
11,945
randym/axlsx
lib/axlsx/workbook/worksheet/rich_text_run.rb
Axlsx.RichTextRun.string_width
def string_width(string, font_size) font_scale = font_size / 10.0 string.count(Worksheet::THIN_CHARS) * font_scale end
ruby
def string_width(string, font_size) font_scale = font_size / 10.0 string.count(Worksheet::THIN_CHARS) * font_scale end
[ "def", "string_width", "(", "string", ",", "font_size", ")", "font_scale", "=", "font_size", "/", "10.0", "string", ".", "count", "(", "Worksheet", "::", "THIN_CHARS", ")", "*", "font_scale", "end" ]
Returns the width of a string according to the current style This is still not perfect... - scaling is not linear as font sizes increase
[ "Returns", "the", "width", "of", "a", "string", "according", "to", "the", "current", "style", "This", "is", "still", "not", "perfect", "...", "-", "scaling", "is", "not", "linear", "as", "font", "sizes", "increase" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/rich_text_run.rb#L216-L219
11,946
randym/axlsx
lib/axlsx/workbook/worksheet/rich_text_run.rb
Axlsx.RichTextRun.font_size
def font_size return sz if sz font = styles.fonts[styles.cellXfs[style].fontId] || styles.fonts[0] (font.b || (defined?(@b) && @b)) ? (font.sz * 1.5) : font.sz end
ruby
def font_size return sz if sz font = styles.fonts[styles.cellXfs[style].fontId] || styles.fonts[0] (font.b || (defined?(@b) && @b)) ? (font.sz * 1.5) : font.sz end
[ "def", "font_size", "return", "sz", "if", "sz", "font", "=", "styles", ".", "fonts", "[", "styles", ".", "cellXfs", "[", "style", "]", ".", "fontId", "]", "||", "styles", ".", "fonts", "[", "0", "]", "(", "font", ".", "b", "||", "(", "defined?", "(", "@b", ")", "&&", "@b", ")", ")", "?", "(", "font", ".", "sz", "*", "1.5", ")", ":", "font", ".", "sz", "end" ]
we scale the font size if bold style is applied to either the style font or the cell itself. Yes, it is a bit of a hack, but it is much better than using imagemagick and loading metrics for every character.
[ "we", "scale", "the", "font", "size", "if", "bold", "style", "is", "applied", "to", "either", "the", "style", "font", "or", "the", "cell", "itself", ".", "Yes", "it", "is", "a", "bit", "of", "a", "hack", "but", "it", "is", "much", "better", "than", "using", "imagemagick", "and", "loading", "metrics", "for", "every", "character", "." ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/rich_text_run.rb#L224-L228
11,947
randym/axlsx
lib/axlsx/stylesheet/gradient_fill.rb
Axlsx.GradientFill.validate_format_percentage
def validate_format_percentage(name, value) DataTypeValidator.validate name, Float, value, lambda { |arg| arg >= 0.0 && arg <= 1.0} end
ruby
def validate_format_percentage(name, value) DataTypeValidator.validate name, Float, value, lambda { |arg| arg >= 0.0 && arg <= 1.0} end
[ "def", "validate_format_percentage", "(", "name", ",", "value", ")", "DataTypeValidator", ".", "validate", "name", ",", "Float", ",", "value", ",", "lambda", "{", "|", "arg", "|", "arg", ">=", "0.0", "&&", "arg", "<=", "1.0", "}", "end" ]
validates that the value provided is between 0.0 and 1.0
[ "validates", "that", "the", "value", "provided", "is", "between", "0", ".", "0", "and", "1", ".", "0" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/stylesheet/gradient_fill.rb#L88-L90
11,948
randym/axlsx
lib/axlsx/content_type/abstract_content_type.rb
Axlsx.AbstractContentType.to_xml_string
def to_xml_string(node_name = '', str = '') str << "<#{node_name} " str << instance_values.map { |key, value| Axlsx::camel(key) << '="' << value.to_s << '"' }.join(' ') str << '/>' end
ruby
def to_xml_string(node_name = '', str = '') str << "<#{node_name} " str << instance_values.map { |key, value| Axlsx::camel(key) << '="' << value.to_s << '"' }.join(' ') str << '/>' end
[ "def", "to_xml_string", "(", "node_name", "=", "''", ",", "str", "=", "''", ")", "str", "<<", "\"<#{node_name} \"", "str", "<<", "instance_values", ".", "map", "{", "|", "key", ",", "value", "|", "Axlsx", "::", "camel", "(", "key", ")", "<<", "'=\"'", "<<", "value", ".", "to_s", "<<", "'\"'", "}", ".", "join", "(", "' '", ")", "str", "<<", "'/>'", "end" ]
Serialize the contenty type to xml
[ "Serialize", "the", "contenty", "type", "to", "xml" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/content_type/abstract_content_type.rb#L25-L29
11,949
randym/axlsx
lib/axlsx/workbook/worksheet/data_validations.rb
Axlsx.DataValidations.to_xml_string
def to_xml_string(str = "") return if empty? str << "<dataValidations count='#{size}'>" each { |item| item.to_xml_string(str) } str << '</dataValidations>' end
ruby
def to_xml_string(str = "") return if empty? str << "<dataValidations count='#{size}'>" each { |item| item.to_xml_string(str) } str << '</dataValidations>' end
[ "def", "to_xml_string", "(", "str", "=", "\"\"", ")", "return", "if", "empty?", "str", "<<", "\"<dataValidations count='#{size}'>\"", "each", "{", "|", "item", "|", "item", ".", "to_xml_string", "(", "str", ")", "}", "str", "<<", "'</dataValidations>'", "end" ]
serialize the conditional formattings
[ "serialize", "the", "conditional", "formattings" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/data_validations.rb#L18-L23
11,950
randym/axlsx
lib/axlsx/workbook/worksheet/icon_set.rb
Axlsx.IconSet.initialize_value_objects
def initialize_value_objects @value_objects = SimpleTypedList.new Cfvo @value_objects.concat [Cfvo.new(:type => :percent, :val => 0), Cfvo.new(:type => :percent, :val => 33), Cfvo.new(:type => :percent, :val => 67)] @value_objects.lock end
ruby
def initialize_value_objects @value_objects = SimpleTypedList.new Cfvo @value_objects.concat [Cfvo.new(:type => :percent, :val => 0), Cfvo.new(:type => :percent, :val => 33), Cfvo.new(:type => :percent, :val => 67)] @value_objects.lock end
[ "def", "initialize_value_objects", "@value_objects", "=", "SimpleTypedList", ".", "new", "Cfvo", "@value_objects", ".", "concat", "[", "Cfvo", ".", "new", "(", ":type", "=>", ":percent", ",", ":val", "=>", "0", ")", ",", "Cfvo", ".", "new", "(", ":type", "=>", ":percent", ",", ":val", "=>", "33", ")", ",", "Cfvo", ".", "new", "(", ":type", "=>", ":percent", ",", ":val", "=>", "67", ")", "]", "@value_objects", ".", "lock", "end" ]
Initalize the simple typed list of value objects I am keeping this private for now as I am not sure what impact changes to the required two cfvo objects will do.
[ "Initalize", "the", "simple", "typed", "list", "of", "value", "objects", "I", "am", "keeping", "this", "private", "for", "now", "as", "I", "am", "not", "sure", "what", "impact", "changes", "to", "the", "required", "two", "cfvo", "objects", "will", "do", "." ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/icon_set.rb#L75-L79
11,951
randym/axlsx
lib/axlsx/util/storage.rb
Axlsx.Storage.to_s
def to_s data = [@name.concat(Array.new(32-@name.size, 0)), @name_size, @type, @color, @left, @right, @child, @created, @modified, @sector, @size].flatten data.pack(PACKING) end
ruby
def to_s data = [@name.concat(Array.new(32-@name.size, 0)), @name_size, @type, @color, @left, @right, @child, @created, @modified, @sector, @size].flatten data.pack(PACKING) end
[ "def", "to_s", "data", "=", "[", "@name", ".", "concat", "(", "Array", ".", "new", "(", "32", "-", "@name", ".", "size", ",", "0", ")", ")", ",", "@name_size", ",", "@type", ",", "@color", ",", "@left", ",", "@right", ",", "@child", ",", "@created", ",", "@modified", ",", "@sector", ",", "@size", "]", ".", "flatten", "data", ".", "pack", "(", "PACKING", ")", "end" ]
Creates a byte string for this storage @return [String]
[ "Creates", "a", "byte", "string", "for", "this", "storage" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/util/storage.rb#L20-L33
11,952
randym/axlsx
lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb
Axlsx.FilterColumn.col_id=
def col_id=(column_index) column_index = column_index.col if column_index.is_a?(Cell) Axlsx.validate_unsigned_int column_index @col_id = column_index end
ruby
def col_id=(column_index) column_index = column_index.col if column_index.is_a?(Cell) Axlsx.validate_unsigned_int column_index @col_id = column_index end
[ "def", "col_id", "=", "(", "column_index", ")", "column_index", "=", "column_index", ".", "col", "if", "column_index", ".", "is_a?", "(", "Cell", ")", "Axlsx", ".", "validate_unsigned_int", "column_index", "@col_id", "=", "column_index", "end" ]
Sets the col_id attribute for this filter column. @param [Integer | Cell] column_index The zero based index of the column to which this filter applies. When you specify a cell, the column index will be read off the cell @return [Integer]
[ "Sets", "the", "col_id", "attribute", "for", "this", "filter", "column", "." ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb#L58-L62
11,953
randym/axlsx
lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb
Axlsx.FilterColumn.apply
def apply(row, offset) row.hidden = @filter.apply(row.cells[offset+col_id.to_i]) end
ruby
def apply(row, offset) row.hidden = @filter.apply(row.cells[offset+col_id.to_i]) end
[ "def", "apply", "(", "row", ",", "offset", ")", "row", ".", "hidden", "=", "@filter", ".", "apply", "(", "row", ".", "cells", "[", "offset", "+", "col_id", ".", "to_i", "]", ")", "end" ]
Apply the filters for this column @param [Array] row A row from a worksheet that needs to be filtered.
[ "Apply", "the", "filters", "for", "this", "column" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb#L67-L69
11,954
randym/axlsx
lib/axlsx/workbook/worksheet/sheet_data.rb
Axlsx.SheetData.to_xml_string
def to_xml_string(str = '') str << '<sheetData>' worksheet.rows.each_with_index do |row, index| row.to_xml_string(index, str) end str << '</sheetData>' end
ruby
def to_xml_string(str = '') str << '<sheetData>' worksheet.rows.each_with_index do |row, index| row.to_xml_string(index, str) end str << '</sheetData>' end
[ "def", "to_xml_string", "(", "str", "=", "''", ")", "str", "<<", "'<sheetData>'", "worksheet", ".", "rows", ".", "each_with_index", "do", "|", "row", ",", "index", "|", "row", ".", "to_xml_string", "(", "index", ",", "str", ")", "end", "str", "<<", "'</sheetData>'", "end" ]
Serialize the sheet data @param [String] str the string this objects serializaton will be concacted to. @return [String]
[ "Serialize", "the", "sheet", "data" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/sheet_data.rb#L18-L24
11,955
randym/axlsx
lib/axlsx/workbook/defined_names.rb
Axlsx.DefinedNames.to_xml_string
def to_xml_string(str = '') return if empty? str << '<definedNames>' each { |defined_name| defined_name.to_xml_string(str) } str << '</definedNames>' end
ruby
def to_xml_string(str = '') return if empty? str << '<definedNames>' each { |defined_name| defined_name.to_xml_string(str) } str << '</definedNames>' end
[ "def", "to_xml_string", "(", "str", "=", "''", ")", "return", "if", "empty?", "str", "<<", "'<definedNames>'", "each", "{", "|", "defined_name", "|", "defined_name", ".", "to_xml_string", "(", "str", ")", "}", "str", "<<", "'</definedNames>'", "end" ]
creates the DefinedNames object Serialize to xml @param [String] str @return [String]
[ "creates", "the", "DefinedNames", "object", "Serialize", "to", "xml" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/defined_names.rb#L13-L18
11,956
randym/axlsx
lib/axlsx/workbook/worksheet/conditional_formatting.rb
Axlsx.ConditionalFormatting.add_rule
def add_rule(rule) if rule.is_a? Axlsx::ConditionalFormattingRule @rules << rule elsif rule.is_a? Hash @rules << ConditionalFormattingRule.new(rule) end end
ruby
def add_rule(rule) if rule.is_a? Axlsx::ConditionalFormattingRule @rules << rule elsif rule.is_a? Hash @rules << ConditionalFormattingRule.new(rule) end end
[ "def", "add_rule", "(", "rule", ")", "if", "rule", ".", "is_a?", "Axlsx", "::", "ConditionalFormattingRule", "@rules", "<<", "rule", "elsif", "rule", ".", "is_a?", "Hash", "@rules", "<<", "ConditionalFormattingRule", ".", "new", "(", "rule", ")", "end", "end" ]
Add a ConditionalFormattingRule. If a hash of options is passed in create a rule on the fly. @param [ConditionalFormattingRule|Hash] rule A rule to use, or the options necessary to create one. @see ConditionalFormattingRule#initialize
[ "Add", "a", "ConditionalFormattingRule", ".", "If", "a", "hash", "of", "options", "is", "passed", "in", "create", "a", "rule", "on", "the", "fly", "." ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/conditional_formatting.rb#L54-L60
11,957
randym/axlsx
lib/axlsx/workbook/worksheet/conditional_formatting.rb
Axlsx.ConditionalFormatting.to_xml_string
def to_xml_string(str = '') str << ('<conditionalFormatting sqref="' << sqref << '">') str << rules.collect{ |rule| rule.to_xml_string }.join(' ') str << '</conditionalFormatting>' end
ruby
def to_xml_string(str = '') str << ('<conditionalFormatting sqref="' << sqref << '">') str << rules.collect{ |rule| rule.to_xml_string }.join(' ') str << '</conditionalFormatting>' end
[ "def", "to_xml_string", "(", "str", "=", "''", ")", "str", "<<", "(", "'<conditionalFormatting sqref=\"'", "<<", "sqref", "<<", "'\">'", ")", "str", "<<", "rules", ".", "collect", "{", "|", "rule", "|", "rule", ".", "to_xml_string", "}", ".", "join", "(", "' '", ")", "str", "<<", "'</conditionalFormatting>'", "end" ]
Serializes the conditional formatting element @example Conditional Formatting XML looks like: <conditionalFormatting sqref="E3:E9"> <cfRule type="cellIs" dxfId="0" priority="1" operator="greaterThan"> <formula>0.5</formula> </cfRule> </conditionalFormatting> @param [String] str @return [String]
[ "Serializes", "the", "conditional", "formatting", "element" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/conditional_formatting.rb#L76-L80
11,958
randym/axlsx
lib/axlsx/drawing/axis.rb
Axlsx.Axis.label_rotation=
def label_rotation=(v) Axlsx::validate_int(v) adjusted = v.to_i * 60000 Axlsx::validate_angle(adjusted) @label_rotation = adjusted end
ruby
def label_rotation=(v) Axlsx::validate_int(v) adjusted = v.to_i * 60000 Axlsx::validate_angle(adjusted) @label_rotation = adjusted end
[ "def", "label_rotation", "=", "(", "v", ")", "Axlsx", "::", "validate_int", "(", "v", ")", "adjusted", "=", "v", ".", "to_i", "*", "60000", "Axlsx", "::", "validate_angle", "(", "adjusted", ")", "@label_rotation", "=", "adjusted", "end" ]
Specify the degree of label rotation to apply to labels default true
[ "Specify", "the", "degree", "of", "label", "rotation", "to", "apply", "to", "labels", "default", "true" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/drawing/axis.rb#L129-L134
11,959
randym/axlsx
lib/axlsx/drawing/axis.rb
Axlsx.Axis.title=
def title=(v) DataTypeValidator.validate "#{self.class}.title", [String, Cell], v @title ||= Title.new if v.is_a?(String) @title.text = v elsif v.is_a?(Cell) @title.cell = v end end
ruby
def title=(v) DataTypeValidator.validate "#{self.class}.title", [String, Cell], v @title ||= Title.new if v.is_a?(String) @title.text = v elsif v.is_a?(Cell) @title.cell = v end end
[ "def", "title", "=", "(", "v", ")", "DataTypeValidator", ".", "validate", "\"#{self.class}.title\"", ",", "[", "String", ",", "Cell", "]", ",", "v", "@title", "||=", "Title", ".", "new", "if", "v", ".", "is_a?", "(", "String", ")", "@title", ".", "text", "=", "v", "elsif", "v", ".", "is_a?", "(", "Cell", ")", "@title", ".", "cell", "=", "v", "end", "end" ]
The title object for the chart. @param [String, Cell] v @return [Title]
[ "The", "title", "object", "for", "the", "chart", "." ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/drawing/axis.rb#L139-L147
11,960
randym/axlsx
lib/axlsx/workbook/worksheet/worksheet.rb
Axlsx.Worksheet.initialize_page_options
def initialize_page_options(options) @page_margins = PageMargins.new options[:page_margins] if options[:page_margins] @page_setup = PageSetup.new options[:page_setup] if options[:page_setup] @print_options = PrintOptions.new options[:print_options] if options[:print_options] @header_footer = HeaderFooter.new options[:header_footer] if options[:header_footer] @row_breaks = RowBreaks.new @col_breaks = ColBreaks.new end
ruby
def initialize_page_options(options) @page_margins = PageMargins.new options[:page_margins] if options[:page_margins] @page_setup = PageSetup.new options[:page_setup] if options[:page_setup] @print_options = PrintOptions.new options[:print_options] if options[:print_options] @header_footer = HeaderFooter.new options[:header_footer] if options[:header_footer] @row_breaks = RowBreaks.new @col_breaks = ColBreaks.new end
[ "def", "initialize_page_options", "(", "options", ")", "@page_margins", "=", "PageMargins", ".", "new", "options", "[", ":page_margins", "]", "if", "options", "[", ":page_margins", "]", "@page_setup", "=", "PageSetup", ".", "new", "options", "[", ":page_setup", "]", "if", "options", "[", ":page_setup", "]", "@print_options", "=", "PrintOptions", ".", "new", "options", "[", ":print_options", "]", "if", "options", "[", ":print_options", "]", "@header_footer", "=", "HeaderFooter", ".", "new", "options", "[", ":header_footer", "]", "if", "options", "[", ":header_footer", "]", "@row_breaks", "=", "RowBreaks", ".", "new", "@col_breaks", "=", "ColBreaks", ".", "new", "end" ]
Initalizes page margin, setup and print options @param [Hash] options Options passed in from the initializer
[ "Initalizes", "page", "margin", "setup", "and", "print", "options" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/worksheet.rb#L34-L41
11,961
randym/axlsx
lib/axlsx/workbook/worksheet/worksheet.rb
Axlsx.Worksheet.add_conditional_formatting
def add_conditional_formatting(cells, rules) cf = ConditionalFormatting.new( :sqref => cells ) cf.add_rules rules conditional_formattings << cf conditional_formattings end
ruby
def add_conditional_formatting(cells, rules) cf = ConditionalFormatting.new( :sqref => cells ) cf.add_rules rules conditional_formattings << cf conditional_formattings end
[ "def", "add_conditional_formatting", "(", "cells", ",", "rules", ")", "cf", "=", "ConditionalFormatting", ".", "new", "(", ":sqref", "=>", "cells", ")", "cf", ".", "add_rules", "rules", "conditional_formattings", "<<", "cf", "conditional_formattings", "end" ]
Add conditional formatting to this worksheet. @param [String] cells The range to apply the formatting to @param [Array|Hash] rules An array of hashes (or just one) to create Conditional formatting rules from. @example This would format column A whenever it is FALSE. # for a longer example, see examples/example_conditional_formatting.rb (link below) worksheet.add_conditional_formatting( "A1:A1048576", { :type => :cellIs, :operator => :equal, :formula => "FALSE", :dxfId => 1, :priority => 1 } @see ConditionalFormattingRule#initialize @see file:examples/example_conditional_formatting.rb
[ "Add", "conditional", "formatting", "to", "this", "worksheet", "." ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/worksheet.rb#L419-L424
11,962
randym/axlsx
lib/axlsx/workbook/worksheet/worksheet.rb
Axlsx.Worksheet.add_data_validation
def add_data_validation(cells, data_validation) dv = DataValidation.new(data_validation) dv.sqref = cells data_validations << dv end
ruby
def add_data_validation(cells, data_validation) dv = DataValidation.new(data_validation) dv.sqref = cells data_validations << dv end
[ "def", "add_data_validation", "(", "cells", ",", "data_validation", ")", "dv", "=", "DataValidation", ".", "new", "(", "data_validation", ")", "dv", ".", "sqref", "=", "cells", "data_validations", "<<", "dv", "end" ]
Add data validation to this worksheet. @param [String] cells The cells the validation will apply to. @param [hash] data_validation options defining the validation to apply. @see examples/data_validation.rb for an example
[ "Add", "data", "validation", "to", "this", "worksheet", "." ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/worksheet.rb#L431-L435
11,963
randym/axlsx
lib/axlsx/workbook/worksheet/worksheet.rb
Axlsx.Worksheet.add_chart
def add_chart(chart_type, options={}) chart = worksheet_drawing.add_chart(chart_type, options) yield chart if block_given? chart end
ruby
def add_chart(chart_type, options={}) chart = worksheet_drawing.add_chart(chart_type, options) yield chart if block_given? chart end
[ "def", "add_chart", "(", "chart_type", ",", "options", "=", "{", "}", ")", "chart", "=", "worksheet_drawing", ".", "add_chart", "(", "chart_type", ",", "options", ")", "yield", "chart", "if", "block_given?", "chart", "end" ]
Adds a chart to this worksheets drawing. This is the recommended way to create charts for your worksheet. This method wraps the complexity of dealing with ooxml drawing, anchors, markers graphic frames chart objects and all the other dirty details. @param [Class] chart_type @option options [Array] start_at @option options [Array] end_at @option options [Cell, String] title @option options [Boolean] show_legend @option options [Integer] style @note each chart type also specifies additional options @see Chart @see Pie3DChart @see Bar3DChart @see Line3DChart @see README for examples
[ "Adds", "a", "chart", "to", "this", "worksheets", "drawing", ".", "This", "is", "the", "recommended", "way", "to", "create", "charts", "for", "your", "worksheet", ".", "This", "method", "wraps", "the", "complexity", "of", "dealing", "with", "ooxml", "drawing", "anchors", "markers", "graphic", "frames", "chart", "objects", "and", "all", "the", "other", "dirty", "details", "." ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/worksheet.rb#L458-L462
11,964
randym/axlsx
lib/axlsx/workbook/worksheet/worksheet.rb
Axlsx.Worksheet.column_widths
def column_widths(*widths) widths.each_with_index do |value, index| next if value == nil Axlsx::validate_unsigned_numeric(value) unless value == nil find_or_create_column_info(index).width = value end end
ruby
def column_widths(*widths) widths.each_with_index do |value, index| next if value == nil Axlsx::validate_unsigned_numeric(value) unless value == nil find_or_create_column_info(index).width = value end end
[ "def", "column_widths", "(", "*", "widths", ")", "widths", ".", "each_with_index", "do", "|", "value", ",", "index", "|", "next", "if", "value", "==", "nil", "Axlsx", "::", "validate_unsigned_numeric", "(", "value", ")", "unless", "value", "==", "nil", "find_or_create_column_info", "(", "index", ")", ".", "width", "=", "value", "end", "end" ]
This is a helper method that Lets you specify a fixed width for multiple columns in a worksheet in one go. Note that you must call column_widths AFTER adding data, otherwise the width will not be set successfully. Setting a fixed column width to nil will revert the behaviour back to calculating the width for you on the next call to add_row. @example This would set the first and third column widhts but leave the second column in autofit state. ws.column_widths 7.2, nil, 3 @note For updating only a single column it is probably easier to just set the width of the ws.column_info[col_index].width directly @param [Integer|Float|nil] widths
[ "This", "is", "a", "helper", "method", "that", "Lets", "you", "specify", "a", "fixed", "width", "for", "multiple", "columns", "in", "a", "worksheet", "in", "one", "go", ".", "Note", "that", "you", "must", "call", "column_widths", "AFTER", "adding", "data", "otherwise", "the", "width", "will", "not", "be", "set", "successfully", ".", "Setting", "a", "fixed", "column", "width", "to", "nil", "will", "revert", "the", "behaviour", "back", "to", "calculating", "the", "width", "for", "you", "on", "the", "next", "call", "to", "add_row", "." ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/worksheet.rb#L515-L521
11,965
randym/axlsx
lib/axlsx/workbook/worksheet/worksheet.rb
Axlsx.Worksheet.col_style
def col_style(index, style, options={}) offset = options.delete(:row_offset) || 0 cells = @rows[(offset..-1)].map { |row| row[index] }.flatten.compact cells.each { |cell| cell.style = style } end
ruby
def col_style(index, style, options={}) offset = options.delete(:row_offset) || 0 cells = @rows[(offset..-1)].map { |row| row[index] }.flatten.compact cells.each { |cell| cell.style = style } end
[ "def", "col_style", "(", "index", ",", "style", ",", "options", "=", "{", "}", ")", "offset", "=", "options", ".", "delete", "(", ":row_offset", ")", "||", "0", "cells", "=", "@rows", "[", "(", "offset", "..", "-", "1", ")", "]", ".", "map", "{", "|", "row", "|", "row", "[", "index", "]", "}", ".", "flatten", ".", "compact", "cells", ".", "each", "{", "|", "cell", "|", "cell", ".", "style", "=", "style", "}", "end" ]
Set the style for cells in a specific column @param [Integer] index the index of the column @param [Integer] style the cellXfs index @param [Hash] options @option [Integer] :row_offset only cells after this column will be updated. @note You can also specify the style for specific columns in the call to add_row by using an array for the :styles option @see Worksheet#add_row @see README.md for an example
[ "Set", "the", "style", "for", "cells", "in", "a", "specific", "column" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/worksheet.rb#L531-L535
11,966
randym/axlsx
lib/axlsx/workbook/worksheet/worksheet.rb
Axlsx.Worksheet.row_style
def row_style(index, style, options={}) offset = options.delete(:col_offset) || 0 cells = cols[(offset..-1)].map { |column| column[index] }.flatten.compact cells.each { |cell| cell.style = style } end
ruby
def row_style(index, style, options={}) offset = options.delete(:col_offset) || 0 cells = cols[(offset..-1)].map { |column| column[index] }.flatten.compact cells.each { |cell| cell.style = style } end
[ "def", "row_style", "(", "index", ",", "style", ",", "options", "=", "{", "}", ")", "offset", "=", "options", ".", "delete", "(", ":col_offset", ")", "||", "0", "cells", "=", "cols", "[", "(", "offset", "..", "-", "1", ")", "]", ".", "map", "{", "|", "column", "|", "column", "[", "index", "]", "}", ".", "flatten", ".", "compact", "cells", ".", "each", "{", "|", "cell", "|", "cell", ".", "style", "=", "style", "}", "end" ]
Set the style for cells in a specific row @param [Integer] index or range of indexes in the table @param [Integer] style the cellXfs index @param [Hash] options the options used when applying the style @option [Integer] :col_offset only cells after this column will be updated. @note You can also specify the style in the add_row call @see Worksheet#add_row @see README.md for an example
[ "Set", "the", "style", "for", "cells", "in", "a", "specific", "row" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/worksheet.rb#L545-L549
11,967
randym/axlsx
lib/axlsx/workbook/worksheet/worksheet.rb
Axlsx.Worksheet.to_sheet_node_xml_string
def to_sheet_node_xml_string(str='') add_autofilter_defined_name_to_workbook str << '<sheet ' serialized_attributes str str << ('name="' << name << '" ') str << ('r:id="' << rId << '"></sheet>') end
ruby
def to_sheet_node_xml_string(str='') add_autofilter_defined_name_to_workbook str << '<sheet ' serialized_attributes str str << ('name="' << name << '" ') str << ('r:id="' << rId << '"></sheet>') end
[ "def", "to_sheet_node_xml_string", "(", "str", "=", "''", ")", "add_autofilter_defined_name_to_workbook", "str", "<<", "'<sheet '", "serialized_attributes", "str", "str", "<<", "(", "'name=\"'", "<<", "name", "<<", "'\" '", ")", "str", "<<", "(", "'r:id=\"'", "<<", "rId", "<<", "'\"></sheet>'", ")", "end" ]
Returns a sheet node serialization for this sheet in the workbook.
[ "Returns", "a", "sheet", "node", "serialization", "for", "this", "sheet", "in", "the", "workbook", "." ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/worksheet.rb#L552-L558
11,968
randym/axlsx
lib/axlsx/workbook/worksheet/worksheet.rb
Axlsx.Worksheet.to_xml_string
def to_xml_string str='' add_autofilter_defined_name_to_workbook auto_filter.apply if auto_filter.range str << '<?xml version="1.0" encoding="UTF-8"?>' str << worksheet_node serializable_parts.each do |item| item.to_xml_string(str) if item end str << '</worksheet>' end
ruby
def to_xml_string str='' add_autofilter_defined_name_to_workbook auto_filter.apply if auto_filter.range str << '<?xml version="1.0" encoding="UTF-8"?>' str << worksheet_node serializable_parts.each do |item| item.to_xml_string(str) if item end str << '</worksheet>' end
[ "def", "to_xml_string", "str", "=", "''", "add_autofilter_defined_name_to_workbook", "auto_filter", ".", "apply", "if", "auto_filter", ".", "range", "str", "<<", "'<?xml version=\"1.0\" encoding=\"UTF-8\"?>'", "str", "<<", "worksheet_node", "serializable_parts", ".", "each", "do", "|", "item", "|", "item", ".", "to_xml_string", "(", "str", ")", "if", "item", "end", "str", "<<", "'</worksheet>'", "end" ]
Serializes the worksheet object to an xml string This intentionally does not use nokogiri for performance reasons @return [String]
[ "Serializes", "the", "worksheet", "object", "to", "an", "xml", "string", "This", "intentionally", "does", "not", "use", "nokogiri", "for", "performance", "reasons" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/worksheet.rb#L563-L572
11,969
randym/axlsx
lib/axlsx/workbook/worksheet/worksheet.rb
Axlsx.Worksheet.relationships
def relationships r = Relationships.new r + [tables.relationships, worksheet_comments.relationships, hyperlinks.relationships, worksheet_drawing.relationship, pivot_tables.relationships].flatten.compact || [] r end
ruby
def relationships r = Relationships.new r + [tables.relationships, worksheet_comments.relationships, hyperlinks.relationships, worksheet_drawing.relationship, pivot_tables.relationships].flatten.compact || [] r end
[ "def", "relationships", "r", "=", "Relationships", ".", "new", "r", "+", "[", "tables", ".", "relationships", ",", "worksheet_comments", ".", "relationships", ",", "hyperlinks", ".", "relationships", ",", "worksheet_drawing", ".", "relationship", ",", "pivot_tables", ".", "relationships", "]", ".", "flatten", ".", "compact", "||", "[", "]", "r", "end" ]
The worksheet relationships. This is managed automatically by the worksheet @return [Relationships]
[ "The", "worksheet", "relationships", ".", "This", "is", "managed", "automatically", "by", "the", "worksheet" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/worksheet.rb#L576-L584
11,970
randym/axlsx
lib/axlsx/workbook/worksheet/worksheet.rb
Axlsx.Worksheet.name_to_cell
def name_to_cell(name) col_index, row_index = *Axlsx::name_to_indices(name) r = rows[row_index] r[col_index] if r end
ruby
def name_to_cell(name) col_index, row_index = *Axlsx::name_to_indices(name) r = rows[row_index] r[col_index] if r end
[ "def", "name_to_cell", "(", "name", ")", "col_index", ",", "row_index", "=", "Axlsx", "::", "name_to_indices", "(", "name", ")", "r", "=", "rows", "[", "row_index", "]", "r", "[", "col_index", "]", "if", "r", "end" ]
returns the column and row index for a named based cell @param [String] name The cell or cell range to return. "A1" will return the first cell of the first row. @return [Cell]
[ "returns", "the", "column", "and", "row", "index", "for", "a", "named", "based", "cell" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/worksheet.rb#L602-L606
11,971
randym/axlsx
lib/axlsx/workbook/worksheet/worksheet.rb
Axlsx.Worksheet.outline_level_rows
def outline_level_rows(start_index, end_index, level = 1, collapsed = true) outline rows, (start_index..end_index), level, collapsed end
ruby
def outline_level_rows(start_index, end_index, level = 1, collapsed = true) outline rows, (start_index..end_index), level, collapsed end
[ "def", "outline_level_rows", "(", "start_index", ",", "end_index", ",", "level", "=", "1", ",", "collapsed", "=", "true", ")", "outline", "rows", ",", "(", "start_index", "..", "end_index", ")", ",", "level", ",", "collapsed", "end" ]
shortcut level to specify the outline level for a series of rows Oulining is what lets you add collapse and expand to a data set. @param [Integer] start_index The zero based index of the first row of outlining. @param [Integer] end_index The zero based index of the last row to be outlined @param [integer] level The level of outline to apply @param [Integer] collapsed The initial collapsed state of the outline group
[ "shortcut", "level", "to", "specify", "the", "outline", "level", "for", "a", "series", "of", "rows", "Oulining", "is", "what", "lets", "you", "add", "collapse", "and", "expand", "to", "a", "data", "set", "." ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/worksheet.rb#L627-L629
11,972
randym/axlsx
lib/axlsx/workbook/worksheet/worksheet.rb
Axlsx.Worksheet.outline_level_columns
def outline_level_columns(start_index, end_index, level = 1, collapsed = true) outline column_info, (start_index..end_index), level, collapsed end
ruby
def outline_level_columns(start_index, end_index, level = 1, collapsed = true) outline column_info, (start_index..end_index), level, collapsed end
[ "def", "outline_level_columns", "(", "start_index", ",", "end_index", ",", "level", "=", "1", ",", "collapsed", "=", "true", ")", "outline", "column_info", ",", "(", "start_index", "..", "end_index", ")", ",", "level", ",", "collapsed", "end" ]
shortcut level to specify the outline level for a series of columns Oulining is what lets you add collapse and expand to a data set. @param [Integer] start_index The zero based index of the first column of outlining. @param [Integer] end_index The zero based index of the last column to be outlined @param [integer] level The level of outline to apply @param [Integer] collapsed The initial collapsed state of the outline group
[ "shortcut", "level", "to", "specify", "the", "outline", "level", "for", "a", "series", "of", "columns", "Oulining", "is", "what", "lets", "you", "add", "collapse", "and", "expand", "to", "a", "data", "set", "." ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/worksheet.rb#L637-L639
11,973
randym/axlsx
lib/axlsx/workbook/worksheet/row.rb
Axlsx.Row.to_xml_string
def to_xml_string(r_index, str = '') serialized_tag('row', str, :r => r_index + 1) do tmp = '' # time / memory tradeoff, lots of calls to rubyzip costs more # time.. each_with_index { |cell, c_index| cell.to_xml_string(r_index, c_index, tmp) } str << tmp end end
ruby
def to_xml_string(r_index, str = '') serialized_tag('row', str, :r => r_index + 1) do tmp = '' # time / memory tradeoff, lots of calls to rubyzip costs more # time.. each_with_index { |cell, c_index| cell.to_xml_string(r_index, c_index, tmp) } str << tmp end end
[ "def", "to_xml_string", "(", "r_index", ",", "str", "=", "''", ")", "serialized_tag", "(", "'row'", ",", "str", ",", ":r", "=>", "r_index", "+", "1", ")", "do", "tmp", "=", "''", "# time / memory tradeoff, lots of calls to rubyzip costs more", "# time..", "each_with_index", "{", "|", "cell", ",", "c_index", "|", "cell", ".", "to_xml_string", "(", "r_index", ",", "c_index", ",", "tmp", ")", "}", "str", "<<", "tmp", "end", "end" ]
Serializes the row @param [Integer] r_index The row index, 0 based. @param [String] str The string this rows xml will be appended to. @return [String]
[ "Serializes", "the", "row" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/row.rb#L88-L95
11,974
randym/axlsx
lib/axlsx/workbook/worksheet/row.rb
Axlsx.Row.add_cell
def add_cell(value = '', options = {}) c = Cell.new(self, value, options) self << c worksheet.send(:update_column_info, self, []) c end
ruby
def add_cell(value = '', options = {}) c = Cell.new(self, value, options) self << c worksheet.send(:update_column_info, self, []) c end
[ "def", "add_cell", "(", "value", "=", "''", ",", "options", "=", "{", "}", ")", "c", "=", "Cell", ".", "new", "(", "self", ",", "value", ",", "options", ")", "self", "<<", "c", "worksheet", ".", "send", "(", ":update_column_info", ",", "self", ",", "[", "]", ")", "c", "end" ]
Adds a single cell to the row based on the data provided and updates the worksheet's autofit data. @return [Cell]
[ "Adds", "a", "single", "cell", "to", "the", "row", "based", "on", "the", "data", "provided", "and", "updates", "the", "worksheet", "s", "autofit", "data", "." ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/row.rb#L99-L104
11,975
randym/axlsx
lib/axlsx/workbook/worksheet/row.rb
Axlsx.Row.color=
def color=(color) each_with_index do | cell, index | cell.color = color.is_a?(Array) ? color[index] : color end end
ruby
def color=(color) each_with_index do | cell, index | cell.color = color.is_a?(Array) ? color[index] : color end end
[ "def", "color", "=", "(", "color", ")", "each_with_index", "do", "|", "cell", ",", "index", "|", "cell", ".", "color", "=", "color", ".", "is_a?", "(", "Array", ")", "?", "color", "[", "index", "]", ":", "color", "end", "end" ]
sets the color for every cell in this row
[ "sets", "the", "color", "for", "every", "cell", "in", "this", "row" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/row.rb#L107-L111
11,976
randym/axlsx
lib/axlsx/workbook/worksheet/row.rb
Axlsx.Row.style=
def style=(style) each_with_index do | cell, index | cell.style = style.is_a?(Array) ? style[index] : style end end
ruby
def style=(style) each_with_index do | cell, index | cell.style = style.is_a?(Array) ? style[index] : style end end
[ "def", "style", "=", "(", "style", ")", "each_with_index", "do", "|", "cell", ",", "index", "|", "cell", ".", "style", "=", "style", ".", "is_a?", "(", "Array", ")", "?", "style", "[", "index", "]", ":", "style", "end", "end" ]
sets the style for every cell in this row
[ "sets", "the", "style", "for", "every", "cell", "in", "this", "row" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/row.rb#L114-L118
11,977
randym/axlsx
lib/axlsx/workbook/worksheet/row.rb
Axlsx.Row.array_to_cells
def array_to_cells(values, options={}) DataTypeValidator.validate :array_to_cells, Array, values types, style, formula_values = options.delete(:types), options.delete(:style), options.delete(:formula_values) values.each_with_index do |value, index| options[:style] = style.is_a?(Array) ? style[index] : style if style options[:type] = types.is_a?(Array) ? types[index] : types if types options[:formula_value] = formula_values[index] if formula_values.is_a?(Array) self[index] = Cell.new(self, value, options) end end
ruby
def array_to_cells(values, options={}) DataTypeValidator.validate :array_to_cells, Array, values types, style, formula_values = options.delete(:types), options.delete(:style), options.delete(:formula_values) values.each_with_index do |value, index| options[:style] = style.is_a?(Array) ? style[index] : style if style options[:type] = types.is_a?(Array) ? types[index] : types if types options[:formula_value] = formula_values[index] if formula_values.is_a?(Array) self[index] = Cell.new(self, value, options) end end
[ "def", "array_to_cells", "(", "values", ",", "options", "=", "{", "}", ")", "DataTypeValidator", ".", "validate", ":array_to_cells", ",", "Array", ",", "values", "types", ",", "style", ",", "formula_values", "=", "options", ".", "delete", "(", ":types", ")", ",", "options", ".", "delete", "(", ":style", ")", ",", "options", ".", "delete", "(", ":formula_values", ")", "values", ".", "each_with_index", "do", "|", "value", ",", "index", "|", "options", "[", ":style", "]", "=", "style", ".", "is_a?", "(", "Array", ")", "?", "style", "[", "index", "]", ":", "style", "if", "style", "options", "[", ":type", "]", "=", "types", ".", "is_a?", "(", "Array", ")", "?", "types", "[", "index", "]", ":", "types", "if", "types", "options", "[", ":formula_value", "]", "=", "formula_values", "[", "index", "]", "if", "formula_values", ".", "is_a?", "(", "Array", ")", "self", "[", "index", "]", "=", "Cell", ".", "new", "(", "self", ",", "value", ",", "options", ")", "end", "end" ]
Converts values, types, and style options into cells and associates them with this row. A new cell is created for each item in the values array. If value option is defined and is a symbol it is applied to all the cells created. If the value option is an array, cell types are applied by index for each cell If the style option is defined and is an Integer, it is applied to all cells created. If the style option is an array, style is applied by index for each cell. @option options [Array] values @option options [Array, Symbol] types @option options [Array, Integer] style
[ "Converts", "values", "types", "and", "style", "options", "into", "cells", "and", "associates", "them", "with", "this", "row", ".", "A", "new", "cell", "is", "created", "for", "each", "item", "in", "the", "values", "array", ".", "If", "value", "option", "is", "defined", "and", "is", "a", "symbol", "it", "is", "applied", "to", "all", "the", "cells", "created", ".", "If", "the", "value", "option", "is", "an", "array", "cell", "types", "are", "applied", "by", "index", "for", "each", "cell", "If", "the", "style", "option", "is", "defined", "and", "is", "an", "Integer", "it", "is", "applied", "to", "all", "cells", "created", ".", "If", "the", "style", "option", "is", "an", "array", "style", "is", "applied", "by", "index", "for", "each", "cell", "." ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/row.rb#L148-L158
11,978
randym/axlsx
lib/axlsx/drawing/drawing.rb
Axlsx.Drawing.add_image
def add_image(options={}) if options[:end_at] TwoCellAnchor.new(self, options).add_pic(options) else OneCellAnchor.new(self, options) end @anchors.last.object end
ruby
def add_image(options={}) if options[:end_at] TwoCellAnchor.new(self, options).add_pic(options) else OneCellAnchor.new(self, options) end @anchors.last.object end
[ "def", "add_image", "(", "options", "=", "{", "}", ")", "if", "options", "[", ":end_at", "]", "TwoCellAnchor", ".", "new", "(", "self", ",", "options", ")", ".", "add_pic", "(", "options", ")", "else", "OneCellAnchor", ".", "new", "(", "self", ",", "options", ")", "end", "@anchors", ".", "last", ".", "object", "end" ]
Creates a new Drawing object @param [Worksheet] worksheet The worksheet that owns this drawing Adds an image to the chart If th end_at option is specified we create a two cell anchor. By default we use a one cell anchor. @note The recommended way to manage images is to use Worksheet.add_image. Please refer to that method for documentation. @see Worksheet#add_image @return [Pic]
[ "Creates", "a", "new", "Drawing", "object" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/drawing/drawing.rb#L85-L92
11,979
randym/axlsx
lib/axlsx/drawing/drawing.rb
Axlsx.Drawing.add_chart
def add_chart(chart_type, options={}) TwoCellAnchor.new(self, options) @anchors.last.add_chart(chart_type, options) end
ruby
def add_chart(chart_type, options={}) TwoCellAnchor.new(self, options) @anchors.last.add_chart(chart_type, options) end
[ "def", "add_chart", "(", "chart_type", ",", "options", "=", "{", "}", ")", "TwoCellAnchor", ".", "new", "(", "self", ",", "options", ")", "@anchors", ".", "last", ".", "add_chart", "(", "chart_type", ",", "options", ")", "end" ]
Adds a chart to the drawing. @note The recommended way to manage charts is to use Worksheet.add_chart. Please refer to that method for documentation. @see Worksheet#add_chart
[ "Adds", "a", "chart", "to", "the", "drawing", "." ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/drawing/drawing.rb#L97-L100
11,980
randym/axlsx
lib/axlsx/drawing/drawing.rb
Axlsx.Drawing.charts
def charts charts = @anchors.select { |a| a.object.is_a?(GraphicFrame) } charts.map { |a| a.object.chart } end
ruby
def charts charts = @anchors.select { |a| a.object.is_a?(GraphicFrame) } charts.map { |a| a.object.chart } end
[ "def", "charts", "charts", "=", "@anchors", ".", "select", "{", "|", "a", "|", "a", ".", "object", ".", "is_a?", "(", "GraphicFrame", ")", "}", "charts", ".", "map", "{", "|", "a", "|", "a", ".", "object", ".", "chart", "}", "end" ]
An array of charts that are associated with this drawing's anchors @return [Array]
[ "An", "array", "of", "charts", "that", "are", "associated", "with", "this", "drawing", "s", "anchors" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/drawing/drawing.rb#L104-L107
11,981
randym/axlsx
lib/axlsx/drawing/drawing.rb
Axlsx.Drawing.hyperlinks
def hyperlinks links = self.images.select { |a| a.hyperlink.is_a?(Hyperlink) } links.map { |a| a.hyperlink } end
ruby
def hyperlinks links = self.images.select { |a| a.hyperlink.is_a?(Hyperlink) } links.map { |a| a.hyperlink } end
[ "def", "hyperlinks", "links", "=", "self", ".", "images", ".", "select", "{", "|", "a", "|", "a", ".", "hyperlink", ".", "is_a?", "(", "Hyperlink", ")", "}", "links", ".", "map", "{", "|", "a", "|", "a", ".", "hyperlink", "}", "end" ]
An array of hyperlink objects associated with this drawings images @return [Array]
[ "An", "array", "of", "hyperlink", "objects", "associated", "with", "this", "drawings", "images" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/drawing/drawing.rb#L111-L114
11,982
randym/axlsx
lib/axlsx/drawing/drawing.rb
Axlsx.Drawing.images
def images images = @anchors.select { |a| a.object.is_a?(Pic) } images.map { |a| a.object } end
ruby
def images images = @anchors.select { |a| a.object.is_a?(Pic) } images.map { |a| a.object } end
[ "def", "images", "images", "=", "@anchors", ".", "select", "{", "|", "a", "|", "a", ".", "object", ".", "is_a?", "(", "Pic", ")", "}", "images", ".", "map", "{", "|", "a", "|", "a", ".", "object", "}", "end" ]
An array of image objects that are associated with this drawing's anchors @return [Array]
[ "An", "array", "of", "image", "objects", "that", "are", "associated", "with", "this", "drawing", "s", "anchors" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/drawing/drawing.rb#L118-L121
11,983
randym/axlsx
lib/axlsx/drawing/drawing.rb
Axlsx.Drawing.relationships
def relationships r = Relationships.new child_objects.each { |child| r << child.relationship } r end
ruby
def relationships r = Relationships.new child_objects.each { |child| r << child.relationship } r end
[ "def", "relationships", "r", "=", "Relationships", ".", "new", "child_objects", ".", "each", "{", "|", "child", "|", "r", "<<", "child", ".", "relationship", "}", "r", "end" ]
The drawing's relationships. @return [Relationships]
[ "The", "drawing", "s", "relationships", "." ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/drawing/drawing.rb#L150-L154
11,984
randym/axlsx
lib/axlsx/workbook/worksheet/sheet_pr.rb
Axlsx.SheetPr.to_xml_string
def to_xml_string(str = '') update_properties str << "<sheetPr #{serialized_attributes}>" tab_color.to_xml_string(str, 'tabColor') if tab_color outline_pr.to_xml_string(str) if @outline_pr page_setup_pr.to_xml_string(str) str << "</sheetPr>" end
ruby
def to_xml_string(str = '') update_properties str << "<sheetPr #{serialized_attributes}>" tab_color.to_xml_string(str, 'tabColor') if tab_color outline_pr.to_xml_string(str) if @outline_pr page_setup_pr.to_xml_string(str) str << "</sheetPr>" end
[ "def", "to_xml_string", "(", "str", "=", "''", ")", "update_properties", "str", "<<", "\"<sheetPr #{serialized_attributes}>\"", "tab_color", ".", "to_xml_string", "(", "str", ",", "'tabColor'", ")", "if", "tab_color", "outline_pr", ".", "to_xml_string", "(", "str", ")", "if", "@outline_pr", "page_setup_pr", ".", "to_xml_string", "(", "str", ")", "str", "<<", "\"</sheetPr>\"", "end" ]
Serialize the object @param [String] str serialized output will be appended to this object if provided. @return [String]
[ "Serialize", "the", "object" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/sheet_pr.rb#L51-L58
11,985
randym/axlsx
lib/axlsx/drawing/pie_3D_chart.rb
Axlsx.Pie3DChart.to_xml_string
def to_xml_string(str = '') super(str) do str << '<c:pie3DChart>' str << ('<c:varyColors val="' << vary_colors.to_s << '"/>') @series.each { |ser| ser.to_xml_string(str) } d_lbls.to_xml_string(str) if @d_lbls str << '</c:pie3DChart>' end end
ruby
def to_xml_string(str = '') super(str) do str << '<c:pie3DChart>' str << ('<c:varyColors val="' << vary_colors.to_s << '"/>') @series.each { |ser| ser.to_xml_string(str) } d_lbls.to_xml_string(str) if @d_lbls str << '</c:pie3DChart>' end end
[ "def", "to_xml_string", "(", "str", "=", "''", ")", "super", "(", "str", ")", "do", "str", "<<", "'<c:pie3DChart>'", "str", "<<", "(", "'<c:varyColors val=\"'", "<<", "vary_colors", ".", "to_s", "<<", "'\"/>'", ")", "@series", ".", "each", "{", "|", "ser", "|", "ser", ".", "to_xml_string", "(", "str", ")", "}", "d_lbls", ".", "to_xml_string", "(", "str", ")", "if", "@d_lbls", "str", "<<", "'</c:pie3DChart>'", "end", "end" ]
Creates a new pie chart object @param [GraphicFrame] frame The workbook that owns this chart. @option options [Cell, String] title @option options [Boolean] show_legend @option options [Symbol] grouping @option options [String] gap_depth @option options [Integer] rot_x @option options [String] h_percent @option options [Integer] rot_y @option options [String] depth_percent @option options [Boolean] r_ang_ax @option options [Integer] perspective @see Chart @see View3D Serializes the object @param [String] str @return [String]
[ "Creates", "a", "new", "pie", "chart", "object" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/drawing/pie_3D_chart.rb#L36-L44
11,986
randym/axlsx
lib/axlsx/workbook/workbook_views.rb
Axlsx.WorkbookViews.to_xml_string
def to_xml_string(str = '') return if empty? str << "<bookViews>" each { |view| view.to_xml_string(str) } str << '</bookViews>' end
ruby
def to_xml_string(str = '') return if empty? str << "<bookViews>" each { |view| view.to_xml_string(str) } str << '</bookViews>' end
[ "def", "to_xml_string", "(", "str", "=", "''", ")", "return", "if", "empty?", "str", "<<", "\"<bookViews>\"", "each", "{", "|", "view", "|", "view", ".", "to_xml_string", "(", "str", ")", "}", "str", "<<", "'</bookViews>'", "end" ]
creates the book views object Serialize to xml @param [String] str @return [String]
[ "creates", "the", "book", "views", "object", "Serialize", "to", "xml" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/workbook_views.rb#L13-L18
11,987
randym/axlsx
lib/axlsx/workbook/worksheet/col.rb
Axlsx.Col.update_width
def update_width(cell, fixed_width=nil, use_autowidth=true) if fixed_width.is_a? Numeric self.width = fixed_width elsif use_autowidth cell_width = cell.autowidth self.width = cell_width unless (width || 0) > (cell_width || 0) end end
ruby
def update_width(cell, fixed_width=nil, use_autowidth=true) if fixed_width.is_a? Numeric self.width = fixed_width elsif use_autowidth cell_width = cell.autowidth self.width = cell_width unless (width || 0) > (cell_width || 0) end end
[ "def", "update_width", "(", "cell", ",", "fixed_width", "=", "nil", ",", "use_autowidth", "=", "true", ")", "if", "fixed_width", ".", "is_a?", "Numeric", "self", ".", "width", "=", "fixed_width", "elsif", "use_autowidth", "cell_width", "=", "cell", ".", "autowidth", "self", ".", "width", "=", "cell_width", "unless", "(", "width", "||", "0", ")", ">", "(", "cell_width", "||", "0", ")", "end", "end" ]
updates the width for this col based on the cells autowidth and an optionally specified fixed width @param [Cell] cell The cell to use in updating this col's width @param [Integer] fixed_width If this is specified the width is set to this value and the cell's attributes are ignored. @param [Boolean] use_autowidth If this is false, the cell's autowidth value will be ignored.
[ "updates", "the", "width", "for", "this", "col", "based", "on", "the", "cells", "autowidth", "and", "an", "optionally", "specified", "fixed", "width" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/col.rb#L124-L131
11,988
randym/axlsx
lib/axlsx/util/parser.rb
Axlsx.Parser.parse_symbol
def parse_symbol attr_name, xpath v = parse_value xpath v = v.to_sym unless v.nil? send("#{attr_name}=", v) end
ruby
def parse_symbol attr_name, xpath v = parse_value xpath v = v.to_sym unless v.nil? send("#{attr_name}=", v) end
[ "def", "parse_symbol", "attr_name", ",", "xpath", "v", "=", "parse_value", "xpath", "v", "=", "v", ".", "to_sym", "unless", "v", ".", "nil?", "send", "(", "\"#{attr_name}=\"", ",", "v", ")", "end" ]
parse convert and assign node text to symbol
[ "parse", "convert", "and", "assign", "node", "text", "to", "symbol" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/util/parser.rb#L16-L20
11,989
randym/axlsx
lib/axlsx/util/parser.rb
Axlsx.Parser.parse_integer
def parse_integer attr_name, xpath v = parse_value xpath v = v.to_i if v.respond_to?(:to_i) send("#{attr_name}=", v) end
ruby
def parse_integer attr_name, xpath v = parse_value xpath v = v.to_i if v.respond_to?(:to_i) send("#{attr_name}=", v) end
[ "def", "parse_integer", "attr_name", ",", "xpath", "v", "=", "parse_value", "xpath", "v", "=", "v", ".", "to_i", "if", "v", ".", "respond_to?", "(", ":to_i", ")", "send", "(", "\"#{attr_name}=\"", ",", "v", ")", "end" ]
parse, convert and assign note text to integer
[ "parse", "convert", "and", "assign", "note", "text", "to", "integer" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/util/parser.rb#L23-L27
11,990
randym/axlsx
lib/axlsx/util/parser.rb
Axlsx.Parser.parse_float
def parse_float attr_name, xpath v = parse_value xpath v = v.to_f if v.respond_to?(:to_f) send("#{attr_name}=", v) end
ruby
def parse_float attr_name, xpath v = parse_value xpath v = v.to_f if v.respond_to?(:to_f) send("#{attr_name}=", v) end
[ "def", "parse_float", "attr_name", ",", "xpath", "v", "=", "parse_value", "xpath", "v", "=", "v", ".", "to_f", "if", "v", ".", "respond_to?", "(", ":to_f", ")", "send", "(", "\"#{attr_name}=\"", ",", "v", ")", "end" ]
parse, convert and assign node text to float
[ "parse", "convert", "and", "assign", "node", "text", "to", "float" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/util/parser.rb#L30-L34
11,991
randym/axlsx
lib/axlsx/util/parser.rb
Axlsx.Parser.parse_value
def parse_value xpath node = parser_xml.xpath(xpath) return nil if node.empty? node.text.strip end
ruby
def parse_value xpath node = parser_xml.xpath(xpath) return nil if node.empty? node.text.strip end
[ "def", "parse_value", "xpath", "node", "=", "parser_xml", ".", "xpath", "(", "xpath", ")", "return", "nil", "if", "node", ".", "empty?", "node", ".", "text", ".", "strip", "end" ]
return node text based on xpath
[ "return", "node", "text", "based", "on", "xpath" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/util/parser.rb#L37-L41
11,992
randym/axlsx
lib/axlsx/workbook/worksheet/worksheet_drawing.rb
Axlsx.WorksheetDrawing.add_chart
def add_chart(chart_type, options) @drawing ||= Drawing.new worksheet drawing.add_chart(chart_type, options) end
ruby
def add_chart(chart_type, options) @drawing ||= Drawing.new worksheet drawing.add_chart(chart_type, options) end
[ "def", "add_chart", "(", "chart_type", ",", "options", ")", "@drawing", "||=", "Drawing", ".", "new", "worksheet", "drawing", ".", "add_chart", "(", "chart_type", ",", "options", ")", "end" ]
adds a chart to the drawing object @param [Class] chart_type The type of chart to add @param [Hash] options Options to pass on to the drawing and chart @see Worksheet#add_chart
[ "adds", "a", "chart", "to", "the", "drawing", "object" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/worksheet_drawing.rb#L25-L28
11,993
randym/axlsx
lib/axlsx/workbook/worksheet/protected_ranges.rb
Axlsx.ProtectedRanges.add_range
def add_range(cells) sqref = if cells.is_a?(String) cells elsif cells.is_a?(SimpleTypedList) || cells.is_a?(Array) Axlsx::cell_range(cells, false) end self << ProtectedRange.new(:sqref => sqref, :name => "Range#{size}") last end
ruby
def add_range(cells) sqref = if cells.is_a?(String) cells elsif cells.is_a?(SimpleTypedList) || cells.is_a?(Array) Axlsx::cell_range(cells, false) end self << ProtectedRange.new(:sqref => sqref, :name => "Range#{size}") last end
[ "def", "add_range", "(", "cells", ")", "sqref", "=", "if", "cells", ".", "is_a?", "(", "String", ")", "cells", "elsif", "cells", ".", "is_a?", "(", "SimpleTypedList", ")", "||", "cells", ".", "is_a?", "(", "Array", ")", "Axlsx", "::", "cell_range", "(", "cells", ",", "false", ")", "end", "self", "<<", "ProtectedRange", ".", "new", "(", ":sqref", "=>", "sqref", ",", ":name", "=>", "\"Range#{size}\"", ")", "last", "end" ]
Adds a protected range @param [Array|String] cells A string range reference or array of cells that will be protected
[ "Adds", "a", "protected", "range" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/protected_ranges.rb#L17-L25
11,994
randym/axlsx
lib/axlsx/workbook/worksheet/protected_ranges.rb
Axlsx.ProtectedRanges.to_xml_string
def to_xml_string(str = '') return if empty? str << '<protectedRanges>' each { |range| range.to_xml_string(str) } str << '</protectedRanges>' end
ruby
def to_xml_string(str = '') return if empty? str << '<protectedRanges>' each { |range| range.to_xml_string(str) } str << '</protectedRanges>' end
[ "def", "to_xml_string", "(", "str", "=", "''", ")", "return", "if", "empty?", "str", "<<", "'<protectedRanges>'", "each", "{", "|", "range", "|", "range", ".", "to_xml_string", "(", "str", ")", "}", "str", "<<", "'</protectedRanges>'", "end" ]
Serializes the protected ranges @param [String] str @return [String]
[ "Serializes", "the", "protected", "ranges" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/protected_ranges.rb#L30-L35
11,995
randym/axlsx
lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb
Axlsx.AutoFilter.add_column
def add_column(col_id, filter_type, options = {}) columns << FilterColumn.new(col_id, filter_type, options) columns.last end
ruby
def add_column(col_id, filter_type, options = {}) columns << FilterColumn.new(col_id, filter_type, options) columns.last end
[ "def", "add_column", "(", "col_id", ",", "filter_type", ",", "options", "=", "{", "}", ")", "columns", "<<", "FilterColumn", ".", "new", "(", "col_id", ",", "filter_type", ",", "options", ")", "columns", ".", "last", "end" ]
Adds a filter column. This is the recommended way to create and manage filter columns for your autofilter. In addition to the require id and type parameters, options will be passed to the filter column during instantiation. @param [String] col_id Zero-based index indicating the AutoFilter column to which this filter information applies. @param [Symbol] filter_type A symbol representing one of the supported filter types. @param [Hash] options a hash of options to pass into the generated filter @return [FilterColumn]
[ "Adds", "a", "filter", "column", ".", "This", "is", "the", "recommended", "way", "to", "create", "and", "manage", "filter", "columns", "for", "your", "autofilter", ".", "In", "addition", "to", "the", "require", "id", "and", "type", "parameters", "options", "will", "be", "passed", "to", "the", "filter", "column", "during", "instantiation", "." ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb#L45-L48
11,996
randym/axlsx
lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb
Axlsx.AutoFilter.apply
def apply first_cell, last_cell = range.split(':') start_point = Axlsx::name_to_indices(first_cell) end_point = Axlsx::name_to_indices(last_cell) # The +1 is so we skip the header row with the filter drop downs rows = worksheet.rows[(start_point.last+1)..end_point.last] || [] column_offset = start_point.first columns.each do |column| rows.each do |row| next if row.hidden column.apply(row, column_offset) end end end
ruby
def apply first_cell, last_cell = range.split(':') start_point = Axlsx::name_to_indices(first_cell) end_point = Axlsx::name_to_indices(last_cell) # The +1 is so we skip the header row with the filter drop downs rows = worksheet.rows[(start_point.last+1)..end_point.last] || [] column_offset = start_point.first columns.each do |column| rows.each do |row| next if row.hidden column.apply(row, column_offset) end end end
[ "def", "apply", "first_cell", ",", "last_cell", "=", "range", ".", "split", "(", "':'", ")", "start_point", "=", "Axlsx", "::", "name_to_indices", "(", "first_cell", ")", "end_point", "=", "Axlsx", "::", "name_to_indices", "(", "last_cell", ")", "# The +1 is so we skip the header row with the filter drop downs", "rows", "=", "worksheet", ".", "rows", "[", "(", "start_point", ".", "last", "+", "1", ")", "..", "end_point", ".", "last", "]", "||", "[", "]", "column_offset", "=", "start_point", ".", "first", "columns", ".", "each", "do", "|", "column", "|", "rows", ".", "each", "do", "|", "row", "|", "next", "if", "row", ".", "hidden", "column", ".", "apply", "(", "row", ",", "column_offset", ")", "end", "end", "end" ]
actually performs the filtering of rows who's cells do not match the filter.
[ "actually", "performs", "the", "filtering", "of", "rows", "who", "s", "cells", "do", "not", "match", "the", "filter", "." ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb#L52-L66
11,997
randym/axlsx
lib/axlsx/util/simple_typed_list.rb
Axlsx.SimpleTypedList.delete
def delete(v) return unless include? v raise ArgumentError, "Item is protected and cannot be deleted" if protected? index(v) @list.delete v end
ruby
def delete(v) return unless include? v raise ArgumentError, "Item is protected and cannot be deleted" if protected? index(v) @list.delete v end
[ "def", "delete", "(", "v", ")", "return", "unless", "include?", "v", "raise", "ArgumentError", ",", "\"Item is protected and cannot be deleted\"", "if", "protected?", "index", "(", "v", ")", "@list", ".", "delete", "v", "end" ]
delete the item from the list @param [Any] v The item to be deleted. @raise [ArgumentError] if the item's index is protected by locking @return [Any] The item deleted
[ "delete", "the", "item", "from", "the", "list" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/util/simple_typed_list.rb#L108-L112
11,998
randym/axlsx
lib/axlsx/util/simple_typed_list.rb
Axlsx.SimpleTypedList.[]=
def []=(index, v) DataTypeValidator.validate :SimpleTypedList_insert, @allowed_types, v raise ArgumentError, "Item is protected and cannot be changed" if protected? index @list[index] = v v end
ruby
def []=(index, v) DataTypeValidator.validate :SimpleTypedList_insert, @allowed_types, v raise ArgumentError, "Item is protected and cannot be changed" if protected? index @list[index] = v v end
[ "def", "[]=", "(", "index", ",", "v", ")", "DataTypeValidator", ".", "validate", ":SimpleTypedList_insert", ",", "@allowed_types", ",", "v", "raise", "ArgumentError", ",", "\"Item is protected and cannot be changed\"", "if", "protected?", "index", "@list", "[", "index", "]", "=", "v", "v", "end" ]
positional assignment. Adds the item at the index specified @param [Integer] index @param [Any] v @raise [ArgumentError] if the index is protected by locking @raise [ArgumentError] if the item is not one of the allowed types
[ "positional", "assignment", ".", "Adds", "the", "item", "at", "the", "index", "specified" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/util/simple_typed_list.rb#L128-L133
11,999
randym/axlsx
lib/axlsx/util/serialized_attributes.rb
Axlsx.SerializedAttributes.serialized_tag
def serialized_tag(tagname, str, additional_attributes = {}, &block) str << "<#{tagname} " serialized_attributes(str, additional_attributes) if block_given? str << '>' yield str << "</#{tagname}>" else str << '/>' end end
ruby
def serialized_tag(tagname, str, additional_attributes = {}, &block) str << "<#{tagname} " serialized_attributes(str, additional_attributes) if block_given? str << '>' yield str << "</#{tagname}>" else str << '/>' end end
[ "def", "serialized_tag", "(", "tagname", ",", "str", ",", "additional_attributes", "=", "{", "}", ",", "&", "block", ")", "str", "<<", "\"<#{tagname} \"", "serialized_attributes", "(", "str", ",", "additional_attributes", ")", "if", "block_given?", "str", "<<", "'>'", "yield", "str", "<<", "\"</#{tagname}>\"", "else", "str", "<<", "'/>'", "end", "end" ]
creates a XML tag with serialized attributes @see SerializedAttributes#serialized_attributes
[ "creates", "a", "XML", "tag", "with", "serialized", "attributes" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/util/serialized_attributes.rb#L34-L44