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
sequence | docstring
stringlengths 8
16k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 94
266
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/matrix.rb | OoxmlParser.Matrix.parse | def parse(node)
columns_count = 1
j = 0
node.xpath('m:mPr').each do |m_pr|
m_pr.xpath('m:mcs').each do |mcs|
mcs.xpath('m:mc').each do |mc|
mc.xpath('m:mcPr').each do |mc_pr|
mc_pr.xpath('m:count').each do |count|
columns_count = count.attribute('val').value.to_i
end
end
end
end
end
node.xpath('m:mr').each do |mr|
i = 0
@rows << MatrixRow.new(columns_count, parent: self)
mr.xpath('m:e').each do |e|
@rows[j].columns[i] = DocxFormula.new(parent: self).parse(e)
i += 1
end
j += 1
end
self
end | ruby | def parse(node)
columns_count = 1
j = 0
node.xpath('m:mPr').each do |m_pr|
m_pr.xpath('m:mcs').each do |mcs|
mcs.xpath('m:mc').each do |mc|
mc.xpath('m:mcPr').each do |mc_pr|
mc_pr.xpath('m:count').each do |count|
columns_count = count.attribute('val').value.to_i
end
end
end
end
end
node.xpath('m:mr').each do |mr|
i = 0
@rows << MatrixRow.new(columns_count, parent: self)
mr.xpath('m:e').each do |e|
@rows[j].columns[i] = DocxFormula.new(parent: self).parse(e)
i += 1
end
j += 1
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"columns_count",
"=",
"1",
"j",
"=",
"0",
"node",
".",
"xpath",
"(",
"'m:mPr'",
")",
".",
"each",
"do",
"|",
"m_pr",
"|",
"m_pr",
".",
"xpath",
"(",
"'m:mcs'",
")",
".",
"each",
"do",
"|",
"mcs",
"|",
"mcs",
".",
"xpath",
"(",
"'m:mc'",
")",
".",
"each",
"do",
"|",
"mc",
"|",
"mc",
".",
"xpath",
"(",
"'m:mcPr'",
")",
".",
"each",
"do",
"|",
"mc_pr",
"|",
"mc_pr",
".",
"xpath",
"(",
"'m:count'",
")",
".",
"each",
"do",
"|",
"count",
"|",
"columns_count",
"=",
"count",
".",
"attribute",
"(",
"'val'",
")",
".",
"value",
".",
"to_i",
"end",
"end",
"end",
"end",
"end",
"node",
".",
"xpath",
"(",
"'m:mr'",
")",
".",
"each",
"do",
"|",
"mr",
"|",
"i",
"=",
"0",
"@rows",
"<<",
"MatrixRow",
".",
"new",
"(",
"columns_count",
",",
"parent",
":",
"self",
")",
"mr",
".",
"xpath",
"(",
"'m:e'",
")",
".",
"each",
"do",
"|",
"e",
"|",
"@rows",
"[",
"j",
"]",
".",
"columns",
"[",
"i",
"]",
"=",
"DocxFormula",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"e",
")",
"i",
"+=",
"1",
"end",
"j",
"+=",
"1",
"end",
"self",
"end"
] | Parse Matrix object
@param node [Nokogiri::XML:Element] node to parse
@return [Matrix] result of parsing | [
"Parse",
"Matrix",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/matrix.rb#L15-L41 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/sdt/sdt_properties.rb | OoxmlParser.SDTProperties.parse | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'alias'
@alias = ValuedChild.new(:string, parent: self).parse(node_child)
when 'tag'
@tag = ValuedChild.new(:string, parent: self).parse(node_child)
when 'lock'
@lock = ValuedChild.new(:symbol, parent: self).parse(node_child)
end
end
self
end | ruby | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'alias'
@alias = ValuedChild.new(:string, parent: self).parse(node_child)
when 'tag'
@tag = ValuedChild.new(:string, parent: self).parse(node_child)
when 'lock'
@lock = ValuedChild.new(:symbol, parent: self).parse(node_child)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'alias'",
"@alias",
"=",
"ValuedChild",
".",
"new",
"(",
":string",
",",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'tag'",
"@tag",
"=",
"ValuedChild",
".",
"new",
"(",
":string",
",",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'lock'",
"@lock",
"=",
"ValuedChild",
".",
"new",
"(",
":symbol",
",",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] | Parse SDTProperties object
@param node [Nokogiri::XML:Element] node to parse
@return [SDTProperties] result of parsing | [
"Parse",
"SDTProperties",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/sdt/sdt_properties.rb#L14-L26 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/text_body.rb | OoxmlParser.TextBody.parse | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'p'
@paragraphs << Paragraph.new(parent: self).parse(node_child)
when 'bodyPr'
@properties = OOXMLShapeBodyProperties.new(parent: self).parse(node_child)
end
end
self
end | ruby | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'p'
@paragraphs << Paragraph.new(parent: self).parse(node_child)
when 'bodyPr'
@properties = OOXMLShapeBodyProperties.new(parent: self).parse(node_child)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'p'",
"@paragraphs",
"<<",
"Paragraph",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'bodyPr'",
"@properties",
"=",
"OOXMLShapeBodyProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] | Parse TextBody object
@param node [Nokogiri::XML:Element] node to parse
@return [TextBody] result of parsing | [
"Parse",
"TextBody",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/text_body.rb#L14-L24 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/animation_effect/animation_effect.rb | OoxmlParser.AnimationEffect.parse | def parse(node)
node.attributes.each do |key, value|
case key
when 'transition'
@transition = value.value
when 'filter'
@filter = value.value
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'cBhvr'
@behavior = Behavior.new(parent: self).parse(node_child)
end
end
self
end | ruby | def parse(node)
node.attributes.each do |key, value|
case key
when 'transition'
@transition = value.value
when 'filter'
@filter = value.value
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'cBhvr'
@behavior = Behavior.new(parent: self).parse(node_child)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'transition'",
"@transition",
"=",
"value",
".",
"value",
"when",
"'filter'",
"@filter",
"=",
"value",
".",
"value",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'cBhvr'",
"@behavior",
"=",
"Behavior",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] | Parse AnimationEffect object
@param node [Nokogiri::XML:Element] node to parse
@return [AnimationEffect] result of parsing | [
"Parse",
"AnimationEffect",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/animation_effect/animation_effect.rb#L8-L25 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/xf.rb | OoxmlParser.Xf.parse | def parse(node)
node.attributes.each do |key, value|
case key
when 'applyFont'
@apply_font = attribute_enabled?(value)
when 'applyBorder'
@apply_border = attribute_enabled?(value)
when 'applyFill'
@apply_fill = attribute_enabled?(value)
when 'applyNumberFormat'
@apply_number_format = attribute_enabled?(value)
when 'applyAlignment'
@apply_alignment = attribute_enabled?(value)
when 'fontId'
@font_id = value.value.to_i
when 'borderId'
@border_id = value.value.to_i
when 'fillId'
@fill_id = value.value.to_i
when 'numFmtId'
@number_format_id = value.value.to_i
when 'quotePrefix'
@quote_prefix = attribute_enabled?(value)
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'alignment'
@alignment.parse(node_child) if @apply_alignment
end
end
self
end | ruby | def parse(node)
node.attributes.each do |key, value|
case key
when 'applyFont'
@apply_font = attribute_enabled?(value)
when 'applyBorder'
@apply_border = attribute_enabled?(value)
when 'applyFill'
@apply_fill = attribute_enabled?(value)
when 'applyNumberFormat'
@apply_number_format = attribute_enabled?(value)
when 'applyAlignment'
@apply_alignment = attribute_enabled?(value)
when 'fontId'
@font_id = value.value.to_i
when 'borderId'
@border_id = value.value.to_i
when 'fillId'
@fill_id = value.value.to_i
when 'numFmtId'
@number_format_id = value.value.to_i
when 'quotePrefix'
@quote_prefix = attribute_enabled?(value)
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'alignment'
@alignment.parse(node_child) if @apply_alignment
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'applyFont'",
"@apply_font",
"=",
"attribute_enabled?",
"(",
"value",
")",
"when",
"'applyBorder'",
"@apply_border",
"=",
"attribute_enabled?",
"(",
"value",
")",
"when",
"'applyFill'",
"@apply_fill",
"=",
"attribute_enabled?",
"(",
"value",
")",
"when",
"'applyNumberFormat'",
"@apply_number_format",
"=",
"attribute_enabled?",
"(",
"value",
")",
"when",
"'applyAlignment'",
"@apply_alignment",
"=",
"attribute_enabled?",
"(",
"value",
")",
"when",
"'fontId'",
"@font_id",
"=",
"value",
".",
"value",
".",
"to_i",
"when",
"'borderId'",
"@border_id",
"=",
"value",
".",
"value",
".",
"to_i",
"when",
"'fillId'",
"@fill_id",
"=",
"value",
".",
"value",
".",
"to_i",
"when",
"'numFmtId'",
"@number_format_id",
"=",
"value",
".",
"value",
".",
"to_i",
"when",
"'quotePrefix'",
"@quote_prefix",
"=",
"attribute_enabled?",
"(",
"value",
")",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'alignment'",
"@alignment",
".",
"parse",
"(",
"node_child",
")",
"if",
"@apply_alignment",
"end",
"end",
"self",
"end"
] | Parse Xf object
@param node [Nokogiri::XML:Element] node to parse
@return [Xf] result of parsing | [
"Parse",
"Xf",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/xf.rb#L86-L118 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view/pane.rb | OoxmlParser.Pane.parse | def parse(node)
node.attributes.each do |key, value|
case key
when 'state'
@state = value.value.to_sym
when 'topLeftCell'
@top_left_cell = Coordinates.parse_coordinates_from_string(value.value)
when 'xSplit'
@x_split = value.value
when 'ySplit'
@y_split = value.value
end
end
self
end | ruby | def parse(node)
node.attributes.each do |key, value|
case key
when 'state'
@state = value.value.to_sym
when 'topLeftCell'
@top_left_cell = Coordinates.parse_coordinates_from_string(value.value)
when 'xSplit'
@x_split = value.value
when 'ySplit'
@y_split = value.value
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'state'",
"@state",
"=",
"value",
".",
"value",
".",
"to_sym",
"when",
"'topLeftCell'",
"@top_left_cell",
"=",
"Coordinates",
".",
"parse_coordinates_from_string",
"(",
"value",
".",
"value",
")",
"when",
"'xSplit'",
"@x_split",
"=",
"value",
".",
"value",
"when",
"'ySplit'",
"@y_split",
"=",
"value",
".",
"value",
"end",
"end",
"self",
"end"
] | Parse Pane object
@param node [Nokogiri::XML:Element] node to parse
@return [Pane] result of parsing | [
"Parse",
"Pane",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view/pane.rb#L9-L23 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_comments/presentation_comment.rb | OoxmlParser.PresentationComment.parse | def parse(node)
node.attributes.each do |key, value|
case key
when 'authorId'
@author_id = value.value.to_i
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'pos'
@position = OOXMLCoordinates.parse(node_child, x_attr: 'x', y_attr: 'y')
when 'text'
@text = node_child.text.to_s
end
end
self
end | ruby | def parse(node)
node.attributes.each do |key, value|
case key
when 'authorId'
@author_id = value.value.to_i
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'pos'
@position = OOXMLCoordinates.parse(node_child, x_attr: 'x', y_attr: 'y')
when 'text'
@text = node_child.text.to_s
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'authorId'",
"@author_id",
"=",
"value",
".",
"value",
".",
"to_i",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'pos'",
"@position",
"=",
"OOXMLCoordinates",
".",
"parse",
"(",
"node_child",
",",
"x_attr",
":",
"'x'",
",",
"y_attr",
":",
"'y'",
")",
"when",
"'text'",
"@text",
"=",
"node_child",
".",
"text",
".",
"to_s",
"end",
"end",
"self",
"end"
] | Parse PresentationComment object
@param node [Nokogiri::XML:Element] node to parse
@return [PresentationComment] result of parsing | [
"Parse",
"PresentationComment",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_comments/presentation_comment.rb#L19-L35 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/common_parser/common_data/table/properties/table_style_properties/table_style_properties_helper.rb | OoxmlParser.TableStylePropertiesHelper.fill_empty_table_styles | def fill_empty_table_styles
TABLE_STYLES_NAMES_HASH.each_value do |current_table_style|
style_exist = false
@table_style_properties_list.each do |existing_style|
style_exist = true if existing_style.type == current_table_style
end
next if style_exist
@table_style_properties_list << TableStyleProperties.new(type: current_table_style)
end
end | ruby | def fill_empty_table_styles
TABLE_STYLES_NAMES_HASH.each_value do |current_table_style|
style_exist = false
@table_style_properties_list.each do |existing_style|
style_exist = true if existing_style.type == current_table_style
end
next if style_exist
@table_style_properties_list << TableStyleProperties.new(type: current_table_style)
end
end | [
"def",
"fill_empty_table_styles",
"TABLE_STYLES_NAMES_HASH",
".",
"each_value",
"do",
"|",
"current_table_style",
"|",
"style_exist",
"=",
"false",
"@table_style_properties_list",
".",
"each",
"do",
"|",
"existing_style",
"|",
"style_exist",
"=",
"true",
"if",
"existing_style",
".",
"type",
"==",
"current_table_style",
"end",
"next",
"if",
"style_exist",
"@table_style_properties_list",
"<<",
"TableStyleProperties",
".",
"new",
"(",
"type",
":",
"current_table_style",
")",
"end",
"end"
] | Fill all empty tables styles with default value
To make last changes in parsing table styles compatible
with `ooxml_parser` 0.1.2 and earlier
@return [Nothing] | [
"Fill",
"all",
"empty",
"tables",
"styles",
"with",
"default",
"value",
"To",
"make",
"last",
"changes",
"in",
"parsing",
"table",
"styles",
"compatible",
"with",
"ooxml_parser",
"0",
".",
"1",
".",
"2",
"and",
"earlier"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/table/properties/table_style_properties/table_style_properties_helper.rb#L31-L41 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/autofilter/filter_column.rb | OoxmlParser.FilterColumn.parse | def parse(node)
node.attributes.each do |key, value|
case key
when 'showButton'
@show_button = attribute_enabled?(value)
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'customFilters'
@custom_filters = CustomFilters.new(parent: self).parse(node_child)
end
end
self
end | ruby | def parse(node)
node.attributes.each do |key, value|
case key
when 'showButton'
@show_button = attribute_enabled?(value)
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'customFilters'
@custom_filters = CustomFilters.new(parent: self).parse(node_child)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'showButton'",
"@show_button",
"=",
"attribute_enabled?",
"(",
"value",
")",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'customFilters'",
"@custom_filters",
"=",
"CustomFilters",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] | Parse FilterColumn data
@param [Nokogiri::XML:Element] node with FilterColumn data
@return [FilterColumn] value of FilterColumn data | [
"Parse",
"FilterColumn",
"data"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/autofilter/filter_column.rb#L21-L36 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/common_parser/common_data/table/row/cell/cell.rb | OoxmlParser.TableCell.parse | def parse(node)
node.attributes.each do |key, value|
case key
when 'gridSpan'
@grid_span = value.value.to_i
when 'hMerge'
@horizontal_merge = value.value.to_i
when 'vMerge'
@vertical_merge = value.value.to_i
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'txBody'
@text_body = TextBody.new(parent: self).parse(node_child)
when 'tcPr'
@properties = CellProperties.new(parent: self).parse(node_child)
when 'p'
@elements << DocumentStructure.default_table_paragraph_style.dup.parse(node_child,
0,
DocumentStructure.default_table_run_style,
parent: self)
when 'sdt'
@elements << StructuredDocumentTag.new(parent: self).parse(node_child)
when 'tbl'
@elements << Table.new(parent: self).parse(node_child)
end
end
self
end | ruby | def parse(node)
node.attributes.each do |key, value|
case key
when 'gridSpan'
@grid_span = value.value.to_i
when 'hMerge'
@horizontal_merge = value.value.to_i
when 'vMerge'
@vertical_merge = value.value.to_i
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'txBody'
@text_body = TextBody.new(parent: self).parse(node_child)
when 'tcPr'
@properties = CellProperties.new(parent: self).parse(node_child)
when 'p'
@elements << DocumentStructure.default_table_paragraph_style.dup.parse(node_child,
0,
DocumentStructure.default_table_run_style,
parent: self)
when 'sdt'
@elements << StructuredDocumentTag.new(parent: self).parse(node_child)
when 'tbl'
@elements << Table.new(parent: self).parse(node_child)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'gridSpan'",
"@grid_span",
"=",
"value",
".",
"value",
".",
"to_i",
"when",
"'hMerge'",
"@horizontal_merge",
"=",
"value",
".",
"value",
".",
"to_i",
"when",
"'vMerge'",
"@vertical_merge",
"=",
"value",
".",
"value",
".",
"to_i",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'txBody'",
"@text_body",
"=",
"TextBody",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'tcPr'",
"@properties",
"=",
"CellProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'p'",
"@elements",
"<<",
"DocumentStructure",
".",
"default_table_paragraph_style",
".",
"dup",
".",
"parse",
"(",
"node_child",
",",
"0",
",",
"DocumentStructure",
".",
"default_table_run_style",
",",
"parent",
":",
"self",
")",
"when",
"'sdt'",
"@elements",
"<<",
"StructuredDocumentTag",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'tbl'",
"@elements",
"<<",
"Table",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] | Parse TableCell object
@param node [Nokogiri::XML:Element] node to parse
@return [TableCell] result of parsing | [
"Parse",
"TableCell",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/table/row/cell/cell.rb#L18-L48 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/delimeter.rb | OoxmlParser.Delimiter.parse | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'dPr'
node_child.xpath('*').each do |node_child_child|
case node_child_child.name
when 'begChr'
@begin_character = ValuedChild.new(:string, parent: self).parse(node_child_child)
when 'endChr'
@end_character = ValuedChild.new(:string, parent: self).parse(node_child_child)
end
end
end
end
@value = DocxFormula.new(parent: self).parse(node)
self
end | ruby | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'dPr'
node_child.xpath('*').each do |node_child_child|
case node_child_child.name
when 'begChr'
@begin_character = ValuedChild.new(:string, parent: self).parse(node_child_child)
when 'endChr'
@end_character = ValuedChild.new(:string, parent: self).parse(node_child_child)
end
end
end
end
@value = DocxFormula.new(parent: self).parse(node)
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'dPr'",
"node_child",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child_child",
"|",
"case",
"node_child_child",
".",
"name",
"when",
"'begChr'",
"@begin_character",
"=",
"ValuedChild",
".",
"new",
"(",
":string",
",",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child_child",
")",
"when",
"'endChr'",
"@end_character",
"=",
"ValuedChild",
".",
"new",
"(",
":string",
",",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child_child",
")",
"end",
"end",
"end",
"end",
"@value",
"=",
"DocxFormula",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node",
")",
"self",
"end"
] | Parse Delimiter object
@param node [Nokogiri::XML:Element] node to parse
@return [Delimiter] result of parsing | [
"Parse",
"Delimiter",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/delimeter.rb#L15-L31 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_axis.rb | OoxmlParser.ChartAxis.parse | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'delete'
@display = false if node_child.attribute('val').value == '1'
when 'title'
@title = ChartAxisTitle.new(parent: self).parse(node_child)
when 'majorGridlines'
@major_grid_lines = true
when 'minorGridlines'
@minor_grid_lines = true
when 'scaling'
@scaling = Scaling.new(parent: self).parse(node_child)
when 'tickLblPos'
@tick_label_position = ValuedChild.new(:symbol, parent: self).parse(node_child)
when 'axPos'
@position = value_to_symbol(node_child.attribute('val'))
end
end
@display = false unless @title.visible?
self
end | ruby | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'delete'
@display = false if node_child.attribute('val').value == '1'
when 'title'
@title = ChartAxisTitle.new(parent: self).parse(node_child)
when 'majorGridlines'
@major_grid_lines = true
when 'minorGridlines'
@minor_grid_lines = true
when 'scaling'
@scaling = Scaling.new(parent: self).parse(node_child)
when 'tickLblPos'
@tick_label_position = ValuedChild.new(:symbol, parent: self).parse(node_child)
when 'axPos'
@position = value_to_symbol(node_child.attribute('val'))
end
end
@display = false unless @title.visible?
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'delete'",
"@display",
"=",
"false",
"if",
"node_child",
".",
"attribute",
"(",
"'val'",
")",
".",
"value",
"==",
"'1'",
"when",
"'title'",
"@title",
"=",
"ChartAxisTitle",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'majorGridlines'",
"@major_grid_lines",
"=",
"true",
"when",
"'minorGridlines'",
"@minor_grid_lines",
"=",
"true",
"when",
"'scaling'",
"@scaling",
"=",
"Scaling",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'tickLblPos'",
"@tick_label_position",
"=",
"ValuedChild",
".",
"new",
"(",
":symbol",
",",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'axPos'",
"@position",
"=",
"value_to_symbol",
"(",
"node_child",
".",
"attribute",
"(",
"'val'",
")",
")",
"end",
"end",
"@display",
"=",
"false",
"unless",
"@title",
".",
"visible?",
"self",
"end"
] | Parse ChartAxis object
@param node [Nokogiri::XML:Element] node to parse
@return [ChartAxis] result of parsing | [
"Parse",
"ChartAxis",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_axis.rb#L27-L48 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb | OoxmlParser.ChartLegend.parse | def parse(node)
node.xpath('*').each do |child_node|
case child_node.name
when 'legendPos'
@position = value_to_symbol(child_node.attribute('val'))
when 'overlay'
@overlay = true if child_node.attribute('val').value.to_s == '1'
end
end
self
end | ruby | def parse(node)
node.xpath('*').each do |child_node|
case child_node.name
when 'legendPos'
@position = value_to_symbol(child_node.attribute('val'))
when 'overlay'
@overlay = true if child_node.attribute('val').value.to_s == '1'
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"child_node",
"|",
"case",
"child_node",
".",
"name",
"when",
"'legendPos'",
"@position",
"=",
"value_to_symbol",
"(",
"child_node",
".",
"attribute",
"(",
"'val'",
")",
")",
"when",
"'overlay'",
"@overlay",
"=",
"true",
"if",
"child_node",
".",
"attribute",
"(",
"'val'",
")",
".",
"value",
".",
"to_s",
"==",
"'1'",
"end",
"end",
"self",
"end"
] | Parse ChartLegend object
@param node [Nokogiri::XML:Element] node to parse
@return [ChartLegend] result of parsing | [
"Parse",
"ChartLegend",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb#L27-L37 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_comments.rb | OoxmlParser.PresentationComments.parse | def parse(file = "#{OOXMLDocumentObject.path_to_folder}/#{OOXMLDocumentObject.root_subfolder}/comments/comment1.xml")
return nil unless File.exist?(file)
document = parse_xml(File.open(file))
node = document.xpath('*').first
node.xpath('*').each do |node_child|
case node_child.name
when 'cm'
@list << PresentationComment.new(parent: self).parse(node_child)
end
end
self
end | ruby | def parse(file = "#{OOXMLDocumentObject.path_to_folder}/#{OOXMLDocumentObject.root_subfolder}/comments/comment1.xml")
return nil unless File.exist?(file)
document = parse_xml(File.open(file))
node = document.xpath('*').first
node.xpath('*').each do |node_child|
case node_child.name
when 'cm'
@list << PresentationComment.new(parent: self).parse(node_child)
end
end
self
end | [
"def",
"parse",
"(",
"file",
"=",
"\"#{OOXMLDocumentObject.path_to_folder}/#{OOXMLDocumentObject.root_subfolder}/comments/comment1.xml\"",
")",
"return",
"nil",
"unless",
"File",
".",
"exist?",
"(",
"file",
")",
"document",
"=",
"parse_xml",
"(",
"File",
".",
"open",
"(",
"file",
")",
")",
"node",
"=",
"document",
".",
"xpath",
"(",
"'*'",
")",
".",
"first",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'cm'",
"@list",
"<<",
"PresentationComment",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] | Parse PresentationComments object
@param file [Nokogiri::XML:Element] node to parse
@return [PresentationComments] result of parsing | [
"Parse",
"PresentationComments",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_comments.rb#L16-L29 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_size.rb | OoxmlParser.OoxmlSize.to_base_unit | def to_base_unit
case @unit
when :centimeter
OoxmlSize.new(@value * 360_000)
when :point
OoxmlSize.new(@value * 12_700)
when :half_point
OoxmlSize.new(@value * (12_700 / 2))
when :one_eighth_point
OoxmlSize.new(@value * (12_700 / 8))
when :one_100th_point
OoxmlSize.new(@value * (12_700 / 100))
when :one_240th_cm
OoxmlSize.new(@value * 1500)
when :dxa, :twip
return OoxmlSize.new(@value * 635, :emu)
when :inch
OoxmlSize.new(@value * 914_400, :emu)
when :spacing_point
OoxmlSize.new(@value * (12_700 / 100), :emu)
when :percent
OoxmlSize.new(@value * 100_000, :one_100000th_percent)
when :pct
OoxmlSize.new(@value * 100_000 / 50, :one_100000th_percent)
when :one_1000th_percent
OoxmlSize.new(@value * 100, :one_100000th_percent)
else
self
end
end | ruby | def to_base_unit
case @unit
when :centimeter
OoxmlSize.new(@value * 360_000)
when :point
OoxmlSize.new(@value * 12_700)
when :half_point
OoxmlSize.new(@value * (12_700 / 2))
when :one_eighth_point
OoxmlSize.new(@value * (12_700 / 8))
when :one_100th_point
OoxmlSize.new(@value * (12_700 / 100))
when :one_240th_cm
OoxmlSize.new(@value * 1500)
when :dxa, :twip
return OoxmlSize.new(@value * 635, :emu)
when :inch
OoxmlSize.new(@value * 914_400, :emu)
when :spacing_point
OoxmlSize.new(@value * (12_700 / 100), :emu)
when :percent
OoxmlSize.new(@value * 100_000, :one_100000th_percent)
when :pct
OoxmlSize.new(@value * 100_000 / 50, :one_100000th_percent)
when :one_1000th_percent
OoxmlSize.new(@value * 100, :one_100000th_percent)
else
self
end
end | [
"def",
"to_base_unit",
"case",
"@unit",
"when",
":centimeter",
"OoxmlSize",
".",
"new",
"(",
"@value",
"*",
"360_000",
")",
"when",
":point",
"OoxmlSize",
".",
"new",
"(",
"@value",
"*",
"12_700",
")",
"when",
":half_point",
"OoxmlSize",
".",
"new",
"(",
"@value",
"*",
"(",
"12_700",
"/",
"2",
")",
")",
"when",
":one_eighth_point",
"OoxmlSize",
".",
"new",
"(",
"@value",
"*",
"(",
"12_700",
"/",
"8",
")",
")",
"when",
":one_100th_point",
"OoxmlSize",
".",
"new",
"(",
"@value",
"*",
"(",
"12_700",
"/",
"100",
")",
")",
"when",
":one_240th_cm",
"OoxmlSize",
".",
"new",
"(",
"@value",
"*",
"1500",
")",
"when",
":dxa",
",",
":twip",
"return",
"OoxmlSize",
".",
"new",
"(",
"@value",
"*",
"635",
",",
":emu",
")",
"when",
":inch",
"OoxmlSize",
".",
"new",
"(",
"@value",
"*",
"914_400",
",",
":emu",
")",
"when",
":spacing_point",
"OoxmlSize",
".",
"new",
"(",
"@value",
"*",
"(",
"12_700",
"/",
"100",
")",
",",
":emu",
")",
"when",
":percent",
"OoxmlSize",
".",
"new",
"(",
"@value",
"*",
"100_000",
",",
":one_100000th_percent",
")",
"when",
":pct",
"OoxmlSize",
".",
"new",
"(",
"@value",
"*",
"100_000",
"/",
"50",
",",
":one_100000th_percent",
")",
"when",
":one_1000th_percent",
"OoxmlSize",
".",
"new",
"(",
"@value",
"*",
"100",
",",
":one_100000th_percent",
")",
"else",
"self",
"end",
"end"
] | Convert all values to one same base unit
@return [OoxmlSize] base unit | [
"Convert",
"all",
"values",
"to",
"one",
"same",
"base",
"unit"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_size.rb#L43-L72 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/docx_parser/docx_data/document_structure/document_properties.rb | OoxmlParser.DocumentProperties.parse | def parse
properties_file = "#{OOXMLDocumentObject.path_to_folder}docProps/app.xml"
unless File.exist?(properties_file)
warn "There is no 'docProps/app.xml' in docx. It may be some problem with it"
return self
end
node = parse_xml(properties_file)
node.xpath('*').each do |node_child|
case node_child.name
when 'Properties'
node_child.xpath('*').each do |node_child_child|
case node_child_child.name
when 'Pages'
@pages = node_child_child.text.to_i
when 'Words'
@words = node_child_child.text.to_i
end
end
end
end
self
end | ruby | def parse
properties_file = "#{OOXMLDocumentObject.path_to_folder}docProps/app.xml"
unless File.exist?(properties_file)
warn "There is no 'docProps/app.xml' in docx. It may be some problem with it"
return self
end
node = parse_xml(properties_file)
node.xpath('*').each do |node_child|
case node_child.name
when 'Properties'
node_child.xpath('*').each do |node_child_child|
case node_child_child.name
when 'Pages'
@pages = node_child_child.text.to_i
when 'Words'
@words = node_child_child.text.to_i
end
end
end
end
self
end | [
"def",
"parse",
"properties_file",
"=",
"\"#{OOXMLDocumentObject.path_to_folder}docProps/app.xml\"",
"unless",
"File",
".",
"exist?",
"(",
"properties_file",
")",
"warn",
"\"There is no 'docProps/app.xml' in docx. It may be some problem with it\"",
"return",
"self",
"end",
"node",
"=",
"parse_xml",
"(",
"properties_file",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'Properties'",
"node_child",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child_child",
"|",
"case",
"node_child_child",
".",
"name",
"when",
"'Pages'",
"@pages",
"=",
"node_child_child",
".",
"text",
".",
"to_i",
"when",
"'Words'",
"@words",
"=",
"node_child_child",
".",
"text",
".",
"to_i",
"end",
"end",
"end",
"end",
"self",
"end"
] | Parse Document properties
@return [DocumentProperties] | [
"Parse",
"Document",
"properties"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_properties.rb#L8-L29 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/non_visual_shape_properties/common_non_visual_properties.rb | OoxmlParser.CommonNonVisualProperties.parse | def parse(node)
node.attributes.each do |key, value|
case key
when 'name'
@name = value.value
when 'id'
@id = value.value
when 'title'
@title = value.value
when 'descr'
@description = value.value
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'hlinkClick'
@on_click_hyperlink = Hyperlink.new(parent: self).parse(node_child)
when 'hlinkHover'
@hyperlink_for_hover = Hyperlink.new(parent: self).parse(node_child)
end
end
self
end | ruby | def parse(node)
node.attributes.each do |key, value|
case key
when 'name'
@name = value.value
when 'id'
@id = value.value
when 'title'
@title = value.value
when 'descr'
@description = value.value
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'hlinkClick'
@on_click_hyperlink = Hyperlink.new(parent: self).parse(node_child)
when 'hlinkHover'
@hyperlink_for_hover = Hyperlink.new(parent: self).parse(node_child)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'name'",
"@name",
"=",
"value",
".",
"value",
"when",
"'id'",
"@id",
"=",
"value",
".",
"value",
"when",
"'title'",
"@title",
"=",
"value",
".",
"value",
"when",
"'descr'",
"@description",
"=",
"value",
".",
"value",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'hlinkClick'",
"@on_click_hyperlink",
"=",
"Hyperlink",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'hlinkHover'",
"@hyperlink_for_hover",
"=",
"Hyperlink",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] | Parse CommonNonVisualProperties object
@param node [Nokogiri::XML:Element] node to parse
@return [CommonNonVisualProperties] result of parsing | [
"Parse",
"CommonNonVisualProperties",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/non_visual_shape_properties/common_non_visual_properties.rb#L13-L36 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/common_parser/common_data/colors/hsl_color.rb | OoxmlParser.HSLColor.to_rgb | def to_rgb
chroma = (1 - (2 * @l - 1).abs) * @s
x = chroma * (1 - ((@h / 60.0) % 2.0 - 1).abs)
m = @l - chroma / 2.0
rgb = if @h.zero?
Color.new(0, 0, 0)
elsif @h > 0 && @h < 60
Color.new(chroma, x, 0)
elsif @h > 60 && @h < 120
Color.new(x, chroma, 0)
elsif @h > 120 && @h < 180
Color.new(0, chroma, x)
elsif @h > 180 && @h < 240
Color.new(0, x, chroma)
elsif @h > 240 && @h < 300
Color.new(x, 0, chroma)
else
Color.new(chroma, 0, x)
end
Color.new(((rgb.red + m) * 255.0).round, ((rgb.green + m) * 255.0).round, ((rgb.blue + m) * 255.0).round)
end | ruby | def to_rgb
chroma = (1 - (2 * @l - 1).abs) * @s
x = chroma * (1 - ((@h / 60.0) % 2.0 - 1).abs)
m = @l - chroma / 2.0
rgb = if @h.zero?
Color.new(0, 0, 0)
elsif @h > 0 && @h < 60
Color.new(chroma, x, 0)
elsif @h > 60 && @h < 120
Color.new(x, chroma, 0)
elsif @h > 120 && @h < 180
Color.new(0, chroma, x)
elsif @h > 180 && @h < 240
Color.new(0, x, chroma)
elsif @h > 240 && @h < 300
Color.new(x, 0, chroma)
else
Color.new(chroma, 0, x)
end
Color.new(((rgb.red + m) * 255.0).round, ((rgb.green + m) * 255.0).round, ((rgb.blue + m) * 255.0).round)
end | [
"def",
"to_rgb",
"chroma",
"=",
"(",
"1",
"-",
"(",
"2",
"*",
"@l",
"-",
"1",
")",
".",
"abs",
")",
"*",
"@s",
"x",
"=",
"chroma",
"*",
"(",
"1",
"-",
"(",
"(",
"@h",
"/",
"60.0",
")",
"%",
"2.0",
"-",
"1",
")",
".",
"abs",
")",
"m",
"=",
"@l",
"-",
"chroma",
"/",
"2.0",
"rgb",
"=",
"if",
"@h",
".",
"zero?",
"Color",
".",
"new",
"(",
"0",
",",
"0",
",",
"0",
")",
"elsif",
"@h",
">",
"0",
"&&",
"@h",
"<",
"60",
"Color",
".",
"new",
"(",
"chroma",
",",
"x",
",",
"0",
")",
"elsif",
"@h",
">",
"60",
"&&",
"@h",
"<",
"120",
"Color",
".",
"new",
"(",
"x",
",",
"chroma",
",",
"0",
")",
"elsif",
"@h",
">",
"120",
"&&",
"@h",
"<",
"180",
"Color",
".",
"new",
"(",
"0",
",",
"chroma",
",",
"x",
")",
"elsif",
"@h",
">",
"180",
"&&",
"@h",
"<",
"240",
"Color",
".",
"new",
"(",
"0",
",",
"x",
",",
"chroma",
")",
"elsif",
"@h",
">",
"240",
"&&",
"@h",
"<",
"300",
"Color",
".",
"new",
"(",
"x",
",",
"0",
",",
"chroma",
")",
"else",
"Color",
".",
"new",
"(",
"chroma",
",",
"0",
",",
"x",
")",
"end",
"Color",
".",
"new",
"(",
"(",
"(",
"rgb",
".",
"red",
"+",
"m",
")",
"*",
"255.0",
")",
".",
"round",
",",
"(",
"(",
"rgb",
".",
"green",
"+",
"m",
")",
"*",
"255.0",
")",
".",
"round",
",",
"(",
"(",
"rgb",
".",
"blue",
"+",
"m",
")",
"*",
"255.0",
")",
".",
"round",
")",
"end"
] | Chroma - The "colorfulness relative to the brightness of a similarly illuminated white". | [
"Chroma",
"-",
"The",
"colorfulness",
"relative",
"to",
"the",
"brightness",
"of",
"a",
"similarly",
"illuminated",
"white",
"."
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/colors/hsl_color.rb#L51-L72 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/transition_properties/transition_properties.rb | OoxmlParser.TransitionProperties.parse | def parse(node)
@type = node.name.to_sym
case node.name
when 'blinds', 'checker', 'comb', 'cover', 'pull', 'push', 'randomBar', 'strips', 'wipe', 'zoom', 'warp'
@direction = value_to_symbol(node.attribute('dir')) if node.attribute('dir')
when 'cut', 'fade'
@through_black = option_enabled?(node, 'thruBlk')
when 'split'
@direction = value_to_symbol(node.attribute('dir')) if node.attribute('dir')
@orientation = node.attribute('orient').value.to_sym if node.attribute('orient')
when 'wheel', 'wheelReverse'
@spokes = option_enabled?(node, 'spokes')
end
self
end | ruby | def parse(node)
@type = node.name.to_sym
case node.name
when 'blinds', 'checker', 'comb', 'cover', 'pull', 'push', 'randomBar', 'strips', 'wipe', 'zoom', 'warp'
@direction = value_to_symbol(node.attribute('dir')) if node.attribute('dir')
when 'cut', 'fade'
@through_black = option_enabled?(node, 'thruBlk')
when 'split'
@direction = value_to_symbol(node.attribute('dir')) if node.attribute('dir')
@orientation = node.attribute('orient').value.to_sym if node.attribute('orient')
when 'wheel', 'wheelReverse'
@spokes = option_enabled?(node, 'spokes')
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"@type",
"=",
"node",
".",
"name",
".",
"to_sym",
"case",
"node",
".",
"name",
"when",
"'blinds'",
",",
"'checker'",
",",
"'comb'",
",",
"'cover'",
",",
"'pull'",
",",
"'push'",
",",
"'randomBar'",
",",
"'strips'",
",",
"'wipe'",
",",
"'zoom'",
",",
"'warp'",
"@direction",
"=",
"value_to_symbol",
"(",
"node",
".",
"attribute",
"(",
"'dir'",
")",
")",
"if",
"node",
".",
"attribute",
"(",
"'dir'",
")",
"when",
"'cut'",
",",
"'fade'",
"@through_black",
"=",
"option_enabled?",
"(",
"node",
",",
"'thruBlk'",
")",
"when",
"'split'",
"@direction",
"=",
"value_to_symbol",
"(",
"node",
".",
"attribute",
"(",
"'dir'",
")",
")",
"if",
"node",
".",
"attribute",
"(",
"'dir'",
")",
"@orientation",
"=",
"node",
".",
"attribute",
"(",
"'orient'",
")",
".",
"value",
".",
"to_sym",
"if",
"node",
".",
"attribute",
"(",
"'orient'",
")",
"when",
"'wheel'",
",",
"'wheelReverse'",
"@spokes",
"=",
"option_enabled?",
"(",
"node",
",",
"'spokes'",
")",
"end",
"self",
"end"
] | Parse TransitionProperties object
@param node [Nokogiri::XML:Element] node to parse
@return [TransitionProperties] result of parsing | [
"Parse",
"TransitionProperties",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/transition_properties/transition_properties.rb#L8-L22 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/inserted.rb | OoxmlParser.Inserted.parse | def parse(node)
node.attributes.each do |key, value|
case key
when 'id'
@id = value.value.to_i
when 'author'
@author = value.value.to_s
when 'date'
@date = parse_date(value.value.to_s)
when 'oouserid'
@user_id = value.value.to_s
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'r'
@run = ParagraphRun.new(parent: self).parse(node_child)
end
end
self
end | ruby | def parse(node)
node.attributes.each do |key, value|
case key
when 'id'
@id = value.value.to_i
when 'author'
@author = value.value.to_s
when 'date'
@date = parse_date(value.value.to_s)
when 'oouserid'
@user_id = value.value.to_s
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'r'
@run = ParagraphRun.new(parent: self).parse(node_child)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'id'",
"@id",
"=",
"value",
".",
"value",
".",
"to_i",
"when",
"'author'",
"@author",
"=",
"value",
".",
"value",
".",
"to_s",
"when",
"'date'",
"@date",
"=",
"parse_date",
"(",
"value",
".",
"value",
".",
"to_s",
")",
"when",
"'oouserid'",
"@user_id",
"=",
"value",
".",
"value",
".",
"to_s",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'r'",
"@run",
"=",
"ParagraphRun",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] | Parse Inserted object
@param node [Nokogiri::XML:Element] node to parse
@return [Inserted] result of parsing | [
"Parse",
"Inserted",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/inserted.rb#L20-L41 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/common_parser/common_data/table/properties/table_style_properties.rb | OoxmlParser.TableStyleProperties.parse | def parse(node)
node.attributes.each do |key, value|
case key
when 'type'
@type = value.value.to_sym
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'rPr'
@run_properties = RunProperties.new(parent: self).parse(node_child)
when 'tcPr'
@table_cell_properties = CellProperties.new(parent: self).parse(node_child)
when 'tblPr'
@table_properties = TableProperties.new(parent: self).parse(node_child)
when 'trPr'
@table_row_properties = TableRowProperties.new(parent: self).parse(node_child)
when 'pPr'
@paragraph_properties = ParagraphProperties.new(parent: self).parse(node_child)
end
end
self
end | ruby | def parse(node)
node.attributes.each do |key, value|
case key
when 'type'
@type = value.value.to_sym
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'rPr'
@run_properties = RunProperties.new(parent: self).parse(node_child)
when 'tcPr'
@table_cell_properties = CellProperties.new(parent: self).parse(node_child)
when 'tblPr'
@table_properties = TableProperties.new(parent: self).parse(node_child)
when 'trPr'
@table_row_properties = TableRowProperties.new(parent: self).parse(node_child)
when 'pPr'
@paragraph_properties = ParagraphProperties.new(parent: self).parse(node_child)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'type'",
"@type",
"=",
"value",
".",
"value",
".",
"to_sym",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'rPr'",
"@run_properties",
"=",
"RunProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'tcPr'",
"@table_cell_properties",
"=",
"CellProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'tblPr'",
"@table_properties",
"=",
"TableProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'trPr'",
"@table_row_properties",
"=",
"TableRowProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'pPr'",
"@paragraph_properties",
"=",
"ParagraphProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] | Parse table style property
@param node [Nokogiri::XML::Element] node to parse
@return [TableStyleProperties] | [
"Parse",
"table",
"style",
"property"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/table/properties/table_style_properties.rb#L29-L52 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/background.rb | OoxmlParser.Background.parse | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'bgPr'
@properties = BackgroundProperties.new(parent: self).parse(node_child)
end
end
background_properties_node = node.xpath('p:bgPr').first
if background_properties_node
@shade_to_title = attribute_enabled?(background_properties_node, 'shadeToTitle')
@fill = PresentationFill.new(parent: self).parse(background_properties_node)
end
self
end | ruby | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'bgPr'
@properties = BackgroundProperties.new(parent: self).parse(node_child)
end
end
background_properties_node = node.xpath('p:bgPr').first
if background_properties_node
@shade_to_title = attribute_enabled?(background_properties_node, 'shadeToTitle')
@fill = PresentationFill.new(parent: self).parse(background_properties_node)
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'bgPr'",
"@properties",
"=",
"BackgroundProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"background_properties_node",
"=",
"node",
".",
"xpath",
"(",
"'p:bgPr'",
")",
".",
"first",
"if",
"background_properties_node",
"@shade_to_title",
"=",
"attribute_enabled?",
"(",
"background_properties_node",
",",
"'shadeToTitle'",
")",
"@fill",
"=",
"PresentationFill",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"background_properties_node",
")",
"end",
"self",
"end"
] | Parse Background object
@param node [Nokogiri::XML:Element] node to parse
@return [Background] result of parsing | [
"Parse",
"Background",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/background.rb#L17-L31 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/structured_document_tag.rb | OoxmlParser.StructuredDocumentTag.parse | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'sdtContent'
@sdt_content = SDTContent.new(parent: self).parse(node_child)
when 'sdtPr'
@properties = SDTProperties.new(parent: self).parse(node_child)
end
end
self
end | ruby | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'sdtContent'
@sdt_content = SDTContent.new(parent: self).parse(node_child)
when 'sdtPr'
@properties = SDTProperties.new(parent: self).parse(node_child)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'sdtContent'",
"@sdt_content",
"=",
"SDTContent",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'sdtPr'",
"@properties",
"=",
"SDTProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] | Parse StructuredDocumentTag object
@param node [Nokogiri::XML:Element] node to parse
@return [StructuredDocumentTag] result of parsing | [
"Parse",
"StructuredDocumentTag",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/structured_document_tag.rb#L14-L24 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/autofilter.rb | OoxmlParser.Autofilter.parse | def parse(node)
node.attributes.each do |key, value|
case key
when 'ref'
@ref = Coordinates.parser_coordinates_range(value.value)
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'filterColumn'
@filter_column = FilterColumn.new(parent: self).parse(node_child)
end
end
self
end | ruby | def parse(node)
node.attributes.each do |key, value|
case key
when 'ref'
@ref = Coordinates.parser_coordinates_range(value.value)
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'filterColumn'
@filter_column = FilterColumn.new(parent: self).parse(node_child)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'ref'",
"@ref",
"=",
"Coordinates",
".",
"parser_coordinates_range",
"(",
"value",
".",
"value",
")",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'filterColumn'",
"@filter_column",
"=",
"FilterColumn",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] | Parse Autofilter data
@param [Nokogiri::XML:Element] node with Autofilter data
@return [Autofilter] value of Autofilter data | [
"Parse",
"Autofilter",
"data"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/autofilter.rb#L17-L32 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/common_parser/common_data/paragraph.rb | OoxmlParser.Paragraph.parse | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'pPr'
@properties = ParagraphProperties.new(parent: self).parse(node_child)
when 'fld'
@text_field = TextField.new(parent: self).parse(node_child)
when 'r'
@runs << ParagraphRun.new(parent: self).parse(node_child)
when 'AlternateContent'
@alternate_content = AlternateContent.new(parent: self).parse(node_child)
end
end
self
end | ruby | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'pPr'
@properties = ParagraphProperties.new(parent: self).parse(node_child)
when 'fld'
@text_field = TextField.new(parent: self).parse(node_child)
when 'r'
@runs << ParagraphRun.new(parent: self).parse(node_child)
when 'AlternateContent'
@alternate_content = AlternateContent.new(parent: self).parse(node_child)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'pPr'",
"@properties",
"=",
"ParagraphProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'fld'",
"@text_field",
"=",
"TextField",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'r'",
"@runs",
"<<",
"ParagraphRun",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'AlternateContent'",
"@alternate_content",
"=",
"AlternateContent",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] | Parse Paragraph object
@param node [Nokogiri::XML:Element] node to parse
@return [Paragraph] result of parsing | [
"Parse",
"Paragraph",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/paragraph.rb#L28-L42 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list/extension.rb | OoxmlParser.Extension.parse | def parse(node)
node.xpath('*').each do |column_node|
case column_node.name
when 'table'
@table = X14Table.new(parent: self).parse(column_node)
when 'sparklineGroups'
@sparkline_groups = SparklineGroups.new(parent: self).parse(column_node)
end
end
self
end | ruby | def parse(node)
node.xpath('*').each do |column_node|
case column_node.name
when 'table'
@table = X14Table.new(parent: self).parse(column_node)
when 'sparklineGroups'
@sparkline_groups = SparklineGroups.new(parent: self).parse(column_node)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"column_node",
"|",
"case",
"column_node",
".",
"name",
"when",
"'table'",
"@table",
"=",
"X14Table",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"column_node",
")",
"when",
"'sparklineGroups'",
"@sparkline_groups",
"=",
"SparklineGroups",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"column_node",
")",
"end",
"end",
"self",
"end"
] | Parse Extension data
@param [Nokogiri::XML:Element] node with Extension data
@return [Extension] value of Extension data | [
"Parse",
"Extension",
"data"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list/extension.rb#L14-L24 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties.rb | OoxmlParser.DocxShapeProperties.parse | def parse(node)
@fill_color = DocxColor.new(parent: self).parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'xfrm'
@shape_size = DocxShapeSize.new(parent: self).parse(node_child)
when 'prstGeom'
@preset_geometry = PresetGeometry.new(parent: self).parse(node_child)
when 'txbx'
@text_box = TextBox.parse_list(node_child)
when 'ln'
@line = DocxShapeLine.new(parent: self).parse(node_child)
when 'blipFill'
@blip_fill = BlipFill.new(parent: self).parse(node_child)
when 'custGeom'
@preset_geometry = PresetGeometry.new(parent: self).parse(node_child)
@preset_geometry.name = :custom
@custom_geometry = OOXMLCustomGeometry.new(parent: self).parse(node_child)
end
end
self
end | ruby | def parse(node)
@fill_color = DocxColor.new(parent: self).parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'xfrm'
@shape_size = DocxShapeSize.new(parent: self).parse(node_child)
when 'prstGeom'
@preset_geometry = PresetGeometry.new(parent: self).parse(node_child)
when 'txbx'
@text_box = TextBox.parse_list(node_child)
when 'ln'
@line = DocxShapeLine.new(parent: self).parse(node_child)
when 'blipFill'
@blip_fill = BlipFill.new(parent: self).parse(node_child)
when 'custGeom'
@preset_geometry = PresetGeometry.new(parent: self).parse(node_child)
@preset_geometry.name = :custom
@custom_geometry = OOXMLCustomGeometry.new(parent: self).parse(node_child)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"@fill_color",
"=",
"DocxColor",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'xfrm'",
"@shape_size",
"=",
"DocxShapeSize",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'prstGeom'",
"@preset_geometry",
"=",
"PresetGeometry",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'txbx'",
"@text_box",
"=",
"TextBox",
".",
"parse_list",
"(",
"node_child",
")",
"when",
"'ln'",
"@line",
"=",
"DocxShapeLine",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'blipFill'",
"@blip_fill",
"=",
"BlipFill",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'custGeom'",
"@preset_geometry",
"=",
"PresetGeometry",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"@preset_geometry",
".",
"name",
"=",
":custom",
"@custom_geometry",
"=",
"OOXMLCustomGeometry",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] | Parse DocxShapeProperties object
@param node [Nokogiri::XML:Element] node to parse
@return [DocxShapeProperties] result of parsing | [
"Parse",
"DocxShapeProperties",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties.rb#L26-L47 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/common_parser/common_data/colors/color_properties.rb | OoxmlParser.ColorProperties.parse | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'alpha'
@alpha = (node_child.attribute('val').value.to_f / 1_000.0).round
when 'lumMod'
@luminance_modulation = node_child.attribute('val').value.to_f / 100_000.0
when 'lumOff'
@luminance_offset = node_child.attribute('val').value.to_f / 100_000.0
when 'tint'
@tint = node_child.attribute('val').value.to_f / 100_000.0
end
end
self
end | ruby | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'alpha'
@alpha = (node_child.attribute('val').value.to_f / 1_000.0).round
when 'lumMod'
@luminance_modulation = node_child.attribute('val').value.to_f / 100_000.0
when 'lumOff'
@luminance_offset = node_child.attribute('val').value.to_f / 100_000.0
when 'tint'
@tint = node_child.attribute('val').value.to_f / 100_000.0
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'alpha'",
"@alpha",
"=",
"(",
"node_child",
".",
"attribute",
"(",
"'val'",
")",
".",
"value",
".",
"to_f",
"/",
"1_000.0",
")",
".",
"round",
"when",
"'lumMod'",
"@luminance_modulation",
"=",
"node_child",
".",
"attribute",
"(",
"'val'",
")",
".",
"value",
".",
"to_f",
"/",
"100_000.0",
"when",
"'lumOff'",
"@luminance_offset",
"=",
"node_child",
".",
"attribute",
"(",
"'val'",
")",
".",
"value",
".",
"to_f",
"/",
"100_000.0",
"when",
"'tint'",
"@tint",
"=",
"node_child",
".",
"attribute",
"(",
"'val'",
")",
".",
"value",
".",
"to_f",
"/",
"100_000.0",
"end",
"end",
"self",
"end"
] | Parse ColorProperties object
@param node [Nokogiri::XML:Element] node to parse
@return [ColorProperties] result of parsing | [
"Parse",
"ColorProperties",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/colors/color_properties.rb#L10-L24 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb | OoxmlParser.DocxShapeLine.parse | def parse(node)
node.attributes.each do |key, value|
case key
when 'w'
@width = OoxmlSize.new(value.value.to_f, :emu)
when 'cap'
@cap = value_to_symbol(value)
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'solidFill'
@color_scheme = DocxColorScheme.new(parent: self).parse(node_child)
when 'noFill'
@width = OoxmlSize.new(0)
when 'headEnd'
@head_end = LineEnd.new(parent: self).parse(node_child)
when 'tailEnd'
@tail_end = LineEnd.new(parent: self).parse(node_child)
when 'prstDash'
@dash = ValuedChild.new(:symbol, parent: self).parse(node_child)
end
end
self
end | ruby | def parse(node)
node.attributes.each do |key, value|
case key
when 'w'
@width = OoxmlSize.new(value.value.to_f, :emu)
when 'cap'
@cap = value_to_symbol(value)
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'solidFill'
@color_scheme = DocxColorScheme.new(parent: self).parse(node_child)
when 'noFill'
@width = OoxmlSize.new(0)
when 'headEnd'
@head_end = LineEnd.new(parent: self).parse(node_child)
when 'tailEnd'
@tail_end = LineEnd.new(parent: self).parse(node_child)
when 'prstDash'
@dash = ValuedChild.new(:symbol, parent: self).parse(node_child)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'w'",
"@width",
"=",
"OoxmlSize",
".",
"new",
"(",
"value",
".",
"value",
".",
"to_f",
",",
":emu",
")",
"when",
"'cap'",
"@cap",
"=",
"value_to_symbol",
"(",
"value",
")",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'solidFill'",
"@color_scheme",
"=",
"DocxColorScheme",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'noFill'",
"@width",
"=",
"OoxmlSize",
".",
"new",
"(",
"0",
")",
"when",
"'headEnd'",
"@head_end",
"=",
"LineEnd",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'tailEnd'",
"@tail_end",
"=",
"LineEnd",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'prstDash'",
"@dash",
"=",
"ValuedChild",
".",
"new",
"(",
":symbol",
",",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] | Parse DocxShapeLine object
@param node [Nokogiri::XML:Element] node to parse
@return [DocxShapeLine] result of parsing | [
"Parse",
"DocxShapeLine",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb#L33-L58 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/common_parser/common_data/table/table_properties.rb | OoxmlParser.TableProperties.parse | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'tableStyleId'
@table_style_id = node_child.text
when 'tblBorders'
@table_borders = TableBorders.new(parent: self).parse(node_child)
when 'tblStyle'
# TODO: Incorrect but to keep compatibility
@table_style_element = TableStyle.new(parent: self).parse(node_child)
when 'tblW'
@table_width = OoxmlSize.new.parse(node_child)
when 'jc'
@jc = node_child.attribute('val').text.to_sym
when 'shd'
@shade = Shade.new(parent: self).parse(node_child)
when 'solidFill'
@fill = PresentationFill.new(parent: self).parse(node)
when 'tblLook'
@table_look = TableLook.new(parent: self).parse(node_child)
when 'tblInd'
@table_indent = OoxmlSize.new(node_child.attribute('w').text.to_f)
when 'tblpPr'
@table_positon = TablePosition.new(parent: self).parse(node_child)
when 'tblCellMar'
@table_cell_margin = TableMargins.new(parent: table_properties).parse(node_child)
when 'tblStyleColBandSize'
@table_style_column_band_size = TableStyleColumnBandSize.new(parent: self).parse(node_child)
when 'tblStyleRowBandSize'
@table_style_row_band_size = TableStyleRowBandSize.new(parent: self).parse(node_child)
when 'tblLayout'
@table_layout = TableLayout.new(parent: self).parse(node_child)
when 'tblCellSpacing'
@table_cell_spacing = OoxmlSize.new.parse(node_child)
when 'tblCaption'
@caption = ValuedChild.new(:string, parent: self).parse(node_child)
when 'tblDescription'
@description = ValuedChild.new(:string, parent: self).parse(node_child)
end
end
@table_look = TableLook.new(parent: self).parse(node) if @table_look.nil?
self
end | ruby | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'tableStyleId'
@table_style_id = node_child.text
when 'tblBorders'
@table_borders = TableBorders.new(parent: self).parse(node_child)
when 'tblStyle'
# TODO: Incorrect but to keep compatibility
@table_style_element = TableStyle.new(parent: self).parse(node_child)
when 'tblW'
@table_width = OoxmlSize.new.parse(node_child)
when 'jc'
@jc = node_child.attribute('val').text.to_sym
when 'shd'
@shade = Shade.new(parent: self).parse(node_child)
when 'solidFill'
@fill = PresentationFill.new(parent: self).parse(node)
when 'tblLook'
@table_look = TableLook.new(parent: self).parse(node_child)
when 'tblInd'
@table_indent = OoxmlSize.new(node_child.attribute('w').text.to_f)
when 'tblpPr'
@table_positon = TablePosition.new(parent: self).parse(node_child)
when 'tblCellMar'
@table_cell_margin = TableMargins.new(parent: table_properties).parse(node_child)
when 'tblStyleColBandSize'
@table_style_column_band_size = TableStyleColumnBandSize.new(parent: self).parse(node_child)
when 'tblStyleRowBandSize'
@table_style_row_band_size = TableStyleRowBandSize.new(parent: self).parse(node_child)
when 'tblLayout'
@table_layout = TableLayout.new(parent: self).parse(node_child)
when 'tblCellSpacing'
@table_cell_spacing = OoxmlSize.new.parse(node_child)
when 'tblCaption'
@caption = ValuedChild.new(:string, parent: self).parse(node_child)
when 'tblDescription'
@description = ValuedChild.new(:string, parent: self).parse(node_child)
end
end
@table_look = TableLook.new(parent: self).parse(node) if @table_look.nil?
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'tableStyleId'",
"@table_style_id",
"=",
"node_child",
".",
"text",
"when",
"'tblBorders'",
"@table_borders",
"=",
"TableBorders",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'tblStyle'",
"# TODO: Incorrect but to keep compatibility",
"@table_style_element",
"=",
"TableStyle",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'tblW'",
"@table_width",
"=",
"OoxmlSize",
".",
"new",
".",
"parse",
"(",
"node_child",
")",
"when",
"'jc'",
"@jc",
"=",
"node_child",
".",
"attribute",
"(",
"'val'",
")",
".",
"text",
".",
"to_sym",
"when",
"'shd'",
"@shade",
"=",
"Shade",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'solidFill'",
"@fill",
"=",
"PresentationFill",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node",
")",
"when",
"'tblLook'",
"@table_look",
"=",
"TableLook",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'tblInd'",
"@table_indent",
"=",
"OoxmlSize",
".",
"new",
"(",
"node_child",
".",
"attribute",
"(",
"'w'",
")",
".",
"text",
".",
"to_f",
")",
"when",
"'tblpPr'",
"@table_positon",
"=",
"TablePosition",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'tblCellMar'",
"@table_cell_margin",
"=",
"TableMargins",
".",
"new",
"(",
"parent",
":",
"table_properties",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'tblStyleColBandSize'",
"@table_style_column_band_size",
"=",
"TableStyleColumnBandSize",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'tblStyleRowBandSize'",
"@table_style_row_band_size",
"=",
"TableStyleRowBandSize",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'tblLayout'",
"@table_layout",
"=",
"TableLayout",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'tblCellSpacing'",
"@table_cell_spacing",
"=",
"OoxmlSize",
".",
"new",
".",
"parse",
"(",
"node_child",
")",
"when",
"'tblCaption'",
"@caption",
"=",
"ValuedChild",
".",
"new",
"(",
":string",
",",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'tblDescription'",
"@description",
"=",
"ValuedChild",
".",
"new",
"(",
":string",
",",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"@table_look",
"=",
"TableLook",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node",
")",
"if",
"@table_look",
".",
"nil?",
"self",
"end"
] | Parse TableProperties object
@param node [Nokogiri::XML:Element] node to parse
@return [TableProperties] result of parsing | [
"Parse",
"TableProperties",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/table/table_properties.rb#L47-L89 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/common_slide_data.rb | OoxmlParser.CommonSlideData.parse | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'spTree'
@shape_tree = ShapeTree.new(parent: self).parse(node_child)
when 'bg'
@background = Background.new(parent: self).parse(node_child)
end
end
self
end | ruby | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'spTree'
@shape_tree = ShapeTree.new(parent: self).parse(node_child)
when 'bg'
@background = Background.new(parent: self).parse(node_child)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'spTree'",
"@shape_tree",
"=",
"ShapeTree",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'bg'",
"@background",
"=",
"Background",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] | Parse CommonSlideData object
@param node [Nokogiri::XML:Element] node to parse
@return [CommonSlideData] result of parsing | [
"Parse",
"CommonSlideData",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/common_slide_data.rb#L14-L24 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/table_cell_line.rb | OoxmlParser.TableCellLine.parse | def parse(node)
@fill = PresentationFill.new(parent: self).parse(node)
@line_join = LineJoin.new(parent: self).parse(node)
node.attributes.each do |key, value|
case key
when 'w'
@width = OoxmlSize.new(value.value.to_f, :emu)
when 'algn'
@align = value_to_symbol(value)
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'headEnd'
@head_end = LineEnd.new(parent: self).parse(node_child)
when 'tailEnd'
@tail_end = LineEnd.new(parent: self).parse(node_child)
when 'ln'
return TableCellLine.new(parent: self).parse(node_child)
end
end
self
end | ruby | def parse(node)
@fill = PresentationFill.new(parent: self).parse(node)
@line_join = LineJoin.new(parent: self).parse(node)
node.attributes.each do |key, value|
case key
when 'w'
@width = OoxmlSize.new(value.value.to_f, :emu)
when 'algn'
@align = value_to_symbol(value)
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'headEnd'
@head_end = LineEnd.new(parent: self).parse(node_child)
when 'tailEnd'
@tail_end = LineEnd.new(parent: self).parse(node_child)
when 'ln'
return TableCellLine.new(parent: self).parse(node_child)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"@fill",
"=",
"PresentationFill",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node",
")",
"@line_join",
"=",
"LineJoin",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'w'",
"@width",
"=",
"OoxmlSize",
".",
"new",
"(",
"value",
".",
"value",
".",
"to_f",
",",
":emu",
")",
"when",
"'algn'",
"@align",
"=",
"value_to_symbol",
"(",
"value",
")",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'headEnd'",
"@head_end",
"=",
"LineEnd",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'tailEnd'",
"@tail_end",
"=",
"LineEnd",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'ln'",
"return",
"TableCellLine",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] | Parse TableCellLine object
@param node [Nokogiri::XML:Element] node to parse
@return [TableCellLine] result of parsing | [
"Parse",
"TableCellLine",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/table_cell_line.rb#L16-L39 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape.rb | OoxmlParser.DocxShape.parse | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'nvSpPr'
@non_visual_properties = NonVisualShapeProperties.new(parent: self).parse(node_child)
when 'spPr'
@properties = DocxShapeProperties.new(parent: self).parse(node_child)
when 'txbx'
@text_body = OOXMLTextBox.new(parent: self).parse(node_child)
when 'txBody'
@text_body = TextBody.new(parent: self).parse(node_child)
when 'bodyPr'
@body_properties = OOXMLShapeBodyProperties.new(parent: self).parse(node_child)
end
end
self
end | ruby | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'nvSpPr'
@non_visual_properties = NonVisualShapeProperties.new(parent: self).parse(node_child)
when 'spPr'
@properties = DocxShapeProperties.new(parent: self).parse(node_child)
when 'txbx'
@text_body = OOXMLTextBox.new(parent: self).parse(node_child)
when 'txBody'
@text_body = TextBody.new(parent: self).parse(node_child)
when 'bodyPr'
@body_properties = OOXMLShapeBodyProperties.new(parent: self).parse(node_child)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'nvSpPr'",
"@non_visual_properties",
"=",
"NonVisualShapeProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'spPr'",
"@properties",
"=",
"DocxShapeProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'txbx'",
"@text_body",
"=",
"OOXMLTextBox",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'txBody'",
"@text_body",
"=",
"TextBody",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'bodyPr'",
"@body_properties",
"=",
"OOXMLShapeBodyProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] | Parse DocxShape object
@param node [Nokogiri::XML:Element] node to parse
@return [DocxShape] result of parsing | [
"Parse",
"DocxShape",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape.rb#L26-L42 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/sdt/sdt_content.rb | OoxmlParser.SDTContent.parse | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'p'
@elements << DocxParagraph.new(parent: self).parse(node_child)
when 'r'
@elements << ParagraphRun.new(parent: self).parse(node_child)
when 'tbl'
@elements << Table.new(parent: self).parse(node_child)
end
end
self
end | ruby | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'p'
@elements << DocxParagraph.new(parent: self).parse(node_child)
when 'r'
@elements << ParagraphRun.new(parent: self).parse(node_child)
when 'tbl'
@elements << Table.new(parent: self).parse(node_child)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'p'",
"@elements",
"<<",
"DocxParagraph",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'r'",
"@elements",
"<<",
"ParagraphRun",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'tbl'",
"@elements",
"<<",
"Table",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] | Parse SDTContent object
@param node [Nokogiri::XML:Element] node to parse
@return [SDTContent] result of parsing | [
"Parse",
"SDTContent",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/sdt/sdt_content.rb#L15-L27 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node/common_timing.rb | OoxmlParser.CommonTiming.parse | def parse(node)
node.attributes.each do |key, value|
case key
when 'dur'
@duration = value.value
when 'restart'
@restart = value.value
when 'id'
@id = value.value
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'stCondLst'
@start_conditions = ConditionList.new(parent: self).parse(node_child)
when 'endCondLst'
@end_conditions = ConditionList.new(parent: self).parse(node_child)
when 'childTnLst'
@children = TimeNode.parse_list(node_child)
end
end
self
end | ruby | def parse(node)
node.attributes.each do |key, value|
case key
when 'dur'
@duration = value.value
when 'restart'
@restart = value.value
when 'id'
@id = value.value
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'stCondLst'
@start_conditions = ConditionList.new(parent: self).parse(node_child)
when 'endCondLst'
@end_conditions = ConditionList.new(parent: self).parse(node_child)
when 'childTnLst'
@children = TimeNode.parse_list(node_child)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'dur'",
"@duration",
"=",
"value",
".",
"value",
"when",
"'restart'",
"@restart",
"=",
"value",
".",
"value",
"when",
"'id'",
"@id",
"=",
"value",
".",
"value",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'stCondLst'",
"@start_conditions",
"=",
"ConditionList",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'endCondLst'",
"@end_conditions",
"=",
"ConditionList",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'childTnLst'",
"@children",
"=",
"TimeNode",
".",
"parse_list",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] | Parse CommonTiming object
@param node [Nokogiri::XML:Element] node to parse
@return [CommonTiming] result of parsing | [
"Parse",
"CommonTiming",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node/common_timing.rb#L16-L39 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/custom_geometry/ooxml_custom_geometry.rb | OoxmlParser.OOXMLCustomGeometry.parse | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'pathLst'
node_child.xpath('a:path', 'xmlns:a' => 'http://schemas.openxmlformats.org/drawingml/2006/main').each do |path_node|
@paths_list << DocxShapeLinePath.new(parent: self).parse(path_node)
end
end
end
self
end | ruby | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'pathLst'
node_child.xpath('a:path', 'xmlns:a' => 'http://schemas.openxmlformats.org/drawingml/2006/main').each do |path_node|
@paths_list << DocxShapeLinePath.new(parent: self).parse(path_node)
end
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'pathLst'",
"node_child",
".",
"xpath",
"(",
"'a:path'",
",",
"'xmlns:a'",
"=>",
"'http://schemas.openxmlformats.org/drawingml/2006/main'",
")",
".",
"each",
"do",
"|",
"path_node",
"|",
"@paths_list",
"<<",
"DocxShapeLinePath",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"path_node",
")",
"end",
"end",
"end",
"self",
"end"
] | Parse OOXMLCustomGeometry object
@param node [Nokogiri::XML:Element] node to parse
@return [OOXMLCustomGeometry] result of parsing | [
"Parse",
"OOXMLCustomGeometry",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/custom_geometry/ooxml_custom_geometry.rb#L15-L25 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/common_parser/common_data/alternate_content/picture/old_docx_picture.rb | OoxmlParser.OldDocxPicture.parse | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'shape'
@type = :shape
@data = OldDocxShape.new(parent: self).parse(node_child)
when 'group'
@type = :group
@data = OldDocxGroup.new(parent: self).parse(node_child)
when 'style'
@style_number = node_child.attribute('val').value.to_i
end
end
self
end | ruby | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'shape'
@type = :shape
@data = OldDocxShape.new(parent: self).parse(node_child)
when 'group'
@type = :group
@data = OldDocxGroup.new(parent: self).parse(node_child)
when 'style'
@style_number = node_child.attribute('val').value.to_i
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'shape'",
"@type",
"=",
":shape",
"@data",
"=",
"OldDocxShape",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'group'",
"@type",
"=",
":group",
"@data",
"=",
"OldDocxGroup",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'style'",
"@style_number",
"=",
"node_child",
".",
"attribute",
"(",
"'val'",
")",
".",
"value",
".",
"to_i",
"end",
"end",
"self",
"end"
] | Parse OldDocxPicture object
@param node [Nokogiri::XML:Element] node to parse
@return [OldDocxPicture] result of parsing | [
"Parse",
"OldDocxPicture",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/old_docx_picture.rb#L12-L26 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula.rb | OoxmlParser.DocxFormula.parse | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'r'
@formula_run << MathRun.new(parent: self).parse(node_child)
when 'box', 'borderBox'
@formula_run << Box.new(parent: self).parse(node_child)
when 'func'
@formula_run << Function.new(parent: self).parse(node_child)
when 'rad'
@formula_run << Radical.new(parent: self).parse(node_child)
when 'e', 'eqArr'
@formula_run << DocxFormula.new(parent: self).parse(node_child)
when 'nary'
@formula_run << Nary.new(parent: self).parse(node_child)
when 'd'
@formula_run << Delimiter.new(parent: self).parse(node_child)
when 'sSubSup', 'sSup', 'sSub'
@formula_run << Index.new(parent: self).parse(node_child)
when 'f'
@formula_run << Fraction.new(parent: self).parse(node_child)
when 'm'
@formula_run << Matrix.new(parent: self).parse(node_child)
when 'bar'
@formula_run << Bar.new(parent: self).parse(node_child)
when 'acc'
@formula_run << Accent.new(parent: self).parse(node_child)
when 'groupChr'
@formula_run << GroupChar.new(parent: self).parse(node_child)
when 'argPr'
@argument_properties = ArgumentProperties.new(parent: self).parse(node_child)
when 'sPre'
@formula_run << PreSubSuperscript.new(parent: self).parse(node_child)
when 'limUpp', 'limLow'
@formula_run << Limit.new(parent: self).parse(node_child)
end
end
return nil if @formula_run.empty?
self
end | ruby | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'r'
@formula_run << MathRun.new(parent: self).parse(node_child)
when 'box', 'borderBox'
@formula_run << Box.new(parent: self).parse(node_child)
when 'func'
@formula_run << Function.new(parent: self).parse(node_child)
when 'rad'
@formula_run << Radical.new(parent: self).parse(node_child)
when 'e', 'eqArr'
@formula_run << DocxFormula.new(parent: self).parse(node_child)
when 'nary'
@formula_run << Nary.new(parent: self).parse(node_child)
when 'd'
@formula_run << Delimiter.new(parent: self).parse(node_child)
when 'sSubSup', 'sSup', 'sSub'
@formula_run << Index.new(parent: self).parse(node_child)
when 'f'
@formula_run << Fraction.new(parent: self).parse(node_child)
when 'm'
@formula_run << Matrix.new(parent: self).parse(node_child)
when 'bar'
@formula_run << Bar.new(parent: self).parse(node_child)
when 'acc'
@formula_run << Accent.new(parent: self).parse(node_child)
when 'groupChr'
@formula_run << GroupChar.new(parent: self).parse(node_child)
when 'argPr'
@argument_properties = ArgumentProperties.new(parent: self).parse(node_child)
when 'sPre'
@formula_run << PreSubSuperscript.new(parent: self).parse(node_child)
when 'limUpp', 'limLow'
@formula_run << Limit.new(parent: self).parse(node_child)
end
end
return nil if @formula_run.empty?
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'r'",
"@formula_run",
"<<",
"MathRun",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'box'",
",",
"'borderBox'",
"@formula_run",
"<<",
"Box",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'func'",
"@formula_run",
"<<",
"Function",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'rad'",
"@formula_run",
"<<",
"Radical",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'e'",
",",
"'eqArr'",
"@formula_run",
"<<",
"DocxFormula",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'nary'",
"@formula_run",
"<<",
"Nary",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'d'",
"@formula_run",
"<<",
"Delimiter",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'sSubSup'",
",",
"'sSup'",
",",
"'sSub'",
"@formula_run",
"<<",
"Index",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'f'",
"@formula_run",
"<<",
"Fraction",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'m'",
"@formula_run",
"<<",
"Matrix",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'bar'",
"@formula_run",
"<<",
"Bar",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'acc'",
"@formula_run",
"<<",
"Accent",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'groupChr'",
"@formula_run",
"<<",
"GroupChar",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'argPr'",
"@argument_properties",
"=",
"ArgumentProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'sPre'",
"@formula_run",
"<<",
"PreSubSuperscript",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'limUpp'",
",",
"'limLow'",
"@formula_run",
"<<",
"Limit",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"return",
"nil",
"if",
"@formula_run",
".",
"empty?",
"self",
"end"
] | Parse DocxFormula object
@param node [Nokogiri::XML:Element] node to parse
@return [DocxFormula] result of parsing | [
"Parse",
"DocxFormula",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula.rb#L31-L71 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/non_visual_shape_properties.rb | OoxmlParser.NonVisualShapeProperties.parse | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'cNvPr'
@common_properties = CommonNonVisualProperties.new(parent: self).parse(node_child)
when 'nvPr'
@non_visual_properties = NonVisualProperties.new(parent: self).parse(node_child)
end
end
self
end | ruby | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'cNvPr'
@common_properties = CommonNonVisualProperties.new(parent: self).parse(node_child)
when 'nvPr'
@non_visual_properties = NonVisualProperties.new(parent: self).parse(node_child)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'cNvPr'",
"@common_properties",
"=",
"CommonNonVisualProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'nvPr'",
"@non_visual_properties",
"=",
"NonVisualProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] | Parse NonVisualShapeProperties object
@param node [Nokogiri::XML:Element] node to parse
@return [NonVisualShapeProperties] result of parsing | [
"Parse",
"NonVisualShapeProperties",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/non_visual_shape_properties.rb#L10-L20 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_column_properties.rb | OoxmlParser.XlsxColumnProperties.parse | def parse(node)
node.attributes.each do |key, value|
case key
when 'min'
@from = value.value.to_i
when 'max'
@to = value.value.to_i
when 'style'
@style = root_object.style_sheet.cell_xfs.xf_array[value.value.to_i]
when 'width'
@width = value.value.to_f - 0.7109375
when 'customWidth'
@custom_width = option_enabled?(node, 'customWidth')
when 'bestFit'
@best_fit = attribute_enabled?(value)
when 'hidden'
@hidden = attribute_enabled?(value)
end
end
self
end | ruby | def parse(node)
node.attributes.each do |key, value|
case key
when 'min'
@from = value.value.to_i
when 'max'
@to = value.value.to_i
when 'style'
@style = root_object.style_sheet.cell_xfs.xf_array[value.value.to_i]
when 'width'
@width = value.value.to_f - 0.7109375
when 'customWidth'
@custom_width = option_enabled?(node, 'customWidth')
when 'bestFit'
@best_fit = attribute_enabled?(value)
when 'hidden'
@hidden = attribute_enabled?(value)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'min'",
"@from",
"=",
"value",
".",
"value",
".",
"to_i",
"when",
"'max'",
"@to",
"=",
"value",
".",
"value",
".",
"to_i",
"when",
"'style'",
"@style",
"=",
"root_object",
".",
"style_sheet",
".",
"cell_xfs",
".",
"xf_array",
"[",
"value",
".",
"value",
".",
"to_i",
"]",
"when",
"'width'",
"@width",
"=",
"value",
".",
"value",
".",
"to_f",
"-",
"0.7109375",
"when",
"'customWidth'",
"@custom_width",
"=",
"option_enabled?",
"(",
"node",
",",
"'customWidth'",
")",
"when",
"'bestFit'",
"@best_fit",
"=",
"attribute_enabled?",
"(",
"value",
")",
"when",
"'hidden'",
"@hidden",
"=",
"attribute_enabled?",
"(",
"value",
")",
"end",
"end",
"self",
"end"
] | Parse XlsxColumnProperties object
@param node [Nokogiri::XML:Element] node to parse
@return [XlsxColumnProperties] result of parsing | [
"Parse",
"XlsxColumnProperties",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_column_properties.rb#L17-L37 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/ooxml_text_box.rb | OoxmlParser.OOXMLTextBox.parse | def parse(node)
text_box_content_node = node.xpath('w:txbxContent').first
text_box_content_node.xpath('*').each_with_index do |node_child, index|
case node_child.name
when 'p'
@elements << DocxParagraph.new(parent: self).parse(node_child, index)
when 'tbl'
@elements << Table.new(parent: self).parse(node_child, index)
when 'bodyPr'
@properties = OOXMLShapeBodyProperties.new(parent: self).parse(node_child)
end
end
self
end | ruby | def parse(node)
text_box_content_node = node.xpath('w:txbxContent').first
text_box_content_node.xpath('*').each_with_index do |node_child, index|
case node_child.name
when 'p'
@elements << DocxParagraph.new(parent: self).parse(node_child, index)
when 'tbl'
@elements << Table.new(parent: self).parse(node_child, index)
when 'bodyPr'
@properties = OOXMLShapeBodyProperties.new(parent: self).parse(node_child)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"text_box_content_node",
"=",
"node",
".",
"xpath",
"(",
"'w:txbxContent'",
")",
".",
"first",
"text_box_content_node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each_with_index",
"do",
"|",
"node_child",
",",
"index",
"|",
"case",
"node_child",
".",
"name",
"when",
"'p'",
"@elements",
"<<",
"DocxParagraph",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
",",
"index",
")",
"when",
"'tbl'",
"@elements",
"<<",
"Table",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
",",
"index",
")",
"when",
"'bodyPr'",
"@properties",
"=",
"OOXMLShapeBodyProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] | Parse OOXMLTextBox object
@param node [Nokogiri::XML:Element] node to parse
@return [OOXMLTextBox] result of parsing | [
"Parse",
"OOXMLTextBox",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/ooxml_text_box.rb#L14-L27 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/docx_parser/docx_data/document_structure/document_style/document_style_helper.rb | OoxmlParser.DocumentStyleHelper.document_style_by_name | def document_style_by_name(name)
root_object.document_styles.each do |style|
return style if style.name == name
end
nil
end | ruby | def document_style_by_name(name)
root_object.document_styles.each do |style|
return style if style.name == name
end
nil
end | [
"def",
"document_style_by_name",
"(",
"name",
")",
"root_object",
".",
"document_styles",
".",
"each",
"do",
"|",
"style",
"|",
"return",
"style",
"if",
"style",
".",
"name",
"==",
"name",
"end",
"nil",
"end"
] | Return document style by its name
@param name [String] name of style
@return [DocumentStyle, nil] | [
"Return",
"document",
"style",
"by",
"its",
"name"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_style/document_style_helper.rb#L7-L12 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/docx_parser/docx_data/document_structure/document_style/document_style_helper.rb | OoxmlParser.DocumentStyleHelper.document_style_by_id | def document_style_by_id(id)
root_object.document_styles.each do |style|
return style if style.style_id == id
end
nil
end | ruby | def document_style_by_id(id)
root_object.document_styles.each do |style|
return style if style.style_id == id
end
nil
end | [
"def",
"document_style_by_id",
"(",
"id",
")",
"root_object",
".",
"document_styles",
".",
"each",
"do",
"|",
"style",
"|",
"return",
"style",
"if",
"style",
".",
"style_id",
"==",
"id",
"end",
"nil",
"end"
] | Return document style by its id
@param id [String] id of style
@return [DocumentStyle, nil] | [
"Return",
"document",
"style",
"by",
"its",
"id"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_style/document_style_helper.rb#L17-L22 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/box.rb | OoxmlParser.Box.parse | def parse(node)
@borders = true if node.name == 'borderBox'
@element = MathRun.new(parent: self).parse(node)
self
end | ruby | def parse(node)
@borders = true if node.name == 'borderBox'
@element = MathRun.new(parent: self).parse(node)
self
end | [
"def",
"parse",
"(",
"node",
")",
"@borders",
"=",
"true",
"if",
"node",
".",
"name",
"==",
"'borderBox'",
"@element",
"=",
"MathRun",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node",
")",
"self",
"end"
] | Parse Box object
@param node [Nokogiri::XML:Element] node to parse
@return [Box] result of parsing | [
"Parse",
"Box",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/box.rb#L14-L18 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/common_parser/common_data/colors/image_fill.rb | OoxmlParser.ImageFill.parse | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'blip'
@file_reference = FileReference.new(parent: self).parse(node_child)
when 'tile'
@tile = Tile.new(OOXMLCoordinates.parse(node_child, x_attr: 'tx', y_attr: 'ty'),
OOXMLCoordinates.parse(node_child, x_attr: 'sx', y_attr: 'sy'),
parent: self).parse(node_child)
end
end
self
end | ruby | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'blip'
@file_reference = FileReference.new(parent: self).parse(node_child)
when 'tile'
@tile = Tile.new(OOXMLCoordinates.parse(node_child, x_attr: 'tx', y_attr: 'ty'),
OOXMLCoordinates.parse(node_child, x_attr: 'sx', y_attr: 'sy'),
parent: self).parse(node_child)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'blip'",
"@file_reference",
"=",
"FileReference",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'tile'",
"@tile",
"=",
"Tile",
".",
"new",
"(",
"OOXMLCoordinates",
".",
"parse",
"(",
"node_child",
",",
"x_attr",
":",
"'tx'",
",",
"y_attr",
":",
"'ty'",
")",
",",
"OOXMLCoordinates",
".",
"parse",
"(",
"node_child",
",",
"x_attr",
":",
"'sx'",
",",
"y_attr",
":",
"'sy'",
")",
",",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] | Parse ImageFill object
@param node [Nokogiri::XML:Element] node to parse
@return [ImageFill] result of parsing | [
"Parse",
"ImageFill",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/colors/image_fill.rb#L16-L28 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing.rb | OoxmlParser.Timing.parse | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'tnLst'
@time_node_list = TimeNode.parse_list(node_child)
end
end
self
end | ruby | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'tnLst'
@time_node_list = TimeNode.parse_list(node_child)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'tnLst'",
"@time_node_list",
"=",
"TimeNode",
".",
"parse_list",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] | Parse Timing object
@param node [Nokogiri::XML:Element] node to parse
@return [Timing] result of parsing | [
"Parse",
"Timing",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing.rb#L17-L25 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/style_parametres.rb | OoxmlParser.StyleParametres.parse | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'name'
@name = node_child.attribute('val').value
when 'qFormat'
@q_format = option_enabled?(node_child)
end
end
self
end | ruby | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'name'
@name = node_child.attribute('val').value
when 'qFormat'
@q_format = option_enabled?(node_child)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'name'",
"@name",
"=",
"node_child",
".",
"attribute",
"(",
"'val'",
")",
".",
"value",
"when",
"'qFormat'",
"@q_format",
"=",
"option_enabled?",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] | Parse StyleParametres data
@param [Nokogiri::XML:Element] node with StyleParametres data
@return [StyleParametres] value of Columns data | [
"Parse",
"StyleParametres",
"data"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/style_parametres.rb#L19-L29 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/spacing.rb | OoxmlParser.Spacing.parse | def parse(node)
node.xpath('*').each do |spacing_node_child|
case spacing_node_child.name
when 'lnSpc'
self.line = Spacing.parse_spacing_value(spacing_node_child)
self.line_rule = Spacing.parse_spacing_rule(spacing_node_child)
when 'spcBef'
self.before = Spacing.parse_spacing_value(spacing_node_child)
when 'spcAft'
self.after = Spacing.parse_spacing_value(spacing_node_child)
end
end
end | ruby | def parse(node)
node.xpath('*').each do |spacing_node_child|
case spacing_node_child.name
when 'lnSpc'
self.line = Spacing.parse_spacing_value(spacing_node_child)
self.line_rule = Spacing.parse_spacing_rule(spacing_node_child)
when 'spcBef'
self.before = Spacing.parse_spacing_value(spacing_node_child)
when 'spcAft'
self.after = Spacing.parse_spacing_value(spacing_node_child)
end
end
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"spacing_node_child",
"|",
"case",
"spacing_node_child",
".",
"name",
"when",
"'lnSpc'",
"self",
".",
"line",
"=",
"Spacing",
".",
"parse_spacing_value",
"(",
"spacing_node_child",
")",
"self",
".",
"line_rule",
"=",
"Spacing",
".",
"parse_spacing_rule",
"(",
"spacing_node_child",
")",
"when",
"'spcBef'",
"self",
".",
"before",
"=",
"Spacing",
".",
"parse_spacing_value",
"(",
"spacing_node_child",
")",
"when",
"'spcAft'",
"self",
".",
"after",
"=",
"Spacing",
".",
"parse_spacing_value",
"(",
"spacing_node_child",
")",
"end",
"end",
"end"
] | Parse data for Spacing
@param [Nokogiri::XML:Element] node with Spacing
@return [Nothing] | [
"Parse",
"data",
"for",
"Spacing"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/spacing.rb#L71-L83 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color/gradient_stop.rb | OoxmlParser.GradientStop.parse | def parse(node)
node.attributes.each do |key, value|
case key
when 'pos'
@position = value.value.to_i / 1_000
end
end
node.xpath('*').each do |node_child|
@color = case node_child.name
when 'prstClr'
ValuedChild.new(:string, parent: self).parse(node_child)
else
Color.new(parent: self).parse_color(node_child)
end
end
self
end | ruby | def parse(node)
node.attributes.each do |key, value|
case key
when 'pos'
@position = value.value.to_i / 1_000
end
end
node.xpath('*').each do |node_child|
@color = case node_child.name
when 'prstClr'
ValuedChild.new(:string, parent: self).parse(node_child)
else
Color.new(parent: self).parse_color(node_child)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'pos'",
"@position",
"=",
"value",
".",
"value",
".",
"to_i",
"/",
"1_000",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"@color",
"=",
"case",
"node_child",
".",
"name",
"when",
"'prstClr'",
"ValuedChild",
".",
"new",
"(",
":string",
",",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"else",
"Color",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse_color",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] | Parse GradientStop object
@param node [Nokogiri::XML:Element] node to parse
@return [GradientStop] result of parsing | [
"Parse",
"GradientStop",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color/gradient_stop.rb#L8-L25 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties/blip_fill/blip/alpha_mod_fix.rb | OoxmlParser.AlphaModFix.parse | def parse(node)
node.attributes.each do |key, value|
case key
when 'amt'
@amount = OoxmlSize.new(value.value.to_f, :one_1000th_percent)
end
end
self
end | ruby | def parse(node)
node.attributes.each do |key, value|
case key
when 'amt'
@amount = OoxmlSize.new(value.value.to_f, :one_1000th_percent)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'amt'",
"@amount",
"=",
"OoxmlSize",
".",
"new",
"(",
"value",
".",
"value",
".",
"to_f",
",",
":one_1000th_percent",
")",
"end",
"end",
"self",
"end"
] | Parse AlphaModFix object
@param node [Nokogiri::XML:Element] node to parse
@return [AlphaModFix] result of parsing | [
"Parse",
"AlphaModFix",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties/blip_fill/blip/alpha_mod_fix.rb#L9-L17 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part.rb | OoxmlParser.TablePart.parse | def parse(node)
link_to_table_part_xml = OOXMLDocumentObject.get_link_from_rels(node.attribute('id').value)
doc = parse_xml(OOXMLDocumentObject.path_to_folder + link_to_table_part_xml.gsub('..', 'xl'))
table_node = doc.xpath('xmlns:table').first
table_node.attributes.each do |key, value|
case key
when 'name'
@name = value.value.to_s
when 'displayName'
@display_name = value.value.to_s
when 'ref'
@reference = Coordinates.parser_coordinates_range value.value.to_s
end
end
table_node.xpath('*').each do |node_child|
case node_child.name
when 'autoFilter'
@autofilter = Autofilter.new(parent: self).parse(node_child)
when 'extLst'
@extension_list = ExtensionList.new(parent: self).parse(node_child)
when 'tableColumns'
@table_columns = TableColumns.new(parent: self).parse(node_child)
when 'tableStyleInfo'
@table_style_info = TableStyleInfo.new(parent: self).parse(node_child)
end
end
self
end | ruby | def parse(node)
link_to_table_part_xml = OOXMLDocumentObject.get_link_from_rels(node.attribute('id').value)
doc = parse_xml(OOXMLDocumentObject.path_to_folder + link_to_table_part_xml.gsub('..', 'xl'))
table_node = doc.xpath('xmlns:table').first
table_node.attributes.each do |key, value|
case key
when 'name'
@name = value.value.to_s
when 'displayName'
@display_name = value.value.to_s
when 'ref'
@reference = Coordinates.parser_coordinates_range value.value.to_s
end
end
table_node.xpath('*').each do |node_child|
case node_child.name
when 'autoFilter'
@autofilter = Autofilter.new(parent: self).parse(node_child)
when 'extLst'
@extension_list = ExtensionList.new(parent: self).parse(node_child)
when 'tableColumns'
@table_columns = TableColumns.new(parent: self).parse(node_child)
when 'tableStyleInfo'
@table_style_info = TableStyleInfo.new(parent: self).parse(node_child)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"link_to_table_part_xml",
"=",
"OOXMLDocumentObject",
".",
"get_link_from_rels",
"(",
"node",
".",
"attribute",
"(",
"'id'",
")",
".",
"value",
")",
"doc",
"=",
"parse_xml",
"(",
"OOXMLDocumentObject",
".",
"path_to_folder",
"+",
"link_to_table_part_xml",
".",
"gsub",
"(",
"'..'",
",",
"'xl'",
")",
")",
"table_node",
"=",
"doc",
".",
"xpath",
"(",
"'xmlns:table'",
")",
".",
"first",
"table_node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'name'",
"@name",
"=",
"value",
".",
"value",
".",
"to_s",
"when",
"'displayName'",
"@display_name",
"=",
"value",
".",
"value",
".",
"to_s",
"when",
"'ref'",
"@reference",
"=",
"Coordinates",
".",
"parser_coordinates_range",
"value",
".",
"value",
".",
"to_s",
"end",
"end",
"table_node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'autoFilter'",
"@autofilter",
"=",
"Autofilter",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'extLst'",
"@extension_list",
"=",
"ExtensionList",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'tableColumns'",
"@table_columns",
"=",
"TableColumns",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'tableStyleInfo'",
"@table_style_info",
"=",
"TableStyleInfo",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] | Parse TablePart object
@param node [Nokogiri::XML:Element] node to parse
@return [TablePart] result of parsing | [
"Parse",
"TablePart",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part.rb#L19-L46 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view.rb | OoxmlParser.SheetView.parse | def parse(node)
node.attributes.each_key do |key|
case key
when 'showGridLines'
@show_gridlines = attribute_enabled?(node, key)
when 'showRowColHeaders'
@show_row_column_headers = attribute_enabled?(node, key)
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'pane'
@pane = Pane.new(parent: self).parse(node_child)
end
end
self
end | ruby | def parse(node)
node.attributes.each_key do |key|
case key
when 'showGridLines'
@show_gridlines = attribute_enabled?(node, key)
when 'showRowColHeaders'
@show_row_column_headers = attribute_enabled?(node, key)
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'pane'
@pane = Pane.new(parent: self).parse(node_child)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each_key",
"do",
"|",
"key",
"|",
"case",
"key",
"when",
"'showGridLines'",
"@show_gridlines",
"=",
"attribute_enabled?",
"(",
"node",
",",
"key",
")",
"when",
"'showRowColHeaders'",
"@show_row_column_headers",
"=",
"attribute_enabled?",
"(",
"node",
",",
"key",
")",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'pane'",
"@pane",
"=",
"Pane",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] | Parse SheetView object
@param node [Nokogiri::XML:Element] node to parse
@return [SheetView] result of parsing | [
"Parse",
"SheetView",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view.rb#L20-L37 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_position.rb | OoxmlParser.DocxDrawingPosition.parse | def parse(node)
node.attributes.each do |key, value|
case key
when 'relativeFrom'
@relative_from = value_to_symbol(value)
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'posOffset', 'pctPosHOffset', 'pctPosVOffset'
@offset = OoxmlSize.new(node_child.text.to_f, :emu)
when 'align'
@align = node_child.text.to_sym
end
end
self
end | ruby | def parse(node)
node.attributes.each do |key, value|
case key
when 'relativeFrom'
@relative_from = value_to_symbol(value)
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'posOffset', 'pctPosHOffset', 'pctPosVOffset'
@offset = OoxmlSize.new(node_child.text.to_f, :emu)
when 'align'
@align = node_child.text.to_sym
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'relativeFrom'",
"@relative_from",
"=",
"value_to_symbol",
"(",
"value",
")",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'posOffset'",
",",
"'pctPosHOffset'",
",",
"'pctPosVOffset'",
"@offset",
"=",
"OoxmlSize",
".",
"new",
"(",
"node_child",
".",
"text",
".",
"to_f",
",",
":emu",
")",
"when",
"'align'",
"@align",
"=",
"node_child",
".",
"text",
".",
"to_sym",
"end",
"end",
"self",
"end"
] | Parse DocxDrawingPosition object
@param node [Nokogiri::XML:Element] node to parse
@return [DocxDrawingPosition] result of parsing | [
"Parse",
"DocxDrawingPosition",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_position.rb#L9-L26 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/common_parser/common_data/alternate_content/picture/shape/old_docx_shape.rb | OoxmlParser.OldDocxShape.parse | def parse(node)
@properties = OldDocxShapeProperties.new(parent: self).parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'textbox'
@text_box = TextBox.parse_list(node_child, parent: self)
when 'imagedata'
@file_reference = FileReference.new(parent: self).parse(node_child)
when 'fill'
@fill = OldDocxShapeFill.new(parent: self).parse(node_child)
end
end
self
end | ruby | def parse(node)
@properties = OldDocxShapeProperties.new(parent: self).parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'textbox'
@text_box = TextBox.parse_list(node_child, parent: self)
when 'imagedata'
@file_reference = FileReference.new(parent: self).parse(node_child)
when 'fill'
@fill = OldDocxShapeFill.new(parent: self).parse(node_child)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"@properties",
"=",
"OldDocxShapeProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'textbox'",
"@text_box",
"=",
"TextBox",
".",
"parse_list",
"(",
"node_child",
",",
"parent",
":",
"self",
")",
"when",
"'imagedata'",
"@file_reference",
"=",
"FileReference",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'fill'",
"@fill",
"=",
"OldDocxShapeFill",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] | Parse OldDocxShape object
@param node [Nokogiri::XML:Element] node to parse
@return [OldDocxShape] result of parsing | [
"Parse",
"OldDocxShape",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/shape/old_docx_shape.rb#L12-L25 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/formula.rb | OoxmlParser.Formula.parse | def parse(node)
node.attributes.each do |key, value|
case key
when 'ref'
@reference = Coordinates.parser_coordinates_range(value.value.to_s)
when 'si'
@string_index = value.value.to_i
when 't'
@type = value.value.to_s
end
end
@value = node.text unless node.text.empty?
self
end | ruby | def parse(node)
node.attributes.each do |key, value|
case key
when 'ref'
@reference = Coordinates.parser_coordinates_range(value.value.to_s)
when 'si'
@string_index = value.value.to_i
when 't'
@type = value.value.to_s
end
end
@value = node.text unless node.text.empty?
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'ref'",
"@reference",
"=",
"Coordinates",
".",
"parser_coordinates_range",
"(",
"value",
".",
"value",
".",
"to_s",
")",
"when",
"'si'",
"@string_index",
"=",
"value",
".",
"value",
".",
"to_i",
"when",
"'t'",
"@type",
"=",
"value",
".",
"value",
".",
"to_s",
"end",
"end",
"@value",
"=",
"node",
".",
"text",
"unless",
"node",
".",
"text",
".",
"empty?",
"self",
"end"
] | Parse Formula object
@param node [Nokogiri::XML:Element] node to parse
@return [Formula] parsed object | [
"Parse",
"Formula",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/formula.rb#L16-L30 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/common_parser/common_data/relationships.rb | OoxmlParser.Relationships.parse_file | def parse_file(file_path)
node = parse_xml(file_path)
node.xpath('*').each do |node_child|
case node_child.name
when 'Relationships'
parse(node_child)
end
end
self
end | ruby | def parse_file(file_path)
node = parse_xml(file_path)
node.xpath('*').each do |node_child|
case node_child.name
when 'Relationships'
parse(node_child)
end
end
self
end | [
"def",
"parse_file",
"(",
"file_path",
")",
"node",
"=",
"parse_xml",
"(",
"file_path",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'Relationships'",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] | Parse .rels file
@param file_path [String] path to file
@return [Relationships] | [
"Parse",
".",
"rels",
"file"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/relationships.rb#L34-L43 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/common_parser/common_data/relationships.rb | OoxmlParser.Relationships.target_by_type | def target_by_type(type)
result = []
@relationship.each do |cur_rels|
result << cur_rels.target if cur_rels.type.include?(type)
end
result
end | ruby | def target_by_type(type)
result = []
@relationship.each do |cur_rels|
result << cur_rels.target if cur_rels.type.include?(type)
end
result
end | [
"def",
"target_by_type",
"(",
"type",
")",
"result",
"=",
"[",
"]",
"@relationship",
".",
"each",
"do",
"|",
"cur_rels",
"|",
"result",
"<<",
"cur_rels",
".",
"target",
"if",
"cur_rels",
".",
"type",
".",
"include?",
"(",
"type",
")",
"end",
"result",
"end"
] | Get target names by type
@param type [String] type of target
@return [Array<String>] target names | [
"Get",
"target",
"names",
"by",
"type"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/relationships.rb#L58-L64 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/abstract_numbering/numbering_level.rb | OoxmlParser.NumberingLevel.parse | def parse(node)
node.attributes.each do |key, value|
case key
when 'ilvl'
@ilvl = value.value.to_f
end
end
node.xpath('*').each do |num_level_child|
case num_level_child.name
when 'start'
@start = ValuedChild.new(:integer, parent: self).parse(num_level_child)
when 'numFmt'
@numbering_format = NumberingFormat.new(parent: self).parse(num_level_child)
when 'lvlText'
@text = LevelText.new(parent: self).parse(num_level_child)
when 'lvlJc'
@justification = LevelJustification.new(parent: self).parse(num_level_child)
when 'pPr'
@paragraph_properties = ParagraphProperties.new(parent: self).parse(num_level_child)
when 'rPr'
@run_properties = RunProperties.new(parent: self).parse(num_level_child)
when 'suff'
@suffix = @suffix.parse(num_level_child)
end
end
self
end | ruby | def parse(node)
node.attributes.each do |key, value|
case key
when 'ilvl'
@ilvl = value.value.to_f
end
end
node.xpath('*').each do |num_level_child|
case num_level_child.name
when 'start'
@start = ValuedChild.new(:integer, parent: self).parse(num_level_child)
when 'numFmt'
@numbering_format = NumberingFormat.new(parent: self).parse(num_level_child)
when 'lvlText'
@text = LevelText.new(parent: self).parse(num_level_child)
when 'lvlJc'
@justification = LevelJustification.new(parent: self).parse(num_level_child)
when 'pPr'
@paragraph_properties = ParagraphProperties.new(parent: self).parse(num_level_child)
when 'rPr'
@run_properties = RunProperties.new(parent: self).parse(num_level_child)
when 'suff'
@suffix = @suffix.parse(num_level_child)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'ilvl'",
"@ilvl",
"=",
"value",
".",
"value",
".",
"to_f",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"num_level_child",
"|",
"case",
"num_level_child",
".",
"name",
"when",
"'start'",
"@start",
"=",
"ValuedChild",
".",
"new",
"(",
":integer",
",",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"num_level_child",
")",
"when",
"'numFmt'",
"@numbering_format",
"=",
"NumberingFormat",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"num_level_child",
")",
"when",
"'lvlText'",
"@text",
"=",
"LevelText",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"num_level_child",
")",
"when",
"'lvlJc'",
"@justification",
"=",
"LevelJustification",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"num_level_child",
")",
"when",
"'pPr'",
"@paragraph_properties",
"=",
"ParagraphProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"num_level_child",
")",
"when",
"'rPr'",
"@run_properties",
"=",
"RunProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"num_level_child",
")",
"when",
"'suff'",
"@suffix",
"=",
"@suffix",
".",
"parse",
"(",
"num_level_child",
")",
"end",
"end",
"self",
"end"
] | Parse Numbering Level data
@param [Nokogiri::XML:Element] node with Numbering Level data
@return [NumberingLevel] value of Numbering Level data | [
"Parse",
"Numbering",
"Level",
"data"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/abstract_numbering/numbering_level.rb#L34-L62 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs.rb | OoxmlParser.CellXfs.parse | def parse(node)
node.attributes.each do |key, value|
case key
when 'count'
@count = value.value.to_i
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'xf'
@xf_array << Xf.new(parent: self).parse(node_child)
end
end
self
end | ruby | def parse(node)
node.attributes.each do |key, value|
case key
when 'count'
@count = value.value.to_i
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'xf'
@xf_array << Xf.new(parent: self).parse(node_child)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'count'",
"@count",
"=",
"value",
".",
"value",
".",
"to_i",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'xf'",
"@xf_array",
"<<",
"Xf",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] | Parse CellXfs data
@param [Nokogiri::XML:Element] node with CellXfs data
@return [CellXfs] value of CellXfs data | [
"Parse",
"CellXfs",
"data"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs.rb#L18-L33 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_blip.rb | OoxmlParser.DocxBlip.parse | def parse(node)
blip_node = node.xpath('a:blip', 'xmlns:a' => 'http://schemas.openxmlformats.org/drawingml/2006/main').first
return self if blip_node.nil?
@file_reference = FileReference.new(parent: self).parse(blip_node)
self
end | ruby | def parse(node)
blip_node = node.xpath('a:blip', 'xmlns:a' => 'http://schemas.openxmlformats.org/drawingml/2006/main').first
return self if blip_node.nil?
@file_reference = FileReference.new(parent: self).parse(blip_node)
self
end | [
"def",
"parse",
"(",
"node",
")",
"blip_node",
"=",
"node",
".",
"xpath",
"(",
"'a:blip'",
",",
"'xmlns:a'",
"=>",
"'http://schemas.openxmlformats.org/drawingml/2006/main'",
")",
".",
"first",
"return",
"self",
"if",
"blip_node",
".",
"nil?",
"@file_reference",
"=",
"FileReference",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"blip_node",
")",
"self",
"end"
] | Parse DocxBlip object
@param node [Nokogiri::XML:Element] node to parse
@return [DocxBlip] result of parsing | [
"Parse",
"DocxBlip",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_blip.rb#L18-L24 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/graphic_frame/graphic_frame.rb | OoxmlParser.GraphicFrame.parse | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'xfrm'
@transform = DocxShapeSize.new(parent: self).parse(node_child)
when 'graphic'
graphic_data = []
node_child.xpath('*').each do |node_child_child|
case node_child_child.name
when 'graphicData'
node_child_child.xpath('*').each do |graphic_node_child|
case graphic_node_child.name
when 'tbl'
graphic_data << Table.new(parent: self).parse(graphic_node_child)
when 'chart'
OOXMLDocumentObject.add_to_xmls_stack(OOXMLDocumentObject.get_link_from_rels(graphic_node_child.attribute('id').value))
graphic_data << Chart.parse(parent: self)
OOXMLDocumentObject.xmls_stack.pop
when 'oleObj'
graphic_data << OleObject.new(parent: self).parse(graphic_node_child)
end
end
end
end
@graphic_data = graphic_data
when 'nvGraphicFramePr'
@non_visual_properties = NonVisualShapeProperties.new(parent: self).parse(node_child)
end
end
self
end | ruby | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'xfrm'
@transform = DocxShapeSize.new(parent: self).parse(node_child)
when 'graphic'
graphic_data = []
node_child.xpath('*').each do |node_child_child|
case node_child_child.name
when 'graphicData'
node_child_child.xpath('*').each do |graphic_node_child|
case graphic_node_child.name
when 'tbl'
graphic_data << Table.new(parent: self).parse(graphic_node_child)
when 'chart'
OOXMLDocumentObject.add_to_xmls_stack(OOXMLDocumentObject.get_link_from_rels(graphic_node_child.attribute('id').value))
graphic_data << Chart.parse(parent: self)
OOXMLDocumentObject.xmls_stack.pop
when 'oleObj'
graphic_data << OleObject.new(parent: self).parse(graphic_node_child)
end
end
end
end
@graphic_data = graphic_data
when 'nvGraphicFramePr'
@non_visual_properties = NonVisualShapeProperties.new(parent: self).parse(node_child)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'xfrm'",
"@transform",
"=",
"DocxShapeSize",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'graphic'",
"graphic_data",
"=",
"[",
"]",
"node_child",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child_child",
"|",
"case",
"node_child_child",
".",
"name",
"when",
"'graphicData'",
"node_child_child",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"graphic_node_child",
"|",
"case",
"graphic_node_child",
".",
"name",
"when",
"'tbl'",
"graphic_data",
"<<",
"Table",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"graphic_node_child",
")",
"when",
"'chart'",
"OOXMLDocumentObject",
".",
"add_to_xmls_stack",
"(",
"OOXMLDocumentObject",
".",
"get_link_from_rels",
"(",
"graphic_node_child",
".",
"attribute",
"(",
"'id'",
")",
".",
"value",
")",
")",
"graphic_data",
"<<",
"Chart",
".",
"parse",
"(",
"parent",
":",
"self",
")",
"OOXMLDocumentObject",
".",
"xmls_stack",
".",
"pop",
"when",
"'oleObj'",
"graphic_data",
"<<",
"OleObject",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"graphic_node_child",
")",
"end",
"end",
"end",
"end",
"@graphic_data",
"=",
"graphic_data",
"when",
"'nvGraphicFramePr'",
"@non_visual_properties",
"=",
"NonVisualShapeProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] | Parse GraphicFrame object
@param node [Nokogiri::XML:Element] node to parse
@return [GraphicFrame] result of parsing | [
"Parse",
"GraphicFrame",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/graphic_frame/graphic_frame.rb#L16-L46 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb | OoxmlParser.DocxShapeSize.parse | def parse(node)
node.attributes.each do |key, value|
case key
when 'rot'
@rotation = value.value.to_f
when 'flipH'
@flip_horizontal = attribute_enabled?(value)
when 'flipV'
@flip_vertical = attribute_enabled?(value)
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'off'
@offset = OOXMLCoordinates.parse(node_child, unit: :emu)
when 'ext'
@extent = OOXMLCoordinates.parse(node_child, x_attr: 'cx', y_attr: 'cy', unit: :emu)
when 'chOff'
@child_offset = OOXMLCoordinates.parse(node_child, unit: :emu)
when 'chExt'
@child_extent = OOXMLCoordinates.parse(node_child, x_attr: 'cx', y_attr: 'cy', unit: :emu)
end
end
self
end | ruby | def parse(node)
node.attributes.each do |key, value|
case key
when 'rot'
@rotation = value.value.to_f
when 'flipH'
@flip_horizontal = attribute_enabled?(value)
when 'flipV'
@flip_vertical = attribute_enabled?(value)
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'off'
@offset = OOXMLCoordinates.parse(node_child, unit: :emu)
when 'ext'
@extent = OOXMLCoordinates.parse(node_child, x_attr: 'cx', y_attr: 'cy', unit: :emu)
when 'chOff'
@child_offset = OOXMLCoordinates.parse(node_child, unit: :emu)
when 'chExt'
@child_extent = OOXMLCoordinates.parse(node_child, x_attr: 'cx', y_attr: 'cy', unit: :emu)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'rot'",
"@rotation",
"=",
"value",
".",
"value",
".",
"to_f",
"when",
"'flipH'",
"@flip_horizontal",
"=",
"attribute_enabled?",
"(",
"value",
")",
"when",
"'flipV'",
"@flip_vertical",
"=",
"attribute_enabled?",
"(",
"value",
")",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'off'",
"@offset",
"=",
"OOXMLCoordinates",
".",
"parse",
"(",
"node_child",
",",
"unit",
":",
":emu",
")",
"when",
"'ext'",
"@extent",
"=",
"OOXMLCoordinates",
".",
"parse",
"(",
"node_child",
",",
"x_attr",
":",
"'cx'",
",",
"y_attr",
":",
"'cy'",
",",
"unit",
":",
":emu",
")",
"when",
"'chOff'",
"@child_offset",
"=",
"OOXMLCoordinates",
".",
"parse",
"(",
"node_child",
",",
"unit",
":",
":emu",
")",
"when",
"'chExt'",
"@child_extent",
"=",
"OOXMLCoordinates",
".",
"parse",
"(",
"node_child",
",",
"x_attr",
":",
"'cx'",
",",
"y_attr",
":",
"'cy'",
",",
"unit",
":",
":emu",
")",
"end",
"end",
"self",
"end"
] | Parse DocxShapeSize object
@param node [Nokogiri::XML:Element] node to parse
@return [DocxShapeSize] result of parsing | [
"Parse",
"DocxShapeSize",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb#L17-L41 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_wrap_drawing.rb | OoxmlParser.DocxWrapDrawing.parse | def parse(node)
unless node.attribute('behindDoc').nil?
@wrap_text = :behind if node.attribute('behindDoc').value == '1'
@wrap_text = :infront if node.attribute('behindDoc').value == '0'
end
node.xpath('*').each do |node_child|
case node_child.name
when 'wrapSquare'
@wrap_text = :square
@distance_from_text = DocxDrawingDistanceFromText.new(parent: self).parse(node_child)
break
when 'wrapTight'
@wrap_text = :tight
@distance_from_text = DocxDrawingDistanceFromText.new(parent: self).parse(node_child)
break
when 'wrapThrough'
@wrap_text = :through
@distance_from_text = DocxDrawingDistanceFromText.new(parent: self).parse(node_child)
break
when 'wrapTopAndBottom'
@wrap_text = :topbottom
@distance_from_text = DocxDrawingDistanceFromText.new(parent: self).parse(node_child)
break
end
end
self
end | ruby | def parse(node)
unless node.attribute('behindDoc').nil?
@wrap_text = :behind if node.attribute('behindDoc').value == '1'
@wrap_text = :infront if node.attribute('behindDoc').value == '0'
end
node.xpath('*').each do |node_child|
case node_child.name
when 'wrapSquare'
@wrap_text = :square
@distance_from_text = DocxDrawingDistanceFromText.new(parent: self).parse(node_child)
break
when 'wrapTight'
@wrap_text = :tight
@distance_from_text = DocxDrawingDistanceFromText.new(parent: self).parse(node_child)
break
when 'wrapThrough'
@wrap_text = :through
@distance_from_text = DocxDrawingDistanceFromText.new(parent: self).parse(node_child)
break
when 'wrapTopAndBottom'
@wrap_text = :topbottom
@distance_from_text = DocxDrawingDistanceFromText.new(parent: self).parse(node_child)
break
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"unless",
"node",
".",
"attribute",
"(",
"'behindDoc'",
")",
".",
"nil?",
"@wrap_text",
"=",
":behind",
"if",
"node",
".",
"attribute",
"(",
"'behindDoc'",
")",
".",
"value",
"==",
"'1'",
"@wrap_text",
"=",
":infront",
"if",
"node",
".",
"attribute",
"(",
"'behindDoc'",
")",
".",
"value",
"==",
"'0'",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'wrapSquare'",
"@wrap_text",
"=",
":square",
"@distance_from_text",
"=",
"DocxDrawingDistanceFromText",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"break",
"when",
"'wrapTight'",
"@wrap_text",
"=",
":tight",
"@distance_from_text",
"=",
"DocxDrawingDistanceFromText",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"break",
"when",
"'wrapThrough'",
"@wrap_text",
"=",
":through",
"@distance_from_text",
"=",
"DocxDrawingDistanceFromText",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"break",
"when",
"'wrapTopAndBottom'",
"@wrap_text",
"=",
":topbottom",
"@distance_from_text",
"=",
"DocxDrawingDistanceFromText",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"break",
"end",
"end",
"self",
"end"
] | Parse DocxWrapDrawing object
@param node [Nokogiri::XML:Element] node to parse
@return [DocxWrapDrawing] result of parsing | [
"Parse",
"DocxWrapDrawing",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_wrap_drawing.rb#L14-L40 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/custom_geometry/docx_custom_geometry/docx_shape_line_path.rb | OoxmlParser.DocxShapeLinePath.parse | def parse(node)
node.attributes.each do |key, value|
case key
when 'w'
@width = value.value.to_f
when 'h'
@height = value.value.to_f
when 'stroke'
@stroke = value.value.to_f
end
end
node.xpath('*').each do |node_child|
@elements << DocxShapeLineElement.new(parent: self).parse(node_child)
end
self
end | ruby | def parse(node)
node.attributes.each do |key, value|
case key
when 'w'
@width = value.value.to_f
when 'h'
@height = value.value.to_f
when 'stroke'
@stroke = value.value.to_f
end
end
node.xpath('*').each do |node_child|
@elements << DocxShapeLineElement.new(parent: self).parse(node_child)
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'w'",
"@width",
"=",
"value",
".",
"value",
".",
"to_f",
"when",
"'h'",
"@height",
"=",
"value",
".",
"value",
".",
"to_f",
"when",
"'stroke'",
"@stroke",
"=",
"value",
".",
"value",
".",
"to_f",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"@elements",
"<<",
"DocxShapeLineElement",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"self",
"end"
] | Parse DocxShapeLinePath object
@param node [Nokogiri::XML:Element] node to parse
@return [DocxShapeLinePath] result of parsing | [
"Parse",
"DocxShapeLinePath",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/custom_geometry/docx_custom_geometry/docx_shape_line_path.rb#L15-L30 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/common_parser/common_data/colors/presentation_fill.rb | OoxmlParser.PresentationFill.parse | def parse(node)
return nil if node.xpath('*').empty?
node.xpath('*').each do |node_child|
case node_child.name
when 'gradFill'
@type = :gradient
@color = GradientColor.new(parent: self).parse(node_child)
when 'solidFill'
@type = :solid
@color = Color.new(parent: self).parse_color(node_child.xpath('*').first)
when 'blipFill'
@type = :image
@image = ImageFill.new(parent: self).parse(node_child)
when 'pattFill'
@type = :pattern
@pattern = PresentationPattern.new(parent: self).parse(node_child)
when 'noFill'
@type = :noneColor
@color = :none
end
end
return nil if @type.nil?
self
end | ruby | def parse(node)
return nil if node.xpath('*').empty?
node.xpath('*').each do |node_child|
case node_child.name
when 'gradFill'
@type = :gradient
@color = GradientColor.new(parent: self).parse(node_child)
when 'solidFill'
@type = :solid
@color = Color.new(parent: self).parse_color(node_child.xpath('*').first)
when 'blipFill'
@type = :image
@image = ImageFill.new(parent: self).parse(node_child)
when 'pattFill'
@type = :pattern
@pattern = PresentationPattern.new(parent: self).parse(node_child)
when 'noFill'
@type = :noneColor
@color = :none
end
end
return nil if @type.nil?
self
end | [
"def",
"parse",
"(",
"node",
")",
"return",
"nil",
"if",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"empty?",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'gradFill'",
"@type",
"=",
":gradient",
"@color",
"=",
"GradientColor",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'solidFill'",
"@type",
"=",
":solid",
"@color",
"=",
"Color",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse_color",
"(",
"node_child",
".",
"xpath",
"(",
"'*'",
")",
".",
"first",
")",
"when",
"'blipFill'",
"@type",
"=",
":image",
"@image",
"=",
"ImageFill",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'pattFill'",
"@type",
"=",
":pattern",
"@pattern",
"=",
"PresentationPattern",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'noFill'",
"@type",
"=",
":noneColor",
"@color",
"=",
":none",
"end",
"end",
"return",
"nil",
"if",
"@type",
".",
"nil?",
"self",
"end"
] | Parse PresentationFill object
@param node [Nokogiri::XML:Element] node to parse
@return [PresentationFill] result of parsing | [
"Parse",
"PresentationFill",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill.rb#L11-L36 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb | OoxmlParser.ParagraphProperties.parse | def parse(node)
@spacing.parse(node)
node.attributes.each do |key, value|
case key
when 'algn'
@align = value_to_symbol(value)
when 'lvl'
@level = value.value.to_i
when 'indent'
@indent = OoxmlSize.new(value.value.to_f, :emu)
when 'marR'
@margin_right = OoxmlSize.new(value.value.to_f, :emu)
when 'marL'
@margin_left = OoxmlSize.new(value.value.to_f, :emu)
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'buSzPct'
@numbering.size = node_child.attribute('val').value
when 'buFont'
@numbering.font = node_child.attribute('typeface').value
when 'buChar'
@numbering.symbol = node_child.attribute('char').value
when 'buAutoNum'
@numbering.type = node_child.attribute('type').value.to_sym
@numbering.start_at = node_child.attribute('startAt').value if node_child.attribute('startAt')
when 'framePr'
@frame_properties = FrameProperties.new(parent: self).parse(node_child)
when 'tabs'
@tabs = Tabs.new(parent: self).parse(node_child)
when 'tabLst'
@tabs = Tabs.new(parent: self).parse(node_child)
when 'ind'
@indent = Indents.new(parent: self).parse(node_child)
when 'rPr'
@run_properties = RunProperties.new(parent: self).parse(node_child)
when 'pBdr'
@paragraph_borders = ParagraphBorders.new(parent: self).parse(node_child)
when 'keepNext'
@keep_next = true
when 'sectPr'
@section_properties = PageProperties.new(parent: self).parse(node_child, @parent, DocxParagraphRun.new)
when 'spacing'
@spacing = ParagraphSpacing.new(parent: self).parse(node_child)
when 'jc'
@justification = value_to_symbol(node_child.attribute('val'))
when 'contextualSpacing'
@contextual_spacing = option_enabled?(node_child)
end
end
self
end | ruby | def parse(node)
@spacing.parse(node)
node.attributes.each do |key, value|
case key
when 'algn'
@align = value_to_symbol(value)
when 'lvl'
@level = value.value.to_i
when 'indent'
@indent = OoxmlSize.new(value.value.to_f, :emu)
when 'marR'
@margin_right = OoxmlSize.new(value.value.to_f, :emu)
when 'marL'
@margin_left = OoxmlSize.new(value.value.to_f, :emu)
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'buSzPct'
@numbering.size = node_child.attribute('val').value
when 'buFont'
@numbering.font = node_child.attribute('typeface').value
when 'buChar'
@numbering.symbol = node_child.attribute('char').value
when 'buAutoNum'
@numbering.type = node_child.attribute('type').value.to_sym
@numbering.start_at = node_child.attribute('startAt').value if node_child.attribute('startAt')
when 'framePr'
@frame_properties = FrameProperties.new(parent: self).parse(node_child)
when 'tabs'
@tabs = Tabs.new(parent: self).parse(node_child)
when 'tabLst'
@tabs = Tabs.new(parent: self).parse(node_child)
when 'ind'
@indent = Indents.new(parent: self).parse(node_child)
when 'rPr'
@run_properties = RunProperties.new(parent: self).parse(node_child)
when 'pBdr'
@paragraph_borders = ParagraphBorders.new(parent: self).parse(node_child)
when 'keepNext'
@keep_next = true
when 'sectPr'
@section_properties = PageProperties.new(parent: self).parse(node_child, @parent, DocxParagraphRun.new)
when 'spacing'
@spacing = ParagraphSpacing.new(parent: self).parse(node_child)
when 'jc'
@justification = value_to_symbol(node_child.attribute('val'))
when 'contextualSpacing'
@contextual_spacing = option_enabled?(node_child)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"@spacing",
".",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'algn'",
"@align",
"=",
"value_to_symbol",
"(",
"value",
")",
"when",
"'lvl'",
"@level",
"=",
"value",
".",
"value",
".",
"to_i",
"when",
"'indent'",
"@indent",
"=",
"OoxmlSize",
".",
"new",
"(",
"value",
".",
"value",
".",
"to_f",
",",
":emu",
")",
"when",
"'marR'",
"@margin_right",
"=",
"OoxmlSize",
".",
"new",
"(",
"value",
".",
"value",
".",
"to_f",
",",
":emu",
")",
"when",
"'marL'",
"@margin_left",
"=",
"OoxmlSize",
".",
"new",
"(",
"value",
".",
"value",
".",
"to_f",
",",
":emu",
")",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'buSzPct'",
"@numbering",
".",
"size",
"=",
"node_child",
".",
"attribute",
"(",
"'val'",
")",
".",
"value",
"when",
"'buFont'",
"@numbering",
".",
"font",
"=",
"node_child",
".",
"attribute",
"(",
"'typeface'",
")",
".",
"value",
"when",
"'buChar'",
"@numbering",
".",
"symbol",
"=",
"node_child",
".",
"attribute",
"(",
"'char'",
")",
".",
"value",
"when",
"'buAutoNum'",
"@numbering",
".",
"type",
"=",
"node_child",
".",
"attribute",
"(",
"'type'",
")",
".",
"value",
".",
"to_sym",
"@numbering",
".",
"start_at",
"=",
"node_child",
".",
"attribute",
"(",
"'startAt'",
")",
".",
"value",
"if",
"node_child",
".",
"attribute",
"(",
"'startAt'",
")",
"when",
"'framePr'",
"@frame_properties",
"=",
"FrameProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'tabs'",
"@tabs",
"=",
"Tabs",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'tabLst'",
"@tabs",
"=",
"Tabs",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'ind'",
"@indent",
"=",
"Indents",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'rPr'",
"@run_properties",
"=",
"RunProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'pBdr'",
"@paragraph_borders",
"=",
"ParagraphBorders",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'keepNext'",
"@keep_next",
"=",
"true",
"when",
"'sectPr'",
"@section_properties",
"=",
"PageProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
",",
"@parent",
",",
"DocxParagraphRun",
".",
"new",
")",
"when",
"'spacing'",
"@spacing",
"=",
"ParagraphSpacing",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'jc'",
"@justification",
"=",
"value_to_symbol",
"(",
"node_child",
".",
"attribute",
"(",
"'val'",
")",
")",
"when",
"'contextualSpacing'",
"@contextual_spacing",
"=",
"option_enabled?",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] | Parse ParagraphProperties object
@param node [Nokogiri::XML:Element] node to parse
@return [ParagraphProperties] result of parsing | [
"Parse",
"ParagraphProperties",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb#L45-L97 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/common_parser/common_data/table/row/row.rb | OoxmlParser.TableRow.parse | def parse(node)
root_object.default_font_style = FontStyle.new(true) # TODO: Add correct parsing of TableStyle.xml file and use it
node.attributes.each do |key, value|
case key
when 'h'
@height = OoxmlSize.new(value.value.to_f, :emu)
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'trPr'
@table_row_properties = TableRowProperties.new(parent: self).parse(node_child)
when 'tc'
@cells << TableCell.new(parent: self).parse(node_child)
end
end
root_object.default_font_style = FontStyle.new
self
end | ruby | def parse(node)
root_object.default_font_style = FontStyle.new(true) # TODO: Add correct parsing of TableStyle.xml file and use it
node.attributes.each do |key, value|
case key
when 'h'
@height = OoxmlSize.new(value.value.to_f, :emu)
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'trPr'
@table_row_properties = TableRowProperties.new(parent: self).parse(node_child)
when 'tc'
@cells << TableCell.new(parent: self).parse(node_child)
end
end
root_object.default_font_style = FontStyle.new
self
end | [
"def",
"parse",
"(",
"node",
")",
"root_object",
".",
"default_font_style",
"=",
"FontStyle",
".",
"new",
"(",
"true",
")",
"# TODO: Add correct parsing of TableStyle.xml file and use it",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'h'",
"@height",
"=",
"OoxmlSize",
".",
"new",
"(",
"value",
".",
"value",
".",
"to_f",
",",
":emu",
")",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'trPr'",
"@table_row_properties",
"=",
"TableRowProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'tc'",
"@cells",
"<<",
"TableCell",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"root_object",
".",
"default_font_style",
"=",
"FontStyle",
".",
"new",
"self",
"end"
] | Parse TableRow object
@param node [Nokogiri::XML:Element] node to parse
@return [TableRow] result of parsing | [
"Parse",
"TableRow",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/table/row/row.rb#L17-L35 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing/xlsx_drawing_position_parameters.rb | OoxmlParser.XlsxDrawingPositionParameters.parse | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'col'
@column = Coordinates.get_column_name(node_child.text.to_i + 1)
when 'colOff'
@column_offset = OoxmlSize.new(node_child.text.to_f, :emu)
when 'row'
@row = node_child.text.to_i + 1
when 'rowOff'
@row_offset = OoxmlSize.new(node_child.text.to_f, :emu)
end
end
self
end | ruby | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'col'
@column = Coordinates.get_column_name(node_child.text.to_i + 1)
when 'colOff'
@column_offset = OoxmlSize.new(node_child.text.to_f, :emu)
when 'row'
@row = node_child.text.to_i + 1
when 'rowOff'
@row_offset = OoxmlSize.new(node_child.text.to_f, :emu)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'col'",
"@column",
"=",
"Coordinates",
".",
"get_column_name",
"(",
"node_child",
".",
"text",
".",
"to_i",
"+",
"1",
")",
"when",
"'colOff'",
"@column_offset",
"=",
"OoxmlSize",
".",
"new",
"(",
"node_child",
".",
"text",
".",
"to_f",
",",
":emu",
")",
"when",
"'row'",
"@row",
"=",
"node_child",
".",
"text",
".",
"to_i",
"+",
"1",
"when",
"'rowOff'",
"@row_offset",
"=",
"OoxmlSize",
".",
"new",
"(",
"node_child",
".",
"text",
".",
"to_f",
",",
":emu",
")",
"end",
"end",
"self",
"end"
] | Parse XlsxDrawingPositionParameters object
@param node [Nokogiri::XML:Element] node to parse
@return [XlsxDrawingPositionParameters] result of parsing | [
"Parse",
"XlsxDrawingPositionParameters",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing/xlsx_drawing_position_parameters.rb#L9-L23 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fills/fill.rb | OoxmlParser.Fill.parse | def parse(node)
node.attributes.each do |key, value|
case key
when 'color2'
@color2 = Color.new(parent: self).parse_hex_string(value.value.split(' ').first.delete('#'))
when 'id'
@id = value.value.to_s
@file = FileReference.new(parent: self).parse(node)
when 'type'
@type = value_to_symbol(value)
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'patternFill'
@pattern_fill = PatternFill.new(parent: self).parse(node_child)
end
end
self
end | ruby | def parse(node)
node.attributes.each do |key, value|
case key
when 'color2'
@color2 = Color.new(parent: self).parse_hex_string(value.value.split(' ').first.delete('#'))
when 'id'
@id = value.value.to_s
@file = FileReference.new(parent: self).parse(node)
when 'type'
@type = value_to_symbol(value)
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'patternFill'
@pattern_fill = PatternFill.new(parent: self).parse(node_child)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'color2'",
"@color2",
"=",
"Color",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse_hex_string",
"(",
"value",
".",
"value",
".",
"split",
"(",
"' '",
")",
".",
"first",
".",
"delete",
"(",
"'#'",
")",
")",
"when",
"'id'",
"@id",
"=",
"value",
".",
"value",
".",
"to_s",
"@file",
"=",
"FileReference",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node",
")",
"when",
"'type'",
"@type",
"=",
"value_to_symbol",
"(",
"value",
")",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'patternFill'",
"@pattern_fill",
"=",
"PatternFill",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] | Parse Fill data
@param [Nokogiri::XML:Element] node with Fill data
@return [Fill] value of Fill data | [
"Parse",
"Fill",
"data"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fills/fill.rb#L19-L39 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/docx_parser/docx_data/document_structure/styles/document_defaults.rb | OoxmlParser.DocumentDefaults.parse | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'rPrDefault'
@run_properties_default = RunPropertiesDefault.new(parent: self).parse(node_child)
when 'pPrDefault'
@paragraph_properties_default = ParagraphPropertiesDefault.new(parent: self).parse(node_child)
end
end
self
end | ruby | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'rPrDefault'
@run_properties_default = RunPropertiesDefault.new(parent: self).parse(node_child)
when 'pPrDefault'
@paragraph_properties_default = ParagraphPropertiesDefault.new(parent: self).parse(node_child)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'rPrDefault'",
"@run_properties_default",
"=",
"RunPropertiesDefault",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'pPrDefault'",
"@paragraph_properties_default",
"=",
"ParagraphPropertiesDefault",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] | Parse Bookmark object
@param node [Nokogiri::XML:Element] node to parse
@return [Bookmark] result of parsing | [
"Parse",
"Bookmark",
"object"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/docx_parser/docx_data/document_structure/styles/document_defaults.rb#L14-L24 | train |
ONLYOFFICE/ooxml_parser | lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fills/fill/pattern_fill.rb | OoxmlParser.PatternFill.parse | def parse(node)
node.attributes.each do |key, value|
case key
when 'patternType'
@pattern_type = value.value.to_sym
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'fgColor'
@foreground_color = OoxmlColor.new(parent: self).parse(node_child)
when 'bgColor'
@background_color = OoxmlColor.new(parent: self).parse(node_child)
end
end
self
end | ruby | def parse(node)
node.attributes.each do |key, value|
case key
when 'patternType'
@pattern_type = value.value.to_sym
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'fgColor'
@foreground_color = OoxmlColor.new(parent: self).parse(node_child)
when 'bgColor'
@background_color = OoxmlColor.new(parent: self).parse(node_child)
end
end
self
end | [
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'patternType'",
"@pattern_type",
"=",
"value",
".",
"value",
".",
"to_sym",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'fgColor'",
"@foreground_color",
"=",
"OoxmlColor",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'bgColor'",
"@background_color",
"=",
"OoxmlColor",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] | Parse PatternFill data
@param [Nokogiri::XML:Element] node with PatternFill data
@return [PatternFill] value of PatternFill data | [
"Parse",
"PatternFill",
"data"
] | 08452315cde52fa94d8cb3e1eff1db4ea33abc88 | https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fills/fill/pattern_fill.rb#L14-L31 | train |
stewartmckee/cobweb | lib/crawl.rb | CobwebModule.Crawl.set_base_url | def set_base_url(redis)
if redis.get("base_url").nil?
unless !defined?(content.redirect_through) || content.redirect_through.empty? || !@options[:first_page_redirect_internal]
uri = Addressable::URI.parse(content.redirect_through.last)
redis.sadd("internal_urls", [uri.scheme, "://", uri.host, "/*"].join)
end
redis.set("base_url", content.url)
end
end | ruby | def set_base_url(redis)
if redis.get("base_url").nil?
unless !defined?(content.redirect_through) || content.redirect_through.empty? || !@options[:first_page_redirect_internal]
uri = Addressable::URI.parse(content.redirect_through.last)
redis.sadd("internal_urls", [uri.scheme, "://", uri.host, "/*"].join)
end
redis.set("base_url", content.url)
end
end | [
"def",
"set_base_url",
"(",
"redis",
")",
"if",
"redis",
".",
"get",
"(",
"\"base_url\"",
")",
".",
"nil?",
"unless",
"!",
"defined?",
"(",
"content",
".",
"redirect_through",
")",
"||",
"content",
".",
"redirect_through",
".",
"empty?",
"||",
"!",
"@options",
"[",
":first_page_redirect_internal",
"]",
"uri",
"=",
"Addressable",
"::",
"URI",
".",
"parse",
"(",
"content",
".",
"redirect_through",
".",
"last",
")",
"redis",
".",
"sadd",
"(",
"\"internal_urls\"",
",",
"[",
"uri",
".",
"scheme",
",",
"\"://\"",
",",
"uri",
".",
"host",
",",
"\"/*\"",
"]",
".",
"join",
")",
"end",
"redis",
".",
"set",
"(",
"\"base_url\"",
",",
"content",
".",
"url",
")",
"end",
"end"
] | Sets the base url in redis. If the first page is a redirect, it sets the base_url to the destination | [
"Sets",
"the",
"base",
"url",
"in",
"redis",
".",
"If",
"the",
"first",
"page",
"is",
"a",
"redirect",
"it",
"sets",
"the",
"base_url",
"to",
"the",
"destination"
] | a957f4519e544c09e6f32a497cac2e991e5dbac3 | https://github.com/stewartmckee/cobweb/blob/a957f4519e544c09e6f32a497cac2e991e5dbac3/lib/crawl.rb#L348-L356 | train |
yihangho/emoji-for-jekyll | lib/emoji_for_jekyll.rb | EmojiForJekyll.EmojiGenerator.convert | def convert(key, block = nil)
if block.nil? or block.call(key)
img_tag(key)
else
":#{key}:"
end
end | ruby | def convert(key, block = nil)
if block.nil? or block.call(key)
img_tag(key)
else
":#{key}:"
end
end | [
"def",
"convert",
"(",
"key",
",",
"block",
"=",
"nil",
")",
"if",
"block",
".",
"nil?",
"or",
"block",
".",
"call",
"(",
"key",
")",
"img_tag",
"(",
"key",
")",
"else",
"\":#{key}:\"",
"end",
"end"
] | convert takes in the key to the emoji to be converted and an optional block
If block is provided, conversion will be done only if this block evaluates to true. | [
"convert",
"takes",
"in",
"the",
"key",
"to",
"the",
"emoji",
"to",
"be",
"converted",
"and",
"an",
"optional",
"block",
"If",
"block",
"is",
"provided",
"conversion",
"will",
"be",
"done",
"only",
"if",
"this",
"block",
"evaluates",
"to",
"true",
"."
] | 2946d1dc5a0419af42b28fe5af9275494bf25316 | https://github.com/yihangho/emoji-for-jekyll/blob/2946d1dc5a0419af42b28fe5af9275494bf25316/lib/emoji_for_jekyll.rb#L82-L88 | train |
stretcher/stretcher | lib/stretcher/index_type.rb | Stretcher.IndexType.get | def get(id, options={}, raw=false)
if options == true || options == false # Support raw as second argument, legacy API
raw = true
options = {}
end
res = request(:get, id, options)
raw ? res : (res["_source"] || res["fields"])
end | ruby | def get(id, options={}, raw=false)
if options == true || options == false # Support raw as second argument, legacy API
raw = true
options = {}
end
res = request(:get, id, options)
raw ? res : (res["_source"] || res["fields"])
end | [
"def",
"get",
"(",
"id",
",",
"options",
"=",
"{",
"}",
",",
"raw",
"=",
"false",
")",
"if",
"options",
"==",
"true",
"||",
"options",
"==",
"false",
"# Support raw as second argument, legacy API",
"raw",
"=",
"true",
"options",
"=",
"{",
"}",
"end",
"res",
"=",
"request",
"(",
":get",
",",
"id",
",",
"options",
")",
"raw",
"?",
"res",
":",
"(",
"res",
"[",
"\"_source\"",
"]",
"||",
"res",
"[",
"\"fields\"",
"]",
")",
"end"
] | Retrieves the document by ID.
Normally this returns the contents of _source, however, if the 'raw' flag is passed in, it will return the full response hash.
Returns nil if the document does not exist.
The :fields argument can either be a csv String or an Array. e.g. [:field1,'field2] or "field1,field2".
If the fields parameter is passed in those fields are returned instead of _source.
If, you include _source as a field, along with other fields you MUST set the raw flag to true to
receive both fields and _source. Otherwise, only _source will be returned | [
"Retrieves",
"the",
"document",
"by",
"ID",
".",
"Normally",
"this",
"returns",
"the",
"contents",
"of",
"_source",
"however",
"if",
"the",
"raw",
"flag",
"is",
"passed",
"in",
"it",
"will",
"return",
"the",
"full",
"response",
"hash",
".",
"Returns",
"nil",
"if",
"the",
"document",
"does",
"not",
"exist",
"."
] | 2ae1b4b012e7d66dfd6028da77a948c55b36fb80 | https://github.com/stretcher/stretcher/blob/2ae1b4b012e7d66dfd6028da77a948c55b36fb80/lib/stretcher/index_type.rb#L23-L31 | train |
stretcher/stretcher | lib/stretcher/index_type.rb | Stretcher.IndexType.delete | def delete(id, options={})
request :delete, id, options
rescue Stretcher::RequestError => e
raise e if e.http_response.status != 404
false
end | ruby | def delete(id, options={})
request :delete, id, options
rescue Stretcher::RequestError => e
raise e if e.http_response.status != 404
false
end | [
"def",
"delete",
"(",
"id",
",",
"options",
"=",
"{",
"}",
")",
"request",
":delete",
",",
"id",
",",
"options",
"rescue",
"Stretcher",
"::",
"RequestError",
"=>",
"e",
"raise",
"e",
"if",
"e",
".",
"http_response",
".",
"status",
"!=",
"404",
"false",
"end"
] | Deletes the document with the given ID | [
"Deletes",
"the",
"document",
"with",
"the",
"given",
"ID"
] | 2ae1b4b012e7d66dfd6028da77a948c55b36fb80 | https://github.com/stretcher/stretcher/blob/2ae1b4b012e7d66dfd6028da77a948c55b36fb80/lib/stretcher/index_type.rb#L69-L74 | train |
stretcher/stretcher | lib/stretcher/index_type.rb | Stretcher.IndexType.exists? | def exists?(id=nil)
request :head, id
true
rescue Stretcher::RequestError::NotFound => e
false
end | ruby | def exists?(id=nil)
request :head, id
true
rescue Stretcher::RequestError::NotFound => e
false
end | [
"def",
"exists?",
"(",
"id",
"=",
"nil",
")",
"request",
":head",
",",
"id",
"true",
"rescue",
"Stretcher",
"::",
"RequestError",
"::",
"NotFound",
"=>",
"e",
"false",
"end"
] | Check if this index type is defined, if passed an id
this will check if the given document exists | [
"Check",
"if",
"this",
"index",
"type",
"is",
"defined",
"if",
"passed",
"an",
"id",
"this",
"will",
"check",
"if",
"the",
"given",
"document",
"exists"
] | 2ae1b4b012e7d66dfd6028da77a948c55b36fb80 | https://github.com/stretcher/stretcher/blob/2ae1b4b012e7d66dfd6028da77a948c55b36fb80/lib/stretcher/index_type.rb#L110-L115 | train |
stretcher/stretcher | lib/stretcher/es_component.rb | Stretcher.EsComponent.do_search | def do_search(generic_opts={}, explicit_body=nil)
query_opts = {}
body = nil
if explicit_body
query_opts = generic_opts
body = explicit_body
else
body = generic_opts
end
response = request(:get, "_search", query_opts, nil, {}, :mashify => false) do |req|
req.body = body
end
SearchResults.new(response)
end | ruby | def do_search(generic_opts={}, explicit_body=nil)
query_opts = {}
body = nil
if explicit_body
query_opts = generic_opts
body = explicit_body
else
body = generic_opts
end
response = request(:get, "_search", query_opts, nil, {}, :mashify => false) do |req|
req.body = body
end
SearchResults.new(response)
end | [
"def",
"do_search",
"(",
"generic_opts",
"=",
"{",
"}",
",",
"explicit_body",
"=",
"nil",
")",
"query_opts",
"=",
"{",
"}",
"body",
"=",
"nil",
"if",
"explicit_body",
"query_opts",
"=",
"generic_opts",
"body",
"=",
"explicit_body",
"else",
"body",
"=",
"generic_opts",
"end",
"response",
"=",
"request",
"(",
":get",
",",
"\"_search\"",
",",
"query_opts",
",",
"nil",
",",
"{",
"}",
",",
":mashify",
"=>",
"false",
")",
"do",
"|",
"req",
"|",
"req",
".",
"body",
"=",
"body",
"end",
"SearchResults",
".",
"new",
"(",
"response",
")",
"end"
] | Many of the methods marked protected are called by one line shims in subclasses. This is mostly to facilitate
better looking rdocs | [
"Many",
"of",
"the",
"methods",
"marked",
"protected",
"are",
"called",
"by",
"one",
"line",
"shims",
"in",
"subclasses",
".",
"This",
"is",
"mostly",
"to",
"facilitate",
"better",
"looking",
"rdocs"
] | 2ae1b4b012e7d66dfd6028da77a948c55b36fb80 | https://github.com/stretcher/stretcher/blob/2ae1b4b012e7d66dfd6028da77a948c55b36fb80/lib/stretcher/es_component.rb#L8-L22 | train |
stretcher/stretcher | lib/stretcher/server.rb | Stretcher.Server.check_response | def check_response(res, options)
if res.status >= 200 && res.status <= 299
if(options[:mashify] && res.body.instance_of?(Hash))
Hashie::Mash.new(res.body)
else
res.body
end
elsif [404, 410].include? res.status
err_str = "Error processing request: (#{res.status})! #{res.env[:method]} URL: #{res.env[:url]}"
err_str << "\n Resp Body: #{res.body}"
raise RequestError::NotFound.new(res), err_str
else
err_str = "Error processing request (#{res.status})! #{res.env[:method]} URL: #{res.env[:url]}"
err_str << "\n Resp Body: #{res.body}"
raise RequestError.new(res), err_str
end
end | ruby | def check_response(res, options)
if res.status >= 200 && res.status <= 299
if(options[:mashify] && res.body.instance_of?(Hash))
Hashie::Mash.new(res.body)
else
res.body
end
elsif [404, 410].include? res.status
err_str = "Error processing request: (#{res.status})! #{res.env[:method]} URL: #{res.env[:url]}"
err_str << "\n Resp Body: #{res.body}"
raise RequestError::NotFound.new(res), err_str
else
err_str = "Error processing request (#{res.status})! #{res.env[:method]} URL: #{res.env[:url]}"
err_str << "\n Resp Body: #{res.body}"
raise RequestError.new(res), err_str
end
end | [
"def",
"check_response",
"(",
"res",
",",
"options",
")",
"if",
"res",
".",
"status",
">=",
"200",
"&&",
"res",
".",
"status",
"<=",
"299",
"if",
"(",
"options",
"[",
":mashify",
"]",
"&&",
"res",
".",
"body",
".",
"instance_of?",
"(",
"Hash",
")",
")",
"Hashie",
"::",
"Mash",
".",
"new",
"(",
"res",
".",
"body",
")",
"else",
"res",
".",
"body",
"end",
"elsif",
"[",
"404",
",",
"410",
"]",
".",
"include?",
"res",
".",
"status",
"err_str",
"=",
"\"Error processing request: (#{res.status})! #{res.env[:method]} URL: #{res.env[:url]}\"",
"err_str",
"<<",
"\"\\n Resp Body: #{res.body}\"",
"raise",
"RequestError",
"::",
"NotFound",
".",
"new",
"(",
"res",
")",
",",
"err_str",
"else",
"err_str",
"=",
"\"Error processing request (#{res.status})! #{res.env[:method]} URL: #{res.env[:url]}\"",
"err_str",
"<<",
"\"\\n Resp Body: #{res.body}\"",
"raise",
"RequestError",
".",
"new",
"(",
"res",
")",
",",
"err_str",
"end",
"end"
] | Internal use only
Check response codes from request | [
"Internal",
"use",
"only",
"Check",
"response",
"codes",
"from",
"request"
] | 2ae1b4b012e7d66dfd6028da77a948c55b36fb80 | https://github.com/stretcher/stretcher/blob/2ae1b4b012e7d66dfd6028da77a948c55b36fb80/lib/stretcher/server.rb#L246-L262 | train |
stretcher/stretcher | lib/stretcher/alias.rb | Stretcher.Alias.create | def create(options = {})
request(:put) do |req|
req.body = {
actions: [
add: options.merge(:alias => @name)
]
}
end
end | ruby | def create(options = {})
request(:put) do |req|
req.body = {
actions: [
add: options.merge(:alias => @name)
]
}
end
end | [
"def",
"create",
"(",
"options",
"=",
"{",
"}",
")",
"request",
"(",
":put",
")",
"do",
"|",
"req",
"|",
"req",
".",
"body",
"=",
"{",
"actions",
":",
"[",
"add",
":",
"options",
".",
"merge",
"(",
":alias",
"=>",
"@name",
")",
"]",
"}",
"end",
"end"
] | Create the alias in elastic search with the given options
my_alias.create({ filter: { term: { user_id: 1 } } }) | [
"Create",
"the",
"alias",
"in",
"elastic",
"search",
"with",
"the",
"given",
"options"
] | 2ae1b4b012e7d66dfd6028da77a948c55b36fb80 | https://github.com/stretcher/stretcher/blob/2ae1b4b012e7d66dfd6028da77a948c55b36fb80/lib/stretcher/alias.rb#L27-L35 | train |
salesforce/flo | lib/flo/task.rb | Flo.Task.call | def call(args=[])
raise ArgumentError.new("Expected Array") unless args.is_a? Array
@provider.public_send(method_sym, *merged_evaluated_args(args.dup))
end | ruby | def call(args=[])
raise ArgumentError.new("Expected Array") unless args.is_a? Array
@provider.public_send(method_sym, *merged_evaluated_args(args.dup))
end | [
"def",
"call",
"(",
"args",
"=",
"[",
"]",
")",
"raise",
"ArgumentError",
".",
"new",
"(",
"\"Expected Array\"",
")",
"unless",
"args",
".",
"is_a?",
"Array",
"@provider",
".",
"public_send",
"(",
"method_sym",
",",
"merged_evaluated_args",
"(",
"args",
".",
"dup",
")",
")",
"end"
] | Creates a new Task instance
@param [Provider] provider The provider to send the message to
@param [Symbol] The method you wish to call on the provider
@param [Hash] provider_options={} A hash of options to be passed when
invoking the method on the provider. Any lambda values will be called
during the execution stage when {#call} is invoked
Call invokes the task on the provider instance. Additional parameters can be
passed in that are merged into the parameters that were provided in {initialize}.
Proc values will be evaluated before being passed to the provider.
@param [Array] args=[] Additional arguments to pass to the provider method
@return [#success?] Response of the provider's method | [
"Creates",
"a",
"new",
"Task",
"instance"
] | 34c01f22e0a5d065f879aaed9fbdf3f2a9b2163a | https://github.com/salesforce/flo/blob/34c01f22e0a5d065f879aaed9fbdf3f2a9b2163a/lib/flo/task.rb#L34-L37 | train |
salesforce/flo | lib/flo/task.rb | Flo.Task.evaluate_proc_values | def evaluate_proc_values(args=[])
args.collect do |arg|
case arg
when Proc
arg.call
when Hash
hsh = {}
arg.each do |k, v|
hsh[k] = v.is_a?(Proc) ? v.call : v
end
hsh
else
arg
end
end
end | ruby | def evaluate_proc_values(args=[])
args.collect do |arg|
case arg
when Proc
arg.call
when Hash
hsh = {}
arg.each do |k, v|
hsh[k] = v.is_a?(Proc) ? v.call : v
end
hsh
else
arg
end
end
end | [
"def",
"evaluate_proc_values",
"(",
"args",
"=",
"[",
"]",
")",
"args",
".",
"collect",
"do",
"|",
"arg",
"|",
"case",
"arg",
"when",
"Proc",
"arg",
".",
"call",
"when",
"Hash",
"hsh",
"=",
"{",
"}",
"arg",
".",
"each",
"do",
"|",
"k",
",",
"v",
"|",
"hsh",
"[",
"k",
"]",
"=",
"v",
".",
"is_a?",
"(",
"Proc",
")",
"?",
"v",
".",
"call",
":",
"v",
"end",
"hsh",
"else",
"arg",
"end",
"end",
"end"
] | For each value in the args array, evaluate any procs.
If the value is a hash, evaluate any values in the hash
that are procs. | [
"For",
"each",
"value",
"in",
"the",
"args",
"array",
"evaluate",
"any",
"procs",
".",
"If",
"the",
"value",
"is",
"a",
"hash",
"evaluate",
"any",
"values",
"in",
"the",
"hash",
"that",
"are",
"procs",
"."
] | 34c01f22e0a5d065f879aaed9fbdf3f2a9b2163a | https://github.com/salesforce/flo/blob/34c01f22e0a5d065f879aaed9fbdf3f2a9b2163a/lib/flo/task.rb#L54-L69 | train |
maestrano/mno-enterprise | core/lib/mno_enterprise/smtp_client.rb | MnoEnterprise.SmtpClient.deliver | def deliver(template, from, to, vars={}, opts={})
@info = vars
@info[:company] = from[:name]
mail(
from: format_sender(from),
to: to[:email],
subject: humanize(template),
template_path: 'system_notifications',
template_name: template
)
end | ruby | def deliver(template, from, to, vars={}, opts={})
@info = vars
@info[:company] = from[:name]
mail(
from: format_sender(from),
to: to[:email],
subject: humanize(template),
template_path: 'system_notifications',
template_name: template
)
end | [
"def",
"deliver",
"(",
"template",
",",
"from",
",",
"to",
",",
"vars",
"=",
"{",
"}",
",",
"opts",
"=",
"{",
"}",
")",
"@info",
"=",
"vars",
"@info",
"[",
":company",
"]",
"=",
"from",
"[",
":name",
"]",
"mail",
"(",
"from",
":",
"format_sender",
"(",
"from",
")",
",",
"to",
":",
"to",
"[",
":email",
"]",
",",
"subject",
":",
"humanize",
"(",
"template",
")",
",",
"template_path",
":",
"'system_notifications'",
",",
"template_name",
":",
"template",
")",
"end"
] | Send SMTP template - terminal mailing part | [
"Send",
"SMTP",
"template",
"-",
"terminal",
"mailing",
"part"
] | bd957f523959531926e2bf844608d77addef2047 | https://github.com/maestrano/mno-enterprise/blob/bd957f523959531926e2bf844608d77addef2047/core/lib/mno_enterprise/smtp_client.rb#L9-L20 | train |
maestrano/mno-enterprise | api/lib/mno_enterprise/intercom_events_listener.rb | MnoEnterprise.IntercomEventsListener.tag_user | def tag_user(user)
if user.meta_data && user.meta_data[:source].present?
intercom.tags.tag(name: user.meta_data[:source], users: [{user_id: user.id}])
end
end | ruby | def tag_user(user)
if user.meta_data && user.meta_data[:source].present?
intercom.tags.tag(name: user.meta_data[:source], users: [{user_id: user.id}])
end
end | [
"def",
"tag_user",
"(",
"user",
")",
"if",
"user",
".",
"meta_data",
"&&",
"user",
".",
"meta_data",
"[",
":source",
"]",
".",
"present?",
"intercom",
".",
"tags",
".",
"tag",
"(",
"name",
":",
"user",
".",
"meta_data",
"[",
":source",
"]",
",",
"users",
":",
"[",
"{",
"user_id",
":",
"user",
".",
"id",
"}",
"]",
")",
"end",
"end"
] | If a source is set, tag the user with it | [
"If",
"a",
"source",
"is",
"set",
"tag",
"the",
"user",
"with",
"it"
] | bd957f523959531926e2bf844608d77addef2047 | https://github.com/maestrano/mno-enterprise/blob/bd957f523959531926e2bf844608d77addef2047/api/lib/mno_enterprise/intercom_events_listener.rb#L65-L69 | train |
maestrano/mno-enterprise | api/app/controllers/mno_enterprise/jpi/v1/admin/invites_controller.rb | MnoEnterprise::Jpi::V1::Admin.InvitesController.send_org_invite | def send_org_invite(user, invite)
# Generate token if not generated
user.send(:generate_confirmation_token!) if !user.confirmed? && user.confirmation_token.blank?
MnoEnterprise::SystemNotificationMailer.organization_invite(invite).deliver_later
# Update staged invite status
invite.status = 'pending' if invite.status == 'staged'
invite.notification_sent_at = Time.now unless invite.notification_sent_at.present?
invite.save
end | ruby | def send_org_invite(user, invite)
# Generate token if not generated
user.send(:generate_confirmation_token!) if !user.confirmed? && user.confirmation_token.blank?
MnoEnterprise::SystemNotificationMailer.organization_invite(invite).deliver_later
# Update staged invite status
invite.status = 'pending' if invite.status == 'staged'
invite.notification_sent_at = Time.now unless invite.notification_sent_at.present?
invite.save
end | [
"def",
"send_org_invite",
"(",
"user",
",",
"invite",
")",
"# Generate token if not generated",
"user",
".",
"send",
"(",
":generate_confirmation_token!",
")",
"if",
"!",
"user",
".",
"confirmed?",
"&&",
"user",
".",
"confirmation_token",
".",
"blank?",
"MnoEnterprise",
"::",
"SystemNotificationMailer",
".",
"organization_invite",
"(",
"invite",
")",
".",
"deliver_later",
"# Update staged invite status",
"invite",
".",
"status",
"=",
"'pending'",
"if",
"invite",
".",
"status",
"==",
"'staged'",
"invite",
".",
"notification_sent_at",
"=",
"Time",
".",
"now",
"unless",
"invite",
".",
"notification_sent_at",
".",
"present?",
"invite",
".",
"save",
"end"
] | Send the org invite and update the status | [
"Send",
"the",
"org",
"invite",
"and",
"update",
"the",
"status"
] | bd957f523959531926e2bf844608d77addef2047 | https://github.com/maestrano/mno-enterprise/blob/bd957f523959531926e2bf844608d77addef2047/api/app/controllers/mno_enterprise/jpi/v1/admin/invites_controller.rb#L28-L38 | train |
maestrano/mno-enterprise | api/app/controllers/mno_enterprise/jpi/v1/base_resource_controller.rb | MnoEnterprise.Jpi::V1::BaseResourceController.check_authorization | def check_authorization
unless current_user
render nothing: true, status: :unauthorized
return false
end
if params[:organization_id] && !parent_organization
render nothing: true, status: :forbidden
return false
end
true
end | ruby | def check_authorization
unless current_user
render nothing: true, status: :unauthorized
return false
end
if params[:organization_id] && !parent_organization
render nothing: true, status: :forbidden
return false
end
true
end | [
"def",
"check_authorization",
"unless",
"current_user",
"render",
"nothing",
":",
"true",
",",
"status",
":",
":unauthorized",
"return",
"false",
"end",
"if",
"params",
"[",
":organization_id",
"]",
"&&",
"!",
"parent_organization",
"render",
"nothing",
":",
"true",
",",
"status",
":",
":forbidden",
"return",
"false",
"end",
"true",
"end"
] | Check current user is logged in
Check organization is valid if specified | [
"Check",
"current",
"user",
"is",
"logged",
"in",
"Check",
"organization",
"is",
"valid",
"if",
"specified"
] | bd957f523959531926e2bf844608d77addef2047 | https://github.com/maestrano/mno-enterprise/blob/bd957f523959531926e2bf844608d77addef2047/api/app/controllers/mno_enterprise/jpi/v1/base_resource_controller.rb#L20-L30 | train |
maestrano/mno-enterprise | core/app/models/mno_enterprise/base_resource.rb | MnoEnterprise.BaseResource.save! | def save!(options={})
if perform_validations(options)
ret = super()
process_response_errors
raise_record_invalid if self.errors.any?
ret
else
raise_record_invalid
end
end | ruby | def save!(options={})
if perform_validations(options)
ret = super()
process_response_errors
raise_record_invalid if self.errors.any?
ret
else
raise_record_invalid
end
end | [
"def",
"save!",
"(",
"options",
"=",
"{",
"}",
")",
"if",
"perform_validations",
"(",
"options",
")",
"ret",
"=",
"super",
"(",
")",
"process_response_errors",
"raise_record_invalid",
"if",
"self",
".",
"errors",
".",
"any?",
"ret",
"else",
"raise_record_invalid",
"end",
"end"
] | ActiveRecord Compatibility for Her | [
"ActiveRecord",
"Compatibility",
"for",
"Her"
] | bd957f523959531926e2bf844608d77addef2047 | https://github.com/maestrano/mno-enterprise/blob/bd957f523959531926e2bf844608d77addef2047/core/app/models/mno_enterprise/base_resource.rb#L149-L158 | train |
maestrano/mno-enterprise | core/app/models/mno_enterprise/user.rb | MnoEnterprise.User.role | def role(organization = nil)
# Return cached version if available
return self.read_attribute(:role) if !organization
# Find in arrays if organizations have been fetched
# already. Perform remote query otherwise
org = begin
if self.organizations.loaded?
self.organizations.to_a.find { |e| e.id == organization.id }
else
self.organizations.where(id: organization.id).first
end
end
org ? org.role : nil
end | ruby | def role(organization = nil)
# Return cached version if available
return self.read_attribute(:role) if !organization
# Find in arrays if organizations have been fetched
# already. Perform remote query otherwise
org = begin
if self.organizations.loaded?
self.organizations.to_a.find { |e| e.id == organization.id }
else
self.organizations.where(id: organization.id).first
end
end
org ? org.role : nil
end | [
"def",
"role",
"(",
"organization",
"=",
"nil",
")",
"# Return cached version if available",
"return",
"self",
".",
"read_attribute",
"(",
":role",
")",
"if",
"!",
"organization",
"# Find in arrays if organizations have been fetched",
"# already. Perform remote query otherwise",
"org",
"=",
"begin",
"if",
"self",
".",
"organizations",
".",
"loaded?",
"self",
".",
"organizations",
".",
"to_a",
".",
"find",
"{",
"|",
"e",
"|",
"e",
".",
"id",
"==",
"organization",
".",
"id",
"}",
"else",
"self",
".",
"organizations",
".",
"where",
"(",
"id",
":",
"organization",
".",
"id",
")",
".",
"first",
"end",
"end",
"org",
"?",
"org",
".",
"role",
":",
"nil",
"end"
] | Return the role of this user for the provided
organization | [
"Return",
"the",
"role",
"of",
"this",
"user",
"for",
"the",
"provided",
"organization"
] | bd957f523959531926e2bf844608d77addef2047 | https://github.com/maestrano/mno-enterprise/blob/bd957f523959531926e2bf844608d77addef2047/core/app/models/mno_enterprise/user.rb#L186-L201 | train |
maestrano/mno-enterprise | core/app/controllers/mno_enterprise/application_controller.rb | MnoEnterprise.ApplicationController.after_sign_in_path_for | def after_sign_in_path_for(resource)
previous_url = session.delete(:previous_url)
default_url = if resource.respond_to?(:admin_role) && resource.admin_role.present?
MnoEnterprise.router.admin_path
else
MnoEnterprise.router.dashboard_path || main_app.root_url
end
return (return_to_url(resource) || previous_url || default_url)
end | ruby | def after_sign_in_path_for(resource)
previous_url = session.delete(:previous_url)
default_url = if resource.respond_to?(:admin_role) && resource.admin_role.present?
MnoEnterprise.router.admin_path
else
MnoEnterprise.router.dashboard_path || main_app.root_url
end
return (return_to_url(resource) || previous_url || default_url)
end | [
"def",
"after_sign_in_path_for",
"(",
"resource",
")",
"previous_url",
"=",
"session",
".",
"delete",
"(",
":previous_url",
")",
"default_url",
"=",
"if",
"resource",
".",
"respond_to?",
"(",
":admin_role",
")",
"&&",
"resource",
".",
"admin_role",
".",
"present?",
"MnoEnterprise",
".",
"router",
".",
"admin_path",
"else",
"MnoEnterprise",
".",
"router",
".",
"dashboard_path",
"||",
"main_app",
".",
"root_url",
"end",
"return",
"(",
"return_to_url",
"(",
"resource",
")",
"||",
"previous_url",
"||",
"default_url",
")",
"end"
] | Redirect to previous url and reset it | [
"Redirect",
"to",
"previous",
"url",
"and",
"reset",
"it"
] | bd957f523959531926e2bf844608d77addef2047 | https://github.com/maestrano/mno-enterprise/blob/bd957f523959531926e2bf844608d77addef2047/core/app/controllers/mno_enterprise/application_controller.rb#L96-L104 | train |
maestrano/mno-enterprise | core/app/models/mno_enterprise/impac/dashboard.rb | MnoEnterprise.Impac::Dashboard.organizations | def organizations(org_list = nil)
if org_list
return org_list if dashboard_type == 'template'
org_list.to_a.select { |e| organization_ids.include?(e.uid) || organization_ids.include?(e.id) }
else
MnoEnterprise::Organization.where('uid.in' => organization_ids).to_a
end
end | ruby | def organizations(org_list = nil)
if org_list
return org_list if dashboard_type == 'template'
org_list.to_a.select { |e| organization_ids.include?(e.uid) || organization_ids.include?(e.id) }
else
MnoEnterprise::Organization.where('uid.in' => organization_ids).to_a
end
end | [
"def",
"organizations",
"(",
"org_list",
"=",
"nil",
")",
"if",
"org_list",
"return",
"org_list",
"if",
"dashboard_type",
"==",
"'template'",
"org_list",
".",
"to_a",
".",
"select",
"{",
"|",
"e",
"|",
"organization_ids",
".",
"include?",
"(",
"e",
".",
"uid",
")",
"||",
"organization_ids",
".",
"include?",
"(",
"e",
".",
"id",
")",
"}",
"else",
"MnoEnterprise",
"::",
"Organization",
".",
"where",
"(",
"'uid.in'",
"=>",
"organization_ids",
")",
".",
"to_a",
"end",
"end"
] | Return all the organizations linked to this dashboard and to which the user has access
If the dashboard is a template, return all the current user's organizations | [
"Return",
"all",
"the",
"organizations",
"linked",
"to",
"this",
"dashboard",
"and",
"to",
"which",
"the",
"user",
"has",
"access",
"If",
"the",
"dashboard",
"is",
"a",
"template",
"return",
"all",
"the",
"current",
"user",
"s",
"organizations"
] | bd957f523959531926e2bf844608d77addef2047 | https://github.com/maestrano/mno-enterprise/blob/bd957f523959531926e2bf844608d77addef2047/core/app/models/mno_enterprise/impac/dashboard.rb#L26-L33 | train |
maestrano/mno-enterprise | core/app/models/mno_enterprise/impac/dashboard.rb | MnoEnterprise.Impac::Dashboard.filtered_widgets_templates | def filtered_widgets_templates
if MnoEnterprise.widgets_templates_listing
return self.widgets_templates.select do |t|
MnoEnterprise.widgets_templates_listing.include?(t[:path])
end
else
return self.widgets_templates
end
end | ruby | def filtered_widgets_templates
if MnoEnterprise.widgets_templates_listing
return self.widgets_templates.select do |t|
MnoEnterprise.widgets_templates_listing.include?(t[:path])
end
else
return self.widgets_templates
end
end | [
"def",
"filtered_widgets_templates",
"if",
"MnoEnterprise",
".",
"widgets_templates_listing",
"return",
"self",
".",
"widgets_templates",
".",
"select",
"do",
"|",
"t",
"|",
"MnoEnterprise",
".",
"widgets_templates_listing",
".",
"include?",
"(",
"t",
"[",
":path",
"]",
")",
"end",
"else",
"return",
"self",
".",
"widgets_templates",
"end",
"end"
] | Filter widgets list based on config | [
"Filter",
"widgets",
"list",
"based",
"on",
"config"
] | bd957f523959531926e2bf844608d77addef2047 | https://github.com/maestrano/mno-enterprise/blob/bd957f523959531926e2bf844608d77addef2047/core/app/models/mno_enterprise/impac/dashboard.rb#L36-L44 | train |
salesforce/flo | lib/flo/command.rb | Flo.Command.call | def call(args={})
evaluate_command_definition(args)
response = tasks.map do |task|
response = task.call(args)
# bail early if the task failed
return response unless response.success?
response
end.last
end | ruby | def call(args={})
evaluate_command_definition(args)
response = tasks.map do |task|
response = task.call(args)
# bail early if the task failed
return response unless response.success?
response
end.last
end | [
"def",
"call",
"(",
"args",
"=",
"{",
"}",
")",
"evaluate_command_definition",
"(",
"args",
")",
"response",
"=",
"tasks",
".",
"map",
"do",
"|",
"task",
"|",
"response",
"=",
"task",
".",
"call",
"(",
"args",
")",
"# bail early if the task failed",
"return",
"response",
"unless",
"response",
".",
"success?",
"response",
"end",
".",
"last",
"end"
] | Invoke the command that has already been defined.
This will run the command, processing any tasks defined by {#perform} and
{#validate} in order, stopping execution if any of the tasks fails.
Arguments passed in here will be merged with the provider options defined
in each task.
@param args [Hash] arguments to be passed to each task | [
"Invoke",
"the",
"command",
"that",
"has",
"already",
"been",
"defined",
"."
] | 34c01f22e0a5d065f879aaed9fbdf3f2a9b2163a | https://github.com/salesforce/flo/blob/34c01f22e0a5d065f879aaed9fbdf3f2a9b2163a/lib/flo/command.rb#L78-L88 | train |
salesforce/flo | lib/flo/command.rb | Flo.Command.optional_parameters | def optional_parameters
definition_lambda.parameters.select { |key,_value| key == :key }.map { |_key,value| value }
end | ruby | def optional_parameters
definition_lambda.parameters.select { |key,_value| key == :key }.map { |_key,value| value }
end | [
"def",
"optional_parameters",
"definition_lambda",
".",
"parameters",
".",
"select",
"{",
"|",
"key",
",",
"_value",
"|",
"key",
"==",
":key",
"}",
".",
"map",
"{",
"|",
"_key",
",",
"value",
"|",
"value",
"}",
"end"
] | Returns a list of any optional parameters
Optional parameters are generated automatically by inspecting the optional
parameters for the definition lambda
@return [Array<Symbol>] An array of symbols representing optional parameters | [
"Returns",
"a",
"list",
"of",
"any",
"optional",
"parameters"
] | 34c01f22e0a5d065f879aaed9fbdf3f2a9b2163a | https://github.com/salesforce/flo/blob/34c01f22e0a5d065f879aaed9fbdf3f2a9b2163a/lib/flo/command.rb#L107-L109 | train |
maestrano/mno-enterprise | api/app/controllers/mno_enterprise/jpi/v1/admin/theme_controller.rb | MnoEnterprise.Jpi::V1::Admin::ThemeController.save_previewer_style | def save_previewer_style(theme)
target = Rails.root.join('frontend', 'src','app','stylesheets','theme-previewer-tmp.less')
File.open(target, 'w') { |f| f.write(theme_to_less(theme)) }
end | ruby | def save_previewer_style(theme)
target = Rails.root.join('frontend', 'src','app','stylesheets','theme-previewer-tmp.less')
File.open(target, 'w') { |f| f.write(theme_to_less(theme)) }
end | [
"def",
"save_previewer_style",
"(",
"theme",
")",
"target",
"=",
"Rails",
".",
"root",
".",
"join",
"(",
"'frontend'",
",",
"'src'",
",",
"'app'",
",",
"'stylesheets'",
",",
"'theme-previewer-tmp.less'",
")",
"File",
".",
"open",
"(",
"target",
",",
"'w'",
")",
"{",
"|",
"f",
"|",
"f",
".",
"write",
"(",
"theme_to_less",
"(",
"theme",
")",
")",
"}",
"end"
] | Save current style to theme-previewer-tmp.less stylesheet
This file overrides theme-previewer-published.less | [
"Save",
"current",
"style",
"to",
"theme",
"-",
"previewer",
"-",
"tmp",
".",
"less",
"stylesheet",
"This",
"file",
"overrides",
"theme",
"-",
"previewer",
"-",
"published",
".",
"less"
] | bd957f523959531926e2bf844608d77addef2047 | https://github.com/maestrano/mno-enterprise/blob/bd957f523959531926e2bf844608d77addef2047/api/app/controllers/mno_enterprise/jpi/v1/admin/theme_controller.rb#L55-L58 | train |
maestrano/mno-enterprise | api/app/controllers/mno_enterprise/jpi/v1/admin/theme_controller.rb | MnoEnterprise.Jpi::V1::Admin::ThemeController.apply_previewer_style | def apply_previewer_style(theme)
target = Rails.root.join('frontend', 'src','app','stylesheets','theme-previewer-published.less')
File.open(target, 'w') { |f| f.write(theme_to_less(theme)) }
reset_previewer_style
end | ruby | def apply_previewer_style(theme)
target = Rails.root.join('frontend', 'src','app','stylesheets','theme-previewer-published.less')
File.open(target, 'w') { |f| f.write(theme_to_less(theme)) }
reset_previewer_style
end | [
"def",
"apply_previewer_style",
"(",
"theme",
")",
"target",
"=",
"Rails",
".",
"root",
".",
"join",
"(",
"'frontend'",
",",
"'src'",
",",
"'app'",
",",
"'stylesheets'",
",",
"'theme-previewer-published.less'",
")",
"File",
".",
"open",
"(",
"target",
",",
"'w'",
")",
"{",
"|",
"f",
"|",
"f",
".",
"write",
"(",
"theme_to_less",
"(",
"theme",
")",
")",
"}",
"reset_previewer_style",
"end"
] | Save style to theme-previewer-published.less and discard theme-previewer-tmp.less | [
"Save",
"style",
"to",
"theme",
"-",
"previewer",
"-",
"published",
".",
"less",
"and",
"discard",
"theme",
"-",
"previewer",
"-",
"tmp",
".",
"less"
] | bd957f523959531926e2bf844608d77addef2047 | https://github.com/maestrano/mno-enterprise/blob/bd957f523959531926e2bf844608d77addef2047/api/app/controllers/mno_enterprise/jpi/v1/admin/theme_controller.rb#L61-L65 | train |
maestrano/mno-enterprise | api/app/controllers/mno_enterprise/jpi/v1/admin/theme_controller.rb | MnoEnterprise.Jpi::V1::Admin::ThemeController.theme_to_less | def theme_to_less(theme)
out = "// Generated by the Express Theme Previewer\n"
if theme[:branding]
out += "\n//----------------------------------------\n"
out += "// General Branding\n"
out += "//----------------------------------------\n"
out += theme[:branding].map { |k,v| "#{k}: #{v};" }.join("\n")
out += "\n"
end
if theme[:variables]
out += "\n//----------------------------------------\n"
out += "// Theme Variables\n"
out += "//----------------------------------------\n"
theme[:variables].each do |section,vars|
out += "// #{section}\n"
out += vars.map { |k,v| "#{k}: #{v};" }.join("\n")
out += "\n\n"
end
end
return out
end | ruby | def theme_to_less(theme)
out = "// Generated by the Express Theme Previewer\n"
if theme[:branding]
out += "\n//----------------------------------------\n"
out += "// General Branding\n"
out += "//----------------------------------------\n"
out += theme[:branding].map { |k,v| "#{k}: #{v};" }.join("\n")
out += "\n"
end
if theme[:variables]
out += "\n//----------------------------------------\n"
out += "// Theme Variables\n"
out += "//----------------------------------------\n"
theme[:variables].each do |section,vars|
out += "// #{section}\n"
out += vars.map { |k,v| "#{k}: #{v};" }.join("\n")
out += "\n\n"
end
end
return out
end | [
"def",
"theme_to_less",
"(",
"theme",
")",
"out",
"=",
"\"// Generated by the Express Theme Previewer\\n\"",
"if",
"theme",
"[",
":branding",
"]",
"out",
"+=",
"\"\\n//----------------------------------------\\n\"",
"out",
"+=",
"\"// General Branding\\n\"",
"out",
"+=",
"\"//----------------------------------------\\n\"",
"out",
"+=",
"theme",
"[",
":branding",
"]",
".",
"map",
"{",
"|",
"k",
",",
"v",
"|",
"\"#{k}: #{v};\"",
"}",
".",
"join",
"(",
"\"\\n\"",
")",
"out",
"+=",
"\"\\n\"",
"end",
"if",
"theme",
"[",
":variables",
"]",
"out",
"+=",
"\"\\n//----------------------------------------\\n\"",
"out",
"+=",
"\"// Theme Variables\\n\"",
"out",
"+=",
"\"//----------------------------------------\\n\"",
"theme",
"[",
":variables",
"]",
".",
"each",
"do",
"|",
"section",
",",
"vars",
"|",
"out",
"+=",
"\"// #{section}\\n\"",
"out",
"+=",
"vars",
".",
"map",
"{",
"|",
"k",
",",
"v",
"|",
"\"#{k}: #{v};\"",
"}",
".",
"join",
"(",
"\"\\n\"",
")",
"out",
"+=",
"\"\\n\\n\"",
"end",
"end",
"return",
"out",
"end"
] | Convert a theme provided as a hash into a properly
formatted LESS file | [
"Convert",
"a",
"theme",
"provided",
"as",
"a",
"hash",
"into",
"a",
"properly",
"formatted",
"LESS",
"file"
] | bd957f523959531926e2bf844608d77addef2047 | https://github.com/maestrano/mno-enterprise/blob/bd957f523959531926e2bf844608d77addef2047/api/app/controllers/mno_enterprise/jpi/v1/admin/theme_controller.rb#L84-L107 | train |
maestrano/mno-enterprise | core/app/pdf/mno_enterprise/invoice_pdf.rb | MnoEnterprise.InvoicePdf.generate_content | def generate_content
@pdf = Prawn::Document.new(
info: self.metadata,
top_margin: @format[:header_size] + @format[:top_margin],
bottom_margin: @format[:footer_size] + @format[:bottom_margin]
)
add_page_body
add_page_header
add_page_footer
add_page_numbering
end | ruby | def generate_content
@pdf = Prawn::Document.new(
info: self.metadata,
top_margin: @format[:header_size] + @format[:top_margin],
bottom_margin: @format[:footer_size] + @format[:bottom_margin]
)
add_page_body
add_page_header
add_page_footer
add_page_numbering
end | [
"def",
"generate_content",
"@pdf",
"=",
"Prawn",
"::",
"Document",
".",
"new",
"(",
"info",
":",
"self",
".",
"metadata",
",",
"top_margin",
":",
"@format",
"[",
":header_size",
"]",
"+",
"@format",
"[",
":top_margin",
"]",
",",
"bottom_margin",
":",
"@format",
"[",
":footer_size",
"]",
"+",
"@format",
"[",
":bottom_margin",
"]",
")",
"add_page_body",
"add_page_header",
"add_page_footer",
"add_page_numbering",
"end"
] | Generate the document content
by adding body, header, footer and
page numbering | [
"Generate",
"the",
"document",
"content",
"by",
"adding",
"body",
"header",
"footer",
"and",
"page",
"numbering"
] | bd957f523959531926e2bf844608d77addef2047 | https://github.com/maestrano/mno-enterprise/blob/bd957f523959531926e2bf844608d77addef2047/core/app/pdf/mno_enterprise/invoice_pdf.rb#L97-L107 | train |
maestrano/mno-enterprise | core/app/pdf/mno_enterprise/invoice_pdf.rb | MnoEnterprise.InvoicePdf.add_page_header | def add_page_header
title = Settings.payment.disabled ? 'Account Statement - ' : 'Monthly Invoice - '
@pdf.repeat :all do
@pdf.bounding_box([0, @pdf.bounds.top+@format[:header_size]], width: 540, height: @format[:footer_size]) do
@pdf.float do
@pdf.image main_logo_white_bg_path(true), fit: [135, (@format[:footer_size])]
end
@pdf.move_down 52
@pdf.font_size(20) { @pdf.text "#{title} #{@data[:period_month]}", style: :bold, align: :right }
end
end
end | ruby | def add_page_header
title = Settings.payment.disabled ? 'Account Statement - ' : 'Monthly Invoice - '
@pdf.repeat :all do
@pdf.bounding_box([0, @pdf.bounds.top+@format[:header_size]], width: 540, height: @format[:footer_size]) do
@pdf.float do
@pdf.image main_logo_white_bg_path(true), fit: [135, (@format[:footer_size])]
end
@pdf.move_down 52
@pdf.font_size(20) { @pdf.text "#{title} #{@data[:period_month]}", style: :bold, align: :right }
end
end
end | [
"def",
"add_page_header",
"title",
"=",
"Settings",
".",
"payment",
".",
"disabled",
"?",
"'Account Statement - '",
":",
"'Monthly Invoice - '",
"@pdf",
".",
"repeat",
":all",
"do",
"@pdf",
".",
"bounding_box",
"(",
"[",
"0",
",",
"@pdf",
".",
"bounds",
".",
"top",
"+",
"@format",
"[",
":header_size",
"]",
"]",
",",
"width",
":",
"540",
",",
"height",
":",
"@format",
"[",
":footer_size",
"]",
")",
"do",
"@pdf",
".",
"float",
"do",
"@pdf",
".",
"image",
"main_logo_white_bg_path",
"(",
"true",
")",
",",
"fit",
":",
"[",
"135",
",",
"(",
"@format",
"[",
":footer_size",
"]",
")",
"]",
"end",
"@pdf",
".",
"move_down",
"52",
"@pdf",
".",
"font_size",
"(",
"20",
")",
"{",
"@pdf",
".",
"text",
"\"#{title} #{@data[:period_month]}\"",
",",
"style",
":",
":bold",
",",
"align",
":",
":right",
"}",
"end",
"end",
"end"
] | Add a repeated header to the document | [
"Add",
"a",
"repeated",
"header",
"to",
"the",
"document"
] | bd957f523959531926e2bf844608d77addef2047 | https://github.com/maestrano/mno-enterprise/blob/bd957f523959531926e2bf844608d77addef2047/core/app/pdf/mno_enterprise/invoice_pdf.rb#L126-L137 | train |
maestrano/mno-enterprise | core/app/pdf/mno_enterprise/invoice_pdf.rb | MnoEnterprise.InvoicePdf.add_page_footer | def add_page_footer
@pdf.repeat :all do
@pdf.bounding_box([0, @pdf.bounds.bottom], width: 540, height: @format[:footer_size]) do
@pdf.move_down 50
@pdf.stroke_color '999999'
@pdf.stroke_horizontal_rule
@pdf.move_down 10
@pdf.font_size(8) do
@pdf.text "<color rgb='999999'>This invoice has been generated by Maestrano Pty Ltd on behalf of the #{MnoEnterprise.app_name} platform (the \"Service\").</color>", inline_format: true
@pdf.text "<color rgb='999999'>All charges in this invoice are in #{@data[:invoice_currency_name]} (#{@data[:invoice_currency]}). Credit card payments will be processed by Maestrano Pty Ltd.</color>", inline_format: true
@pdf.text " ", inline_format: true
@pdf.text "<color rgb='999999'>Maestrano Pty Ltd | Suite 504, 46 Market Street, Sydney, NSW 2000, Australia | ABN: 80 152 564 424</color>", inline_format: true
end
end
end
end | ruby | def add_page_footer
@pdf.repeat :all do
@pdf.bounding_box([0, @pdf.bounds.bottom], width: 540, height: @format[:footer_size]) do
@pdf.move_down 50
@pdf.stroke_color '999999'
@pdf.stroke_horizontal_rule
@pdf.move_down 10
@pdf.font_size(8) do
@pdf.text "<color rgb='999999'>This invoice has been generated by Maestrano Pty Ltd on behalf of the #{MnoEnterprise.app_name} platform (the \"Service\").</color>", inline_format: true
@pdf.text "<color rgb='999999'>All charges in this invoice are in #{@data[:invoice_currency_name]} (#{@data[:invoice_currency]}). Credit card payments will be processed by Maestrano Pty Ltd.</color>", inline_format: true
@pdf.text " ", inline_format: true
@pdf.text "<color rgb='999999'>Maestrano Pty Ltd | Suite 504, 46 Market Street, Sydney, NSW 2000, Australia | ABN: 80 152 564 424</color>", inline_format: true
end
end
end
end | [
"def",
"add_page_footer",
"@pdf",
".",
"repeat",
":all",
"do",
"@pdf",
".",
"bounding_box",
"(",
"[",
"0",
",",
"@pdf",
".",
"bounds",
".",
"bottom",
"]",
",",
"width",
":",
"540",
",",
"height",
":",
"@format",
"[",
":footer_size",
"]",
")",
"do",
"@pdf",
".",
"move_down",
"50",
"@pdf",
".",
"stroke_color",
"'999999'",
"@pdf",
".",
"stroke_horizontal_rule",
"@pdf",
".",
"move_down",
"10",
"@pdf",
".",
"font_size",
"(",
"8",
")",
"do",
"@pdf",
".",
"text",
"\"<color rgb='999999'>This invoice has been generated by Maestrano Pty Ltd on behalf of the #{MnoEnterprise.app_name} platform (the \\\"Service\\\").</color>\"",
",",
"inline_format",
":",
"true",
"@pdf",
".",
"text",
"\"<color rgb='999999'>All charges in this invoice are in #{@data[:invoice_currency_name]} (#{@data[:invoice_currency]}). Credit card payments will be processed by Maestrano Pty Ltd.</color>\"",
",",
"inline_format",
":",
"true",
"@pdf",
".",
"text",
"\" \"",
",",
"inline_format",
":",
"true",
"@pdf",
".",
"text",
"\"<color rgb='999999'>Maestrano Pty Ltd | Suite 504, 46 Market Street, Sydney, NSW 2000, Australia | ABN: 80 152 564 424</color>\"",
",",
"inline_format",
":",
"true",
"end",
"end",
"end",
"end"
] | Add a repeated footer to the document | [
"Add",
"a",
"repeated",
"footer",
"to",
"the",
"document"
] | bd957f523959531926e2bf844608d77addef2047 | https://github.com/maestrano/mno-enterprise/blob/bd957f523959531926e2bf844608d77addef2047/core/app/pdf/mno_enterprise/invoice_pdf.rb#L140-L155 | train |
maestrano/mno-enterprise | core/app/pdf/mno_enterprise/invoice_pdf.rb | MnoEnterprise.InvoicePdf.add_page_numbering | def add_page_numbering
numbering_options = {
at: [@pdf.bounds.right - 150, 0-@format[:footer_size]],
width: 150,
align: :right,
start_count_at: 1,
color: "999999",
size: 8
}
@pdf.number_pages "Page <page> of <total>", numbering_options
end | ruby | def add_page_numbering
numbering_options = {
at: [@pdf.bounds.right - 150, 0-@format[:footer_size]],
width: 150,
align: :right,
start_count_at: 1,
color: "999999",
size: 8
}
@pdf.number_pages "Page <page> of <total>", numbering_options
end | [
"def",
"add_page_numbering",
"numbering_options",
"=",
"{",
"at",
":",
"[",
"@pdf",
".",
"bounds",
".",
"right",
"-",
"150",
",",
"0",
"-",
"@format",
"[",
":footer_size",
"]",
"]",
",",
"width",
":",
"150",
",",
"align",
":",
":right",
",",
"start_count_at",
":",
"1",
",",
"color",
":",
"\"999999\"",
",",
"size",
":",
"8",
"}",
"@pdf",
".",
"number_pages",
"\"Page <page> of <total>\"",
",",
"numbering_options",
"end"
] | Add page number on every page | [
"Add",
"page",
"number",
"on",
"every",
"page"
] | bd957f523959531926e2bf844608d77addef2047 | https://github.com/maestrano/mno-enterprise/blob/bd957f523959531926e2bf844608d77addef2047/core/app/pdf/mno_enterprise/invoice_pdf.rb#L158-L168 | train |
NCSU-Libraries/quick_search | app/searchers/quick_search/best_bets_searcher.rb | QuickSearch.BestBetsSearcher.search_best_bets_index | def search_best_bets_index
response = @http.get(query_url)
parsed_response = JSON.parse(response.body)
if parsed_response['response']['numFound'].to_s == '0'
return nil
else
resp = parsed_response['response']['docs'][0]
result = OpenStruct.new
result.title = title(resp)
result.link = link(resp)
result.id = id(resp)
result.description = description(resp)
result.best_bets_type = 'best-bets-regular'
@response = result
end
end | ruby | def search_best_bets_index
response = @http.get(query_url)
parsed_response = JSON.parse(response.body)
if parsed_response['response']['numFound'].to_s == '0'
return nil
else
resp = parsed_response['response']['docs'][0]
result = OpenStruct.new
result.title = title(resp)
result.link = link(resp)
result.id = id(resp)
result.description = description(resp)
result.best_bets_type = 'best-bets-regular'
@response = result
end
end | [
"def",
"search_best_bets_index",
"response",
"=",
"@http",
".",
"get",
"(",
"query_url",
")",
"parsed_response",
"=",
"JSON",
".",
"parse",
"(",
"response",
".",
"body",
")",
"if",
"parsed_response",
"[",
"'response'",
"]",
"[",
"'numFound'",
"]",
".",
"to_s",
"==",
"'0'",
"return",
"nil",
"else",
"resp",
"=",
"parsed_response",
"[",
"'response'",
"]",
"[",
"'docs'",
"]",
"[",
"0",
"]",
"result",
"=",
"OpenStruct",
".",
"new",
"result",
".",
"title",
"=",
"title",
"(",
"resp",
")",
"result",
".",
"link",
"=",
"link",
"(",
"resp",
")",
"result",
".",
"id",
"=",
"id",
"(",
"resp",
")",
"result",
".",
"description",
"=",
"description",
"(",
"resp",
")",
"result",
".",
"best_bets_type",
"=",
"'best-bets-regular'",
"@response",
"=",
"result",
"end",
"end"
] | Regular Best Bets | [
"Regular",
"Best",
"Bets"
] | 2e2c3f8682eed63a2bf2c008fa77f04ff9dd6a03 | https://github.com/NCSU-Libraries/quick_search/blob/2e2c3f8682eed63a2bf2c008fa77f04ff9dd6a03/app/searchers/quick_search/best_bets_searcher.rb#L34-L50 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.