repo
stringlengths
5
58
path
stringlengths
9
168
func_name
stringlengths
9
130
original_string
stringlengths
66
10.5k
language
stringclasses
1 value
code
stringlengths
66
10.5k
code_tokens
list
docstring
stringlengths
8
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
94
266
partition
stringclasses
1 value
projectcypress/health-data-standards
lib/hqmf-parser/2.0/data_criteria_helpers/dc_post_processing.rb
HQMF2.DataCriteriaPostProcessing.handle_mapping_template
def handle_mapping_template(mapping) if mapping if mapping[:valueset_path] && @entry.at_xpath(mapping[:valueset_path]) @code_list_xpath = mapping[:valueset_path] end @value = DataCriteriaMethods.parse_value(@entry, mapping[:result_path]) if mapping[:result_path] end end
ruby
def handle_mapping_template(mapping) if mapping if mapping[:valueset_path] && @entry.at_xpath(mapping[:valueset_path]) @code_list_xpath = mapping[:valueset_path] end @value = DataCriteriaMethods.parse_value(@entry, mapping[:result_path]) if mapping[:result_path] end end
[ "def", "handle_mapping_template", "(", "mapping", ")", "if", "mapping", "if", "mapping", "[", ":valueset_path", "]", "&&", "@entry", ".", "at_xpath", "(", "mapping", "[", ":valueset_path", "]", ")", "@code_list_xpath", "=", "mapping", "[", ":valueset_path", "]",...
Set the value and code_list_xpath using the template mapping held in the ValueSetHelper class
[ "Set", "the", "value", "and", "code_list_xpath", "using", "the", "template", "mapping", "held", "in", "the", "ValueSetHelper", "class" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/data_criteria_helpers/dc_post_processing.rb#L41-L48
train
projectcypress/health-data-standards
lib/hqmf-parser/2.0/data_criteria_helpers/dc_post_processing.rb
HQMF2.DataCriteriaPostProcessing.handle_derived_specific_occurrences
def handle_derived_specific_occurrences return unless @definition == 'derived' # remove "_source" from source data critera. It gets added in in SpecificOccurrenceAndSource but # when it gets added we have not yet determined the definition of the data criteria so we cannot # skip adding it. Det...
ruby
def handle_derived_specific_occurrences return unless @definition == 'derived' # remove "_source" from source data critera. It gets added in in SpecificOccurrenceAndSource but # when it gets added we have not yet determined the definition of the data criteria so we cannot # skip adding it. Det...
[ "def", "handle_derived_specific_occurrences", "return", "unless", "@definition", "==", "'derived'", "# remove \"_source\" from source data critera. It gets added in in SpecificOccurrenceAndSource but", "# when it gets added we have not yet determined the definition of the data criteria so we cannot"...
Apply some elements from the reference_criteria to the derived specific occurrence
[ "Apply", "some", "elements", "from", "the", "reference_criteria", "to", "the", "derived", "specific", "occurrence" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/data_criteria_helpers/dc_post_processing.rb#L62-L83
train
projectcypress/health-data-standards
lib/hqmf-parser/converter/pass1/data_criteria_converter.rb
HQMF.DataCriteriaConverter.create_group_data_criteria
def create_group_data_criteria(preconditions, type, value, parent_id, id, standard_category, qds_data_type) extract_group_data_criteria_tree(HQMF::DataCriteria::UNION,preconditions, type, parent_id) end
ruby
def create_group_data_criteria(preconditions, type, value, parent_id, id, standard_category, qds_data_type) extract_group_data_criteria_tree(HQMF::DataCriteria::UNION,preconditions, type, parent_id) end
[ "def", "create_group_data_criteria", "(", "preconditions", ",", "type", ",", "value", ",", "parent_id", ",", "id", ",", "standard_category", ",", "qds_data_type", ")", "extract_group_data_criteria_tree", "(", "HQMF", "::", "DataCriteria", "::", "UNION", ",", "precon...
grouping data criteria are used to allow a single reference off of a temporal reference or subset operator grouping data criteria can reference either regular data criteria as children, or other grouping data criteria
[ "grouping", "data", "criteria", "are", "used", "to", "allow", "a", "single", "reference", "off", "of", "a", "temporal", "reference", "or", "subset", "operator", "grouping", "data", "criteria", "can", "reference", "either", "regular", "data", "criteria", "as", ...
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/converter/pass1/data_criteria_converter.rb#L46-L48
train
projectcypress/health-data-standards
lib/hqmf-parser/converter/pass1/data_criteria_converter.rb
HQMF.DataCriteriaConverter.extract_group_data_criteria_tree
def extract_group_data_criteria_tree(conjunction, preconditions, type, parent_id) children = [] preconditions.each do |precondition| if (precondition.comparison?) if (precondition.reference.id == HQMF::Document::MEASURE_PERIOD_ID) children << measure_period_criteria ...
ruby
def extract_group_data_criteria_tree(conjunction, preconditions, type, parent_id) children = [] preconditions.each do |precondition| if (precondition.comparison?) if (precondition.reference.id == HQMF::Document::MEASURE_PERIOD_ID) children << measure_period_criteria ...
[ "def", "extract_group_data_criteria_tree", "(", "conjunction", ",", "preconditions", ",", "type", ",", "parent_id", ")", "children", "=", "[", "]", "preconditions", ".", "each", "do", "|", "precondition", "|", "if", "(", "precondition", ".", "comparison?", ")", ...
pull the children data criteria out of a set of preconditions
[ "pull", "the", "children", "data", "criteria", "out", "of", "a", "set", "of", "preconditions" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/converter/pass1/data_criteria_converter.rb#L73-L96
train
projectcypress/health-data-standards
lib/hqmf-parser/converter/pass1/data_criteria_converter.rb
HQMF.DataCriteriaConverter.create_measure_period_v1_data_criteria
def create_measure_period_v1_data_criteria(doc,measure_period,v1_data_criteria_by_id) attributes = doc[:attributes] attributes.keys.each {|key| attributes[key.to_s] = attributes[key]} measure_period_key = attributes['MEASUREMENT_PERIOD'][:id] measure_start_key = attributes['MEASUREMENT_S...
ruby
def create_measure_period_v1_data_criteria(doc,measure_period,v1_data_criteria_by_id) attributes = doc[:attributes] attributes.keys.each {|key| attributes[key.to_s] = attributes[key]} measure_period_key = attributes['MEASUREMENT_PERIOD'][:id] measure_start_key = attributes['MEASUREMENT_S...
[ "def", "create_measure_period_v1_data_criteria", "(", "doc", ",", "measure_period", ",", "v1_data_criteria_by_id", ")", "attributes", "=", "doc", "[", ":attributes", "]", "attributes", ".", "keys", ".", "each", "{", "|", "key", "|", "attributes", "[", "key", "."...
this method creates V1 data criteria for the measurement period. These data criteria can be referenced properly within the restrictions
[ "this", "method", "creates", "V1", "data", "criteria", "for", "the", "measurement", "period", ".", "These", "data", "criteria", "can", "be", "referenced", "properly", "within", "the", "restrictions" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/converter/pass1/data_criteria_converter.rb#L214-L245
train
projectcypress/health-data-standards
lib/hqmf-parser/2.0/data_criteria_helpers/dc_base_extract.rb
HQMF2.DataCriteriaBaseExtractions.extract_child_criteria
def extract_child_criteria @entry.xpath("./*/cda:outboundRelationship[@typeCode='COMP']/cda:criteriaReference/cda:id", HQMF2::Document::NAMESPACES).collect do |ref| Reference.new(ref).id end.compact end
ruby
def extract_child_criteria @entry.xpath("./*/cda:outboundRelationship[@typeCode='COMP']/cda:criteriaReference/cda:id", HQMF2::Document::NAMESPACES).collect do |ref| Reference.new(ref).id end.compact end
[ "def", "extract_child_criteria", "@entry", ".", "xpath", "(", "\"./*/cda:outboundRelationship[@typeCode='COMP']/cda:criteriaReference/cda:id\"", ",", "HQMF2", "::", "Document", "::", "NAMESPACES", ")", ".", "collect", "do", "|", "ref", "|", "Reference", ".", "new", "(",...
Generate a list of child criterias
[ "Generate", "a", "list", "of", "child", "criterias" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/data_criteria_helpers/dc_base_extract.rb#L22-L27
train
projectcypress/health-data-standards
lib/hqmf-parser/2.0/data_criteria_helpers/dc_base_extract.rb
HQMF2.DataCriteriaBaseExtractions.all_subset_operators
def all_subset_operators @entry.xpath('./*/cda:excerpt', HQMF2::Document::NAMESPACES).collect do |subset_operator| SubsetOperator.new(subset_operator) end end
ruby
def all_subset_operators @entry.xpath('./*/cda:excerpt', HQMF2::Document::NAMESPACES).collect do |subset_operator| SubsetOperator.new(subset_operator) end end
[ "def", "all_subset_operators", "@entry", ".", "xpath", "(", "'./*/cda:excerpt'", ",", "HQMF2", "::", "Document", "::", "NAMESPACES", ")", ".", "collect", "do", "|", "subset_operator", "|", "SubsetOperator", ".", "new", "(", "subset_operator", ")", "end", "end" ]
Extracts all subset operators contained in the entry xml
[ "Extracts", "all", "subset", "operators", "contained", "in", "the", "entry", "xml" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/data_criteria_helpers/dc_base_extract.rb#L56-L60
train
projectcypress/health-data-standards
lib/hqmf-parser/1.0/utilities.rb
HQMF1.Utilities.check_nil_conjunction_on_child
def check_nil_conjunction_on_child if (@preconditions.length == 1 && @preconditions.first.conjunction.nil?) bad_precondition = @preconditions.first if (bad_precondition.restrictions.empty? && bad_precondition.subset.nil? && bad_precondition.expression.nil?) @preconditions = @precondition...
ruby
def check_nil_conjunction_on_child if (@preconditions.length == 1 && @preconditions.first.conjunction.nil?) bad_precondition = @preconditions.first if (bad_precondition.restrictions.empty? && bad_precondition.subset.nil? && bad_precondition.expression.nil?) @preconditions = @precondition...
[ "def", "check_nil_conjunction_on_child", "if", "(", "@preconditions", ".", "length", "==", "1", "&&", "@preconditions", ".", "first", ".", "conjunction", ".", "nil?", ")", "bad_precondition", "=", "@preconditions", ".", "first", "if", "(", "bad_precondition", ".",...
Preconditions can have nil conjunctions as part of a DATEDIFF, we want to remove these and warn
[ "Preconditions", "can", "have", "nil", "conjunctions", "as", "part", "of", "a", "DATEDIFF", "we", "want", "to", "remove", "these", "and", "warn" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/1.0/utilities.rb#L41-L51
train
projectcypress/health-data-standards
lib/hqmf-model/document.rb
HQMF.Document.specific_occurrence_source_data_criteria
def specific_occurrence_source_data_criteria(force_sources=nil) return [] if @source_data_criteria.nil? matching = @source_data_criteria.select {|dc| !dc.specific_occurrence.nil?} if force_sources existing = matching.map(&:id) matching.concat @source_data_criteria.select {|dc| !existi...
ruby
def specific_occurrence_source_data_criteria(force_sources=nil) return [] if @source_data_criteria.nil? matching = @source_data_criteria.select {|dc| !dc.specific_occurrence.nil?} if force_sources existing = matching.map(&:id) matching.concat @source_data_criteria.select {|dc| !existi...
[ "def", "specific_occurrence_source_data_criteria", "(", "force_sources", "=", "nil", ")", "return", "[", "]", "if", "@source_data_criteria", ".", "nil?", "matching", "=", "@source_data_criteria", ".", "select", "{", "|", "dc", "|", "!", "dc", ".", "specific_occurr...
Get the source data criteria that are specific occurrences @return [Array] an array of HQMF::DataCriteria describing the data elements used by the measure that are specific occurrences
[ "Get", "the", "source", "data", "criteria", "that", "are", "specific", "occurrences" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-model/document.rb#L146-L156
train
projectcypress/health-data-standards
lib/hqmf-model/document.rb
HQMF.Document.attributes_for_code
def attributes_for_code(code, code_system) @attributes.find_all { |e| e.send(:code) == code && e.send(:code_obj).send(:system) == code_system } end
ruby
def attributes_for_code(code, code_system) @attributes.find_all { |e| e.send(:code) == code && e.send(:code_obj).send(:system) == code_system } end
[ "def", "attributes_for_code", "(", "code", ",", "code_system", ")", "@attributes", ".", "find_all", "{", "|", "e", "|", "e", ".", "send", "(", ":code", ")", "==", "code", "&&", "e", ".", "send", "(", ":code_obj", ")", ".", "send", "(", ":system", ")"...
Get specific attributes by code. @param [String] code the attribute code @param [String] code_system the attribute code system @return [Array#Attribute] the matching attributes, raises an Exception if not found
[ "Get", "specific", "attributes", "by", "code", "." ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-model/document.rb#L183-L185
train
projectcypress/health-data-standards
lib/hqmf-model/document.rb
HQMF.Document.backfill_patient_characteristics_with_codes
def backfill_patient_characteristics_with_codes(codes) [].concat(self.all_data_criteria).concat(self.source_data_criteria).each do |data_criteria| if (data_criteria.type == :characteristic and !data_criteria.property.nil?) if (codes) value_set = codes[data_criteria.code_list_i...
ruby
def backfill_patient_characteristics_with_codes(codes) [].concat(self.all_data_criteria).concat(self.source_data_criteria).each do |data_criteria| if (data_criteria.type == :characteristic and !data_criteria.property.nil?) if (codes) value_set = codes[data_criteria.code_list_i...
[ "def", "backfill_patient_characteristics_with_codes", "(", "codes", ")", "[", "]", ".", "concat", "(", "self", ".", "all_data_criteria", ")", ".", "concat", "(", "self", ".", "source_data_criteria", ")", ".", "each", "do", "|", "data_criteria", "|", "if", "(",...
patient characteristics data criteria such as GENDER require looking at the codes to determine if the measure is interested in Males or Females. This process is awkward, and thus is done as a separate step after the document has been converted.
[ "patient", "characteristics", "data", "criteria", "such", "as", "GENDER", "require", "looking", "at", "the", "codes", "to", "determine", "if", "the", "measure", "is", "interested", "in", "Males", "or", "Females", ".", "This", "process", "is", "awkward", "and",...
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-model/document.rb#L197-L236
train
projectcypress/health-data-standards
lib/hqmf-parser/2.0/data_criteria_helpers/dc_definition_from_template_or_type_extract.rb
HQMF2.DataCriteriaTypeAndDefinitionExtraction.handle_known_template_id
def handle_known_template_id(template_id) case template_id when VARIABLE_TEMPLATE @derivation_operator = HQMF::DataCriteria::INTERSECT if @derivation_operator == HQMF::DataCriteria::XPRODUCT @definition ||= 'derived' @variable = true @negation = false when SATISFIES_ANY...
ruby
def handle_known_template_id(template_id) case template_id when VARIABLE_TEMPLATE @derivation_operator = HQMF::DataCriteria::INTERSECT if @derivation_operator == HQMF::DataCriteria::XPRODUCT @definition ||= 'derived' @variable = true @negation = false when SATISFIES_ANY...
[ "def", "handle_known_template_id", "(", "template_id", ")", "case", "template_id", "when", "VARIABLE_TEMPLATE", "@derivation_operator", "=", "HQMF", "::", "DataCriteria", "::", "INTERSECT", "if", "@derivation_operator", "==", "HQMF", "::", "DataCriteria", "::", "XPRODUC...
Given a template id, modify the variables inside this data criteria to reflect the template
[ "Given", "a", "template", "id", "modify", "the", "variables", "inside", "this", "data", "criteria", "to", "reflect", "the", "template" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/data_criteria_helpers/dc_definition_from_template_or_type_extract.rb#L36-L54
train
projectcypress/health-data-standards
lib/hqmf-parser/2.0/data_criteria_helpers/dc_definition_from_template_or_type_extract.rb
HQMF2.DataCriteriaTypeAndDefinitionExtraction.extract_information_for_specific_variable
def extract_information_for_specific_variable reference = @entry.at_xpath('./*/cda:outboundRelationship/cda:criteriaReference', HQMF2::Document::NAMESPACES) if reference ref_id = strip_tokens( "#{HQMF2::Utilities.attr_val(reference, 'cda:id/@extension')}_#...
ruby
def extract_information_for_specific_variable reference = @entry.at_xpath('./*/cda:outboundRelationship/cda:criteriaReference', HQMF2::Document::NAMESPACES) if reference ref_id = strip_tokens( "#{HQMF2::Utilities.attr_val(reference, 'cda:id/@extension')}_#...
[ "def", "extract_information_for_specific_variable", "reference", "=", "@entry", ".", "at_xpath", "(", "'./*/cda:outboundRelationship/cda:criteriaReference'", ",", "HQMF2", "::", "Document", "::", "NAMESPACES", ")", "if", "reference", "ref_id", "=", "strip_tokens", "(", "\...
Extracts information from a reference for a specific
[ "Extracts", "information", "from", "a", "reference", "for", "a", "specific" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/data_criteria_helpers/dc_definition_from_template_or_type_extract.rb#L73-L87
train
projectcypress/health-data-standards
lib/hqmf-parser/2.0/data_criteria_helpers/dc_definition_from_template_or_type_extract.rb
HQMF2.DataCriteriaTypeAndDefinitionExtraction.handle_specific_variable_ref
def handle_specific_variable_ref(reference_criteria) # if there are no referenced children, then it's a variable representing # a single data criteria, so just reference it if reference_criteria.children_criteria.empty? @children_criteria = [reference_criteria.id] # otherwise pull all th...
ruby
def handle_specific_variable_ref(reference_criteria) # if there are no referenced children, then it's a variable representing # a single data criteria, so just reference it if reference_criteria.children_criteria.empty? @children_criteria = [reference_criteria.id] # otherwise pull all th...
[ "def", "handle_specific_variable_ref", "(", "reference_criteria", ")", "# if there are no referenced children, then it's a variable representing", "# a single data criteria, so just reference it", "if", "reference_criteria", ".", "children_criteria", ".", "empty?", "@children_criteria", ...
Apply additional information to a specific occurrence's elements from the criteria it references.
[ "Apply", "additional", "information", "to", "a", "specific", "occurrence", "s", "elements", "from", "the", "criteria", "it", "references", "." ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/data_criteria_helpers/dc_definition_from_template_or_type_extract.rb#L90-L106
train
projectcypress/health-data-standards
lib/hqmf-parser/2.0/data_criteria_helpers/dc_definition_from_template_or_type_extract.rb
HQMF2.DataCriteriaTypeAndDefinitionExtraction.definition_for_nil_entry
def definition_for_nil_entry reference = @entry.at_xpath('./*/cda:outboundRelationship/cda:criteriaReference', HQMF2::Document::NAMESPACES) ref_id = nil unless reference.nil? ref_id = "#{HQMF2::Utilities.attr_val(reference, 'cda:id/@extension')}_#{HQMF2::Utilities.attr_val(reference, 'cda:id/@...
ruby
def definition_for_nil_entry reference = @entry.at_xpath('./*/cda:outboundRelationship/cda:criteriaReference', HQMF2::Document::NAMESPACES) ref_id = nil unless reference.nil? ref_id = "#{HQMF2::Utilities.attr_val(reference, 'cda:id/@extension')}_#{HQMF2::Utilities.attr_val(reference, 'cda:id/@...
[ "def", "definition_for_nil_entry", "reference", "=", "@entry", ".", "at_xpath", "(", "'./*/cda:outboundRelationship/cda:criteriaReference'", ",", "HQMF2", "::", "Document", "::", "NAMESPACES", ")", "ref_id", "=", "nil", "unless", "reference", ".", "nil?", "ref_id", "=...
If there is no entry type, extract the entry type from what it references, and extract additional information for specific occurrences. If there are no outbound references, print an error and mark it as variable.
[ "If", "there", "is", "no", "entry", "type", "extract", "the", "entry", "type", "from", "what", "it", "references", "and", "extract", "additional", "information", "for", "specific", "occurrences", ".", "If", "there", "are", "no", "outbound", "references", "prin...
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/data_criteria_helpers/dc_definition_from_template_or_type_extract.rb#L132-L161
train
projectcypress/health-data-standards
lib/hqmf-parser/2.0/document_helpers/doc_utilities.rb
HQMF2.DocumentUtilities.handle_variable
def handle_variable(data_criteria, collapsed_source_data_criteria) if data_criteria.is_derived_specific_occurrence_variable data_criteria.handle_derived_specific_occurrence_variable extract_source_data_criteria(data_criteria) return end tmp_id = data_criteria.id groupe...
ruby
def handle_variable(data_criteria, collapsed_source_data_criteria) if data_criteria.is_derived_specific_occurrence_variable data_criteria.handle_derived_specific_occurrence_variable extract_source_data_criteria(data_criteria) return end tmp_id = data_criteria.id groupe...
[ "def", "handle_variable", "(", "data_criteria", ",", "collapsed_source_data_criteria", ")", "if", "data_criteria", ".", "is_derived_specific_occurrence_variable", "data_criteria", ".", "handle_derived_specific_occurrence_variable", "extract_source_data_criteria", "(", "data_criteria"...
Create grouper data criteria for encapsulating variable data criteria and update document data criteria list and references map
[ "Create", "grouper", "data", "criteria", "for", "encapsulating", "variable", "data", "criteria", "and", "update", "document", "data", "criteria", "list", "and", "references", "map" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/document_helpers/doc_utilities.rb#L6-L41
train
projectcypress/health-data-standards
lib/hqmf-parser/2.0/document_helpers/doc_utilities.rb
HQMF2.DocumentUtilities.complex_coverage
def complex_coverage(data_criteria, check_criteria) same_value = data_criteria.value.nil? || data_criteria.value.try(:to_model).try(:to_json) == check_criteria.value.try(:to_model).try(:to_json) same_field_values = same_field_values_check(data_criteria, check_criteria) same_negati...
ruby
def complex_coverage(data_criteria, check_criteria) same_value = data_criteria.value.nil? || data_criteria.value.try(:to_model).try(:to_json) == check_criteria.value.try(:to_model).try(:to_json) same_field_values = same_field_values_check(data_criteria, check_criteria) same_negati...
[ "def", "complex_coverage", "(", "data_criteria", ",", "check_criteria", ")", "same_value", "=", "data_criteria", ".", "value", ".", "nil?", "||", "data_criteria", ".", "value", ".", "try", "(", ":to_model", ")", ".", "try", "(", ":to_json", ")", "==", "check...
Check elements that do not already exist; else, if they do, check if those elements are the same in a different, potentially matching, data criteria
[ "Check", "elements", "that", "do", "not", "already", "exist", ";", "else", "if", "they", "do", "check", "if", "those", "elements", "are", "the", "same", "in", "a", "different", "potentially", "matching", "data", "criteria" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/document_helpers/doc_utilities.rb#L107-L117
train
projectcypress/health-data-standards
lib/hqmf-parser/2.0/data_criteria_helpers/dc_specific_occurrences_and_source_data_criteria_extract.rb
HQMF2.SpecificOccurrenceAndSource.handle_specific_and_source
def handle_specific_and_source(occurrence_identifier, source_data_criteria_extension, source_data_criteria_root, specific_occurrence_const, specific_occurrence) source_data_criteria = "#{source_data_criteria_extension}_#{source_data_criteria_root}_source" if !occurrence_id...
ruby
def handle_specific_and_source(occurrence_identifier, source_data_criteria_extension, source_data_criteria_root, specific_occurrence_const, specific_occurrence) source_data_criteria = "#{source_data_criteria_extension}_#{source_data_criteria_root}_source" if !occurrence_id...
[ "def", "handle_specific_and_source", "(", "occurrence_identifier", ",", "source_data_criteria_extension", ",", "source_data_criteria_root", ",", "specific_occurrence_const", ",", "specific_occurrence", ")", "source_data_criteria", "=", "\"#{source_data_criteria_extension}_#{source_data...
Handle setting the specific and source instance variables with a given occurrence identifier
[ "Handle", "setting", "the", "specific", "and", "source", "instance", "variables", "with", "a", "given", "occurrence", "identifier" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/data_criteria_helpers/dc_specific_occurrences_and_source_data_criteria_extract.rb#L52-L79
train
projectcypress/health-data-standards
lib/hqmf-parser/2.0/data_criteria.rb
HQMF2.DataCriteria.basic_setup
def basic_setup @status = attr_val('./*/cda:statusCode/@code') @id_xpath = './*/cda:id/@extension' @id = "#{attr_val('./*/cda:id/@extension')}_#{attr_val('./*/cda:id/@root')}" @comments = @entry.xpath("./#{CRITERIA_GLOB}/cda:text/cda:xml/cda:qdmUserComments/cda:item/text()", ...
ruby
def basic_setup @status = attr_val('./*/cda:statusCode/@code') @id_xpath = './*/cda:id/@extension' @id = "#{attr_val('./*/cda:id/@extension')}_#{attr_val('./*/cda:id/@root')}" @comments = @entry.xpath("./#{CRITERIA_GLOB}/cda:text/cda:xml/cda:qdmUserComments/cda:item/text()", ...
[ "def", "basic_setup", "@status", "=", "attr_val", "(", "'./*/cda:statusCode/@code'", ")", "@id_xpath", "=", "'./*/cda:id/@extension'", "@id", "=", "\"#{attr_val('./*/cda:id/@extension')}_#{attr_val('./*/cda:id/@root')}\"", "@comments", "=", "@entry", ".", "xpath", "(", "\"./#...
Handles elments that can be extracted directly from the xml. Utilises the "BaseExtractions" class.
[ "Handles", "elments", "that", "can", "be", "extracted", "directly", "from", "the", "xml", ".", "Utilises", "the", "BaseExtractions", "class", "." ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/data_criteria.rb#L184-L201
train
projectcypress/health-data-standards
lib/hqmf-parser/2.0/data_criteria.rb
HQMF2.DataCriteria.duplicate_child_info
def duplicate_child_info(child_ref) @title ||= child_ref.title @type ||= child_ref.subset_operators @definition ||= child_ref.definition @status ||= child_ref.status @code_list_id ||= child_ref.code_list_id @temporal_references = child_ref.temporal_references if @temporal_references....
ruby
def duplicate_child_info(child_ref) @title ||= child_ref.title @type ||= child_ref.subset_operators @definition ||= child_ref.definition @status ||= child_ref.status @code_list_id ||= child_ref.code_list_id @temporal_references = child_ref.temporal_references if @temporal_references....
[ "def", "duplicate_child_info", "(", "child_ref", ")", "@title", "||=", "child_ref", ".", "title", "@type", "||=", "child_ref", ".", "subset_operators", "@definition", "||=", "child_ref", ".", "definition", "@status", "||=", "child_ref", ".", "status", "@code_list_id...
Duplicates information from a child element to this data criteria if none exits. If the duplication requires that come values should be overwritten, do so only in the function calling this.
[ "Duplicates", "information", "from", "a", "child", "element", "to", "this", "data", "criteria", "if", "none", "exits", ".", "If", "the", "duplication", "requires", "that", "come", "values", "should", "be", "overwritten", "do", "so", "only", "in", "the", "fun...
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/data_criteria.rb#L233-L243
train
projectcypress/health-data-standards
lib/hqmf-parser/2.0/data_criteria.rb
HQMF2.DataCriteria.retrieve_field_values_model_for_model
def retrieve_field_values_model_for_model field_values = {} @field_values.each_pair do |id, val| field_values[id] = val.to_model end @code_list_id ||= code_list_id # Model transfers as a field if %w(transfer_to transfer_from).include? @definition field_code_list_id =...
ruby
def retrieve_field_values_model_for_model field_values = {} @field_values.each_pair do |id, val| field_values[id] = val.to_model end @code_list_id ||= code_list_id # Model transfers as a field if %w(transfer_to transfer_from).include? @definition field_code_list_id =...
[ "def", "retrieve_field_values_model_for_model", "field_values", "=", "{", "}", "@field_values", ".", "each_pair", "do", "|", "id", ",", "val", "|", "field_values", "[", "id", "]", "=", "val", ".", "to_model", "end", "@code_list_id", "||=", "code_list_id", "# Mod...
Generate the models of the field values
[ "Generate", "the", "models", "of", "the", "field", "values" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/data_criteria.rb#L246-L264
train
projectcypress/health-data-standards
lib/hqmf-parser/2.0/data_criteria.rb
HQMF2.DataCriteria.retrieve_title_and_description_for_model
def retrieve_title_and_description_for_model # drop "* Value Set" from titles exact_desc = title.split(' ')[0...-3].join(' ') # don't drop anything for patient characterstic titles exact_desc = title if @definition.start_with?('patient_characteristic') && !title.end_with?('Value Set') # r...
ruby
def retrieve_title_and_description_for_model # drop "* Value Set" from titles exact_desc = title.split(' ')[0...-3].join(' ') # don't drop anything for patient characterstic titles exact_desc = title if @definition.start_with?('patient_characteristic') && !title.end_with?('Value Set') # r...
[ "def", "retrieve_title_and_description_for_model", "# drop \"* Value Set\" from titles", "exact_desc", "=", "title", ".", "split", "(", "' '", ")", "[", "0", "...", "-", "3", "]", ".", "join", "(", "' '", ")", "# don't drop anything for patient characterstic titles", "e...
Generate the title and description used when producing the model
[ "Generate", "the", "title", "and", "description", "used", "when", "producing", "the", "model" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/data_criteria.rb#L267-L278
train
Shopify/doggy
lib/doggy/model.rb
Doggy.Model.save_local
def save_local ensure_read_only! self.path ||= Doggy.object_root.join("#{prefix}-#{id}.json") File.open(@path, 'w') { |f| f.write(JSON.pretty_generate(to_h)) } end
ruby
def save_local ensure_read_only! self.path ||= Doggy.object_root.join("#{prefix}-#{id}.json") File.open(@path, 'w') { |f| f.write(JSON.pretty_generate(to_h)) } end
[ "def", "save_local", "ensure_read_only!", "self", ".", "path", "||=", "Doggy", ".", "object_root", ".", "join", "(", "\"#{prefix}-#{id}.json\"", ")", "File", ".", "open", "(", "@path", ",", "'w'", ")", "{", "|", "f", "|", "f", ".", "write", "(", "JSON", ...
class << self
[ "class", "<<", "self" ]
5c5a08698925c26eb1118eae7a81a5ad39dc086f
https://github.com/Shopify/doggy/blob/5c5a08698925c26eb1118eae7a81a5ad39dc086f/lib/doggy/model.rb#L184-L188
train
chef/chef-zero
lib/chef_zero/server.rb
ChefZero.Server.url
def url sch = @options[:ssl] ? "https" : "http" hosts = Array(@options[:host]) @url ||= if hosts.first.include?(":") URI("#{sch}://[#{hosts.first}]:#{port}").to_s else URI("#{sch}://#{hosts.first}:#{port}").to_s end end
ruby
def url sch = @options[:ssl] ? "https" : "http" hosts = Array(@options[:host]) @url ||= if hosts.first.include?(":") URI("#{sch}://[#{hosts.first}]:#{port}").to_s else URI("#{sch}://#{hosts.first}:#{port}").to_s end end
[ "def", "url", "sch", "=", "@options", "[", ":ssl", "]", "?", "\"https\"", ":", "\"http\"", "hosts", "=", "Array", "(", "@options", "[", ":host", "]", ")", "@url", "||=", "if", "hosts", ".", "first", ".", "include?", "(", "\":\"", ")", "URI", "(", "...
The URL for this Chef Zero server. If the given host is an IPV6 address, it is escaped in brackets according to RFC-2732. @see http://www.ietf.org/rfc/rfc2732.txt RFC-2732 @return [String]
[ "The", "URL", "for", "this", "Chef", "Zero", "server", ".", "If", "the", "given", "host", "is", "an", "IPV6", "address", "it", "is", "escaped", "in", "brackets", "according", "to", "RFC", "-", "2732", "." ]
5873d906942770a34f0cf0fed05973ec3240a275
https://github.com/chef/chef-zero/blob/5873d906942770a34f0cf0fed05973ec3240a275/lib/chef_zero/server.rb#L167-L175
train
chef/chef-zero
lib/chef_zero/server.rb
ChefZero.Server.listen
def listen(hosts, port) hosts.each do |host| @server.listen(host, port) end true rescue Errno::EADDRINUSE ChefZero::Log.warn("Port #{port} not available") @server.listeners.each { |l| l.close } @server.listeners.clear false end
ruby
def listen(hosts, port) hosts.each do |host| @server.listen(host, port) end true rescue Errno::EADDRINUSE ChefZero::Log.warn("Port #{port} not available") @server.listeners.each { |l| l.close } @server.listeners.clear false end
[ "def", "listen", "(", "hosts", ",", "port", ")", "hosts", ".", "each", "do", "|", "host", "|", "@server", ".", "listen", "(", "host", ",", "port", ")", "end", "true", "rescue", "Errno", "::", "EADDRINUSE", "ChefZero", "::", "Log", ".", "warn", "(", ...
Start a Chef Zero server in a forked process. This method returns the PID to the forked process. @param [Fixnum] wait the number of seconds to wait for the server to start @return [Thread] the thread the background process is running in
[ "Start", "a", "Chef", "Zero", "server", "in", "a", "forked", "process", ".", "This", "method", "returns", "the", "PID", "to", "the", "forked", "process", "." ]
5873d906942770a34f0cf0fed05973ec3240a275
https://github.com/chef/chef-zero/blob/5873d906942770a34f0cf0fed05973ec3240a275/lib/chef_zero/server.rb#L270-L280
train
chef/chef-zero
lib/chef_zero/server.rb
ChefZero.Server.stop
def stop(wait = 5) if @running @server.shutdown if @server @thread.join(wait) if @thread end rescue Timeout::Error if @thread ChefZero::Log.error("Chef Zero did not stop within #{wait} seconds! Killing...") @thread.kill SocketlessServerMap.deregister(port) ...
ruby
def stop(wait = 5) if @running @server.shutdown if @server @thread.join(wait) if @thread end rescue Timeout::Error if @thread ChefZero::Log.error("Chef Zero did not stop within #{wait} seconds! Killing...") @thread.kill SocketlessServerMap.deregister(port) ...
[ "def", "stop", "(", "wait", "=", "5", ")", "if", "@running", "@server", ".", "shutdown", "if", "@server", "@thread", ".", "join", "(", "wait", ")", "if", "@thread", "end", "rescue", "Timeout", "::", "Error", "if", "@thread", "ChefZero", "::", "Log", "....
Gracefully stop the Chef Zero server. @param [Fixnum] wait the number of seconds to wait before raising force-terminating the server
[ "Gracefully", "stop", "the", "Chef", "Zero", "server", "." ]
5873d906942770a34f0cf0fed05973ec3240a275
https://github.com/chef/chef-zero/blob/5873d906942770a34f0cf0fed05973ec3240a275/lib/chef_zero/server.rb#L358-L372
train
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) en...
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) en...
[ "def", "json_response", "(", "response_code", ",", "data", ",", "options", "=", "{", "}", ")", "options", "=", "{", "pretty", ":", "true", "}", ".", "merge", "(", "options", ")", "do_pretty_json", "=", "!", "!", "options", ".", "delete", "(", ":pretty"...
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 [Boole...
[ "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
train
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_versi...
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_versi...
[ "def", "already_json_response", "(", "response_code", ",", "json_text", ",", "options", "=", "{", "}", ")", "version_header", "=", "FFI_Yajl", "::", "Encoder", ".", "encode", "(", "\"min_version\"", "=>", "MIN_API_VERSION", ".", "to_s", ",", "\"max_version\"", "...
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] :reque...
[ "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
train
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" e...
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" e...
[ "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\"", ",", "...
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
train
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", ")", "|", "...
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
train
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::Thr...
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::Thr...
[ "def", "async_state", "(", "handles", ")", "response", "=", "@client", ".", "GetOperationStatus", "(", "Hive2", "::", "Thrift", "::", "TGetOperationStatusReq", ".", "new", "(", "operationHandle", ":", "prepare_operation_handle", "(", "handles", ")", ")", ")", "c...
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
train
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) ...
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) ...
[ "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", "fetc...
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
train
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, TCLISchemaDef...
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, TCLISchemaDef...
[ "def", "fetch_rows", "(", "op_handle", ",", "orientation", "=", ":first", ",", "max_rows", "=", "1000", ")", "fetch_req", "=", "prepare_fetch_results", "(", "op_handle", ",", "orientation", ",", "max_rows", ")", "fetch_results", "=", "@client", ".", "FetchResult...
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
train
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", "::", "TCLIConnectionErr...
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
train
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...
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...
[ "def", "parse_options", "(", "args", ")", "config", "=", "{", "}", "deprecated_args", "=", "[", "]", "flag", "=", "/", "/", "args", ".", "size", ".", "times", "do", "break", "if", "args", ".", "empty?", "peek", "=", "args", ".", "first", "next", "u...
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
train
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("...
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("...
[ "def", "line_formatter", "(", "array", ")", "if", "array", ".", "any?", "{", "|", "item", "|", "item", ".", "is_a?", "(", "Array", ")", "}", "cols", "=", "[", "]", "array", ".", "each", "do", "|", "item", "|", "if", "item", ".", "is_a?", "(", "...
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
train
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?", "(...
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
train
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
train
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
train
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
train
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", ...
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 ...
[ "Serialize", "your", "workbook", "to", "disk", "as", "an", "xlsx", "document", "." ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/package.rb#L101-L108
train
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", "::", "OutputStrea...
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
train
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[:p...
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[:p...
[ "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", ...
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
train
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...
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...
[ "def", "parts", "parts", "=", "[", "{", ":entry", "=>", "RELS_PN", ",", ":doc", "=>", "relationships", ",", ":schema", "=>", "RELS_XSD", "}", ",", "{", ":entry", "=>", "\"xl/#{STYLES_PN}\"", ",", ":doc", "=>", "workbook", ".", "styles", ",", ":schema", "...
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
train
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", "=", "[", "]", ...
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
train
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.n...
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.n...
[ "def", "content_types", "c_types", "=", "base_content_types", "workbook", ".", "drawings", ".", "each", "do", "|", "drawing", "|", "c_types", "<<", "Axlsx", "::", "Override", ".", "new", "(", ":PartName", "=>", "\"/xl/#{drawing.pn}\"", ",", ":ContentType", "=>",...
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
train
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(...
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(...
[ "def", "base_content_types", "c_types", "=", "ContentType", ".", "new", "(", ")", "c_types", "<<", "Default", ".", "new", "(", ":ContentType", "=>", "RELS_CT", ",", ":Extension", "=>", "RELS_EX", ")", "c_types", "<<", "Default", ".", "new", "(", ":Extension"...
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
train
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", ",", ...
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
train
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", "(", "\"...
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
train
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
train
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",...
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
train
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",...
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
train
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", ")",...
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
train
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", ...
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 def...
[ "creates", "a", "new", "ColorScale", "object", "." ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/color_scale.rb#L70-L74
train
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", "<<", ...
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
train
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.si...
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.si...
[ "def", "initialize_default_cfvos", "(", "user_cfvos", ")", "defaults", "=", "self", ".", "class", ".", "default_cfvos", "user_cfvos", ".", "each_with_index", "do", "|", "cfvo", ",", "index", "|", "if", "index", "<", "defaults", ".", "size", "cfvo", "=", "def...
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
train
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
train
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 ...
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 ...
[ "def", "to_xml_string", "(", "str", "=", "''", ")", "Axlsx", "::", "sanitize", "(", "@shared_xml_string", ")", "str", "<<", "(", "'<?xml version=\"1.0\" encoding=\"UTF-8\"?><sst xmlns=\"'", "<<", "XML_NS", "<<", "'\"'", ")", "str", "<<", "(", "' count=\"'", "<<", ...
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
train
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...
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...
[ "def", "resolve", "(", "cells", ")", "cells", ".", "each", "do", "|", "cell", "|", "cell_hash", "=", "cell", ".", "value", "if", "index", "=", "@unique_cells", "[", "cell_hash", "]", "cell", ".", "send", ":ssti=", ",", "index", "else", "cell", ".", "...
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 c...
[ "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", ...
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/shared_strings_table.rb#L63-L75
train
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
train
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
train
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", ")", "@works...
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...
[ "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", "co...
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/workbook.rb#L263-L269
train
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, PI...
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, PI...
[ "def", "relationships", "r", "=", "Relationships", ".", "new", "@worksheets", ".", "each", "do", "|", "sheet", "|", "r", "<<", "Relationship", ".", "new", "(", "sheet", ",", "WORKSHEET_R", ",", "WORKSHEET_PN", "%", "(", "r", ".", "size", "+", "1", ")",...
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
train
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", ...
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. ...
[ "returns", "a", "range", "of", "cells", "in", "a", "worksheet" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/workbook.rb#L344-L349
train
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(s...
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(s...
[ "def", "to_xml_string", "(", "str", "=", "''", ")", "add_worksheet", "(", "name", ":", "'Sheet1'", ")", "unless", "worksheets", ".", "size", ">", "0", "str", "<<", "'<?xml version=\"1.0\" encoding=\"UTF-8\"?>'", "str", "<<", "(", "'<workbook xmlns=\"'", "<<", "X...
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
train
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}=...
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
train
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
train
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", "...
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
train
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_gi...
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_gi...
[ "def", "add_comment", "(", "options", "=", "{", "}", ")", "raise", "ArgumentError", ",", "\"Comment require an author\"", "unless", "options", "[", ":author", "]", "raise", "ArgumentError", ",", "\"Comment requires text\"", "unless", "options", "[", ":text", "]", ...
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...
[ "Creates", "a", "new", "Comments", "object" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/comments.rb#L41-L48
train
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 ...
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 ...
[ "def", "autowidth", "(", "widtharray", ")", "return", "if", "value", ".", "nil?", "if", "styles", ".", "cellXfs", "[", "style", "]", ".", "alignment", "&&", "styles", ".", "cellXfs", "[", "style", "]", ".", "alignment", ".", "wrap_text", "first", "=", ...
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
train
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 ...
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 ...
[ "def", "to_xml_string", "(", "str", "=", "''", ")", "valid", "=", "RichTextRun", "::", "INLINE_STYLES", "data", "=", "Hash", "[", "self", ".", "instance_values", ".", "map", "{", "|", "k", ",", "v", "|", "[", "k", ".", "to_sym", ",", "v", "]", "}",...
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
train
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
train
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?", ...
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", ...
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/rich_text_run.rb#L224-L228
train
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
train
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", ")", "<<", "'=\"'", ...
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
train
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
train
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", "...
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
train
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(PACKI...
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(PACKI...
[ "def", "to_s", "data", "=", "[", "@name", ".", "concat", "(", "Array", ".", "new", "(", "32", "-", "@name", ".", "size", ",", "0", ")", ")", ",", "@name_size", ",", "@type", ",", "@color", ",", "@left", ",", "@right", ",", "@child", ",", "@create...
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
train
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
train
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
train
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", "<<", "'<...
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
train
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
train
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
train
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", "("...
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 @...
[ "Serializes", "the", "conditional", "formatting", "element" ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/conditional_formatting.rb#L76-L80
train
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
train
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...
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
train
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 = He...
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 = He...
[ "def", "initialize_page_options", "(", "options", ")", "@page_margins", "=", "PageMargins", ".", "new", "options", "[", ":page_margins", "]", "if", "options", "[", ":page_margins", "]", "@page_setup", "=", "PageSetup", ".", "new", "options", "[", ":page_setup", ...
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
train
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/exam...
[ "Add", "conditional", "formatting", "to", "this", "worksheet", "." ]
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/worksheet.rb#L419-L424
train
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
train
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 o...
[ "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...
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/worksheet.rb#L458-L462
train
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", "fi...
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 t...
[ "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",...
c593a08b2a929dac7aa8dc418b55e26b4c49dc34
https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/worksheet.rb#L515-L521
train
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", "{",...
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 ...
[ "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
train
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", "{", ...
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 ...
[ "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
train
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=\"'", "<<"...
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
train
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>' ...
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>' ...
[ "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"...
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
train
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_table...
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
train
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
train
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 Th...
[ "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
train
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]...
[ "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
train
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_...
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
train