_id
stringlengths
2
6
title
stringlengths
9
130
partition
stringclasses
3 values
text
stringlengths
66
10.5k
language
stringclasses
1 value
meta_information
dict
q17800
Sfn.Cache.get_local_storage
train
def get_local_storage(data_type, full_name, args = {}) @storage ||= {} @storage[full_name] ||= case data_type.to_sym when :array [] when :hash {} when :value LocalValue.new when :lock LocalLock.new(full_name, {:expiration => 60, :timeout => 0.1}.merge(args)) when :stamped Stamped.new(full_name.sub("#{key}_", "").to_sym, get_local_storage(:value, full_name), self) else raise TypeError.new("Unsupported caching data type encountered: #{data_type}") end end
ruby
{ "resource": "" }
q17801
Sfn.Cache.time_check_allow?
train
def time_check_allow?(key, stamp) Time.now.to_i - stamp.to_i > apply_limit(key) end
ruby
{ "resource": "" }
q17802
Sfn.Cache.apply_limit
train
def apply_limit(kind, seconds = nil) @apply_limit ||= {} if seconds @apply_limit[kind.to_sym] = seconds.to_i end @apply_limit[kind.to_sym].to_i end
ruby
{ "resource": "" }
q17803
Sfn.Cache.locked_action
train
def locked_action(lock_name, raise_on_locked = false) begin self[lock_name].lock do yield end rescue => e if e.class.to_s.end_with?("Timeout") raise if raise_on_locked else raise end end end
ruby
{ "resource": "" }
q17804
HashDiff.LinearCompareArray.index_of_match_after_additions
train
def index_of_match_after_additions return unless expected_additions > 0 (1..expected_additions).each do |i| next_difference = item_difference( old_array[old_index], new_array[new_index + i], old_index ) return new_index + i if next_difference.empty? end nil end
ruby
{ "resource": "" }
q17805
HashDiff.LinearCompareArray.index_of_match_after_deletions
train
def index_of_match_after_deletions return unless expected_additions < 0 (1..(expected_additions.abs)).each do |i| next_difference = item_difference( old_array[old_index + i], new_array[new_index], old_index ) return old_index + i if next_difference.empty? end nil end
ruby
{ "resource": "" }
q17806
MySQLBinUUID.Type.cast
train
def cast(value) if value.is_a?(MySQLBinUUID::Type::Data) # It could be a Data object, in which case we should add dashes to the # string value from there. add_dashes(value.to_s) elsif value.is_a?(String) && value.encoding == Encoding::ASCII_8BIT && strip_dashes(value).length != 32 # We cannot unpack something that looks like a UUID, with or without # dashes. Not entirely sure why ActiveRecord does a weird combination of # cast and serialize before anything needs to be saved.. undashed_uuid = value.unpack1('H*') add_dashes(undashed_uuid.to_s) else super end end
ruby
{ "resource": "" }
q17807
MySQLBinUUID.Type.serialize
train
def serialize(value) return if value.nil? undashed_uuid = strip_dashes(value) # To avoid SQL injection, verify that it looks like a UUID. ActiveRecord # does not explicity escape the Binary data type. escaping is implicit as # the Binary data type always converts its value to a hex string. unless valid_undashed_uuid?(undashed_uuid) raise MySQLBinUUID::InvalidUUID, "#{value} is not a valid UUID" end Data.new(undashed_uuid) end
ruby
{ "resource": "" }
q17808
MySQLBinUUID.Type.add_dashes
train
def add_dashes(uuid) return uuid if uuid =~ /\-/ [uuid[0..7], uuid[8..11], uuid[12..15], uuid[16..19], uuid[20..-1]].join("-") end
ruby
{ "resource": "" }
q17809
Oath.ControllerHelpers.sign_in
train
def sign_in user Oath.config.sign_in_service.new(user, warden).perform.tap do |status| if status && block_given? yield end end end
ruby
{ "resource": "" }
q17810
Oath.ControllerHelpers.sign_up
train
def sign_up user_params Oath.config.sign_up_service.new(user_params).perform.tap do |status| if status && block_given? yield end end end
ruby
{ "resource": "" }
q17811
Oath.ControllerHelpers.authenticate_session
train
def authenticate_session session_params, field_map = nil token_field = Oath.config.user_token_field params_hash = Oath.transform_params(session_params).symbolize_keys password = params_hash.fetch(token_field) user = Oath.lookup(params_hash.except(token_field), field_map) authenticate(user, password) end
ruby
{ "resource": "" }
q17812
Oath.ControllerHelpers.authenticate
train
def authenticate user, password Oath.config.authentication_service.new(user, password).perform end
ruby
{ "resource": "" }
q17813
Oath.ControllerHelpers.reset_password
train
def reset_password user, password Oath.config.password_reset_service.new(user, password).perform end
ruby
{ "resource": "" }
q17814
Oath.ParamTransformer.to_h
train
def to_h sanitized_params.each_with_object({}) do |(key, value), hash| hash[key] = transform(key, value) end end
ruby
{ "resource": "" }
q17815
GoogleDistanceMatrix.Client.get
train
def get(url, instrumentation: {}, **_options) uri = URI.parse url response = ActiveSupport::Notifications.instrument( 'client_request_matrix_data.google_distance_matrix', instrumentation ) do Net::HTTP.get_response uri end handle response, url rescue Timeout::Error => error raise ServerError, error end
ruby
{ "resource": "" }
q17816
GoogleDistanceMatrix.PolylineEncoder.encode
train
def encode return @encoded if @encoded deltas = @delta.deltas_rounded @array_of_lat_lng_pairs chars_array = deltas.map { |v| @value_encoder.encode v } @encoded = chars_array.join end
ruby
{ "resource": "" }
q17817
RocketJobMissionControl.Query.unsorted_query
train
def unsorted_query records = scope # Text Search if search_term escaped = Regexp.escape(search_term) regexp = Regexp.new(escaped, Regexp::IGNORECASE) if search_columns.size == 1 records = records.where(search_columns.first => regexp) else cols = search_columns.collect { |col| {col => regexp} } records = records.where('$or' => cols) end end # Pagination if start && page_size records = records.skip(start).limit(page_size) end records end
ruby
{ "resource": "" }
q17818
RocketJobMissionControl.ApplicationHelper.editable_field_html
train
def editable_field_html(klass, field_name, value, f, include_nil_selectors = false) # When editing a job the values are of the correct type. # When editing a dirmon entry values are strings. field = klass.fields[field_name.to_s] return unless field && field.type placeholder = field.default_val placeholder = nil if placeholder.is_a?(Proc) case field.type.name when 'Symbol', 'String', 'Integer' options = extract_inclusion_values(klass, field_name) str = "[#{field.type.name}]\n".html_safe if options str + f.select(field_name, options, { include_blank: options.include?(nil) || include_nil_selectors, selected: value }, { class: 'selectize form-control' }) else if field.type.name == 'Integer' str + f.number_field(field_name, value: value, class: 'form-control', placeholder: placeholder) else str + f.text_field(field_name, value: value, class: 'form-control', placeholder: placeholder) end end when 'Hash' "[JSON Hash]\n".html_safe + f.text_field(field_name, value: value ? value.to_json : '', class: 'form-control', placeholder: '{"key1":"value1", "key2":"value2", "key3":"value3"}') when 'Array' options = Array(value) "[Array]\n".html_safe + f.select(field_name, options_for_select(options, options), { include_hidden: false }, { class: 'selectize form-control', multiple: true }) when 'Mongoid::Boolean' name = "#{field_name}_true".to_sym value = value.to_s str = '<div class="radio-buttons">'.html_safe str << f.radio_button(field_name, 'true', checked: value == 'true') str << ' '.html_safe + f.label(name, 'true') str << ' '.html_safe + f.radio_button(field_name, 'false', checked: value == 'false') str << ' '.html_safe + f.label(name, 'false') # Allow this field to be unset (nil). if include_nil_selectors str << ' '.html_safe + f.radio_button(field_name, '', checked: value == '') str << ' '.html_safe + f.label(name, 'nil') end str << '</div>'.html_safe else "[#{field.type.name}]".html_safe + f.text_field(field_name, value: value, class: 'form-control', placeholder: placeholder) end end
ruby
{ "resource": "" }
q17819
RocketJobMissionControl.JobsDatatable.map
train
def map(job) index = 0 h = {} @columns.each do |column| h[index.to_s] = send(column[:value], job) index += 1 end h['DT_RowClass'] = "card callout callout-#{job_state(job)}" h end
ruby
{ "resource": "" }
q17820
OoxmlParser.SharedStringTable.parse
train
def parse(file) return nil unless File.exist?(file) document = parse_xml(file) node = document.xpath('*').first node.attributes.each do |key, value| case key when 'count' @count = value.value.to_i when 'uniqueCount' @unique_count = value.value.to_i end end node.xpath('*').each do |node_child| case node_child.name when 'si' @string_indexes << StringIndex.new(parent: self).parse(node_child) end end self end
ruby
{ "resource": "" }
q17821
OoxmlParser.OldDocxGroup.parse
train
def parse(node) node.xpath('*').each do |node_child| case node_child.name when 'shape' element = OldDocxGroupElement.new(:shape) element.object = OldDocxShape.new(parent: self).parse(node_child) @elements << element when 'wrap' @properties.wrap = node_child.attribute('type').value.to_sym unless node_child.attribute('type').nil? when 'group' @elements << OldDocxGroup.new(parent: self).parse(node_child) end end self end
ruby
{ "resource": "" }
q17822
OoxmlParser.PlotArea.parse
train
def parse(node) node.xpath('*').each do |node_child| case node_child.name when 'barChart' @bar_chart = CommonChartData.new(parent: self).parse(node_child) when 'lineChart' @line_chart = CommonChartData.new(parent: self).parse(node_child) when 'areaChart' @area_chart = CommonChartData.new(parent: self).parse(node_child) when 'bubbleChart' @bubble_chart = CommonChartData.new(parent: self).parse(node_child) when 'doughnutChart' @doughnut_chart = CommonChartData.new(parent: self).parse(node_child) when 'pieChart' @pie_chart = CommonChartData.new(parent: self).parse(node_child) when 'scatterChart' @scatter_chart = CommonChartData.new(parent: self).parse(node_child) when 'radarChart' @radar_chart = CommonChartData.new(parent: self).parse(node_child) when 'stockChart' @stock_chart = CommonChartData.new(parent: self).parse(node_child) when 'surface3DChart' @surface_3d_chart = CommonChartData.new(parent: self).parse(node_child) when 'line3DChart' @line_3d_chart = CommonChartData.new(parent: self).parse(node_child) when 'bar3DChart' @bar_3d_chart = CommonChartData.new(parent: self).parse(node_child) when 'pie3DChart' @pie_3d_chart = CommonChartData.new(parent: self).parse(node_child) end end self end
ruby
{ "resource": "" }
q17823
OoxmlParser.DisplayLabelsProperties.parse
train
def parse(node) node.xpath('*').each do |node_child| case node_child.name when 'dLblPos' @position = value_to_symbol(node_child.attribute('val')) when 'showLegendKey' @show_legend_key = true if node_child.attribute('val').value == '1' when 'showVal' @show_values = true if node_child.attribute('val').value == '1' when 'showCatName' @show_category_name = option_enabled?(node_child) when 'showSerName' @show_series_name = option_enabled?(node_child) when 'delete' @delete = option_enabled?(node_child) end end self end
ruby
{ "resource": "" }
q17824
OoxmlParser.DocxPatternFill.parse
train
def parse(node) @preset = node.attribute('prst').value.to_sym node.xpath('*').each do |node_child| case node_child.name when 'fgClr' @foreground_color = Color.new(parent: self).parse_color_model(node_child) when 'bgClr' @background_color = Color.new(parent: self).parse_color_model(node_child) end end self end
ruby
{ "resource": "" }
q17825
OoxmlParser.OldDocxShapeFill.parse
train
def parse(node) node.attributes.each do |key, value| case key when 'id' @file_reference = FileReference.new(parent: self).parse(node) when 'type' @stretching_type = case value.value when 'frame' :stretch else value.value.to_sym end when 'title' @title = value.value.to_s end end self end
ruby
{ "resource": "" }
q17826
OoxmlParser.ParagraphBorders.parse
train
def parse(node) node.xpath('*').each do |node_child| case node_child.name when 'bottom' @bottom = BordersProperties.new(parent: self).parse(node_child) when 'left' @left = BordersProperties.new(parent: self).parse(node_child) when 'top' @top = BordersProperties.new(parent: self).parse(node_child) when 'right' @right = BordersProperties.new(parent: self).parse(node_child) when 'between' @between = BordersProperties.new(parent: self).parse(node_child) when 'bar' @bar = BordersProperties.new(parent: self).parse(node_child) end end self end
ruby
{ "resource": "" }
q17827
OoxmlParser.PresentationAlternateContent.parse
train
def parse(node) node.xpath('mc:Choice/*', 'xmlns:mc' => 'http://schemas.openxmlformats.org/markup-compatibility/2006').each do |node_child| case node_child.name when 'timing' @timing = Timing.new(parent: self).parse(node_child) when 'transition' @transition = Transition.new(parent: self).parse(node_child) when 'sp' @elements << DocxShape.new(parent: self).parse(node_child) end end self end
ruby
{ "resource": "" }
q17828
OoxmlParser.DocxColorScheme.parse
train
def parse(node) node.xpath('*').each do |node_child| case node_child.name when 'solidFill' @type = :solid @color = Color.new(parent: self).parse_color_model(node_child) when 'gradFill' @type = :gradient @color = GradientColor.new(parent: self).parse(node_child) when 'noFill' @color = :none @type = :none when 'srgbClr' @color = Color.new(parent: self).parse_hex_string(node_child.attribute('val').value) when 'schemeClr' @color = Color.new(parent: self).parse_scheme_color(node_child) end end self end
ruby
{ "resource": "" }
q17829
OoxmlParser.DocumentBackground.parse
train
def parse(node) @color1 = Color.new(parent: self).parse_hex_string(node.attribute('color').value) node.xpath('v:background').each do |second_color| @size = second_color.attribute('targetscreensize').value.sub(',', 'x') unless second_color.attribute('targetscreensize').nil? second_color.xpath('*').each do |node_child| case node_child.name when 'fill' @fill = Fill.new(parent: self).parse(node_child) end end end self end
ruby
{ "resource": "" }
q17830
OoxmlParser.OleObjects.parse
train
def parse(node) list = [] node.xpath('*').each do |node_child| case node_child.name when 'AlternateContent' list << AlternateContent.new(parent: self).parse(node_child) end end list end
ruby
{ "resource": "" }
q17831
OoxmlParser.DocumentStyle.parse
train
def parse(node) node.attributes.each do |key, value| case key when 'type' @type = value.value.to_sym when 'styleId' @style_id = value.value when 'default' @default = attribute_enabled?(value.value) end end node.xpath('*').each do |subnode| case subnode.name when 'name' @name = subnode.attribute('val').value when 'basedOn' @based_on = subnode.attribute('val').value when 'next' @next_style = subnode.attribute('val').value when 'rPr' @run_properties = DocxParagraphRun.new(parent: self).parse_properties(subnode) when 'pPr' @paragraph_properties = ParagraphProperties.new(parent: self).parse(subnode) when 'tblPr' @table_properties = TableProperties.new(parent: self).parse(subnode) when 'trPr' @table_row_properties = TableRowProperties.new(parent: self).parse(subnode) when 'tcPr' @table_cell_properties = CellProperties.new(parent: self).parse(subnode) when 'tblStylePr' @table_style_properties_list << TableStyleProperties.new(parent: self).parse(subnode) when 'qFormat' @q_format = true end end fill_empty_table_styles self end
ruby
{ "resource": "" }
q17832
OoxmlParser.Worksheet.parse_drawing
train
def parse_drawing drawing_node = parse_xml(OOXMLDocumentObject.current_xml) drawing_node.xpath('xdr:wsDr/*').each do |drawing_node_child| @drawings << XlsxDrawing.new(parent: self).parse(drawing_node_child) end end
ruby
{ "resource": "" }
q17833
OoxmlParser.Worksheet.parse_comments
train
def parse_comments return unless relationships comments_target = relationships.target_by_type('comment') return if comments_target.empty? comments_file = "#{OOXMLDocumentObject.path_to_folder}/#{OOXMLDocumentObject.root_subfolder}/#{comments_target.first.gsub('..', '')}" @comments = ExcelComments.new(parent: self).parse(comments_file) end
ruby
{ "resource": "" }
q17834
OoxmlParser.StringIndex.parse
train
def parse(node) node.xpath('*').each do |node_child| case node_child.name when 't' @text = node_child.text when 'r' @run = ParagraphRun.new(parent: self).parse(node_child) end end self end
ruby
{ "resource": "" }
q17835
OoxmlParser.BookmarkStart.parse
train
def parse(node) node.attributes.each do |key, value| case key when 'id' @id = value.value.to_i when 'name' @name = value.value end end self end
ruby
{ "resource": "" }
q17836
OoxmlParser.Behavior.parse
train
def parse(node) node.xpath('*').each do |node_child| case node_child.name when 'cTn' @common_time_node = CommonTiming.new(parent: self).parse(node_child) when 'tgtEl' @target = TargetElement.new(parent: self).parse(node_child) when 'attrNameLst' node_child.xpath('p:attrName').each do |attribute_name_node| @attribute_name_list << attribute_name_node.text end end end self end
ruby
{ "resource": "" }
q17837
OoxmlParser.AbstractNumbering.parse
train
def parse(node) node.attributes.each do |key, value| case key when 'abstractNumId' @id = value.value.to_f end end node.xpath('*').each do |numbering_child_node| case numbering_child_node.name when 'multiLevelType' @multilevel_type = MultilevelType.new(parent: self).parse(numbering_child_node) when 'lvl' @level_list << NumberingLevel.new(parent: self).parse(numbering_child_node) end end self end
ruby
{ "resource": "" }
q17838
OoxmlParser.XlsxRow.parse
train
def parse(node) node.attributes.each do |key, value| case key when 'customHeight' @custom_height = option_enabled?(node, 'customHeight') when 'ht' @height = OoxmlSize.new(value.value.to_f, :point) when 'hidden' @hidden = option_enabled?(node, 'hidden') when 'r' @index = value.value.to_i end end node.xpath('*').each do |node_child| case node_child.name when 'c' @cells[Coordinates.parse_coordinates_from_string(node_child.attribute('r').value.to_s).column_number.to_i - 1] = XlsxCell.new(parent: self).parse(node_child) end end self end
ruby
{ "resource": "" }
q17839
OoxmlParser.Accent.parse
train
def parse(node) node.xpath('*').each do |node_child| case node_child.name when 'accPr' node_child.xpath('*').each do |node_child_child| case node_child_child.name when 'chr' @symbol = node_child_child.attribute('val').value end end end end @element = DocxFormula.new(parent: self).parse(node) self end
ruby
{ "resource": "" }
q17840
OoxmlParser.Color.looks_like?
train
def looks_like?(color_to_check = nil, delta = 8) color_to_check = color_to_check.converted_color if color_to_check.is_a?(SchemeColor) color_to_check = color_to_check.pattern_fill.foreground_folor if color_to_check.is_a?(Fill) color_to_check = color_to_check.color.converted_color if color_to_check.is_a?(PresentationFill) color_to_check = Color.parse(color_to_check) if color_to_check.is_a?(String) color_to_check = Color.parse(color_to_check.to_s) if color_to_check.is_a?(Symbol) color_to_check = Color.parse(color_to_check.value) if color_to_check.is_a?(DocxColor) return true if none? && color_to_check.nil? return true if none? && color_to_check.none? return false if none? && color_to_check.any? return false if !none? && color_to_check.none? return true if self == color_to_check red = color_to_check.red green = color_to_check.green blue = color_to_check.blue (self.red - red).abs < delta && (self.green - green).abs < delta && (self.blue - blue).abs < delta ? true : false end
ruby
{ "resource": "" }
q17841
OoxmlParser.ChartCellsRange.parse
train
def parse(node) @list = node.xpath('c:f')[0].text.split('!').first coordinates = Coordinates.parser_coordinates_range(node.xpath('c:f')[0].text) # .split('!')[1].gsub('$', '')) return self unless coordinates node.xpath('c:numCache/c:pt').each_with_index do |point_node, index| point = ChartPoint.new(coordinates[index]) point.value = point_node.xpath('c:v').first.text.to_f unless point_node.xpath('c:v').first.nil? @points << point end self end
ruby
{ "resource": "" }
q17842
OoxmlParser.XlsxAlignment.parse
train
def parse(node) node.attributes.each do |key, value| case key when 'horizontal' @horizontal = value.value.to_sym @wrap_text = true if @horizontal == :justify when 'vertical' @vertical = value.value.to_sym when 'wrapText' @wrap_text = value.value.to_s == '1' when 'textRotation' @text_rotation = value.value.to_i end end self end
ruby
{ "resource": "" }
q17843
OoxmlParser.TableStyle.parse
train
def parse(node) node.attributes.each do |key, value| case key when 'styleId' @id = value.value.to_s when 'styleName' @name = value.value.to_s when 'val' @value = value.value.to_s end end node.xpath('*').each do |style_node_child| case style_node_child.name when 'wholeTbl' @whole_table = TableElement.new(parent: self).parse(style_node_child) when 'band1H' @banding_1_horizontal = TableElement.new(parent: self).parse(style_node_child) when 'band2H', 'band2Horz' @banding_2_horizontal = TableElement.new(parent: self).parse(style_node_child) when 'band1V' @banding_1_vertical = TableElement.new(parent: self).parse(style_node_child) when 'band2V' @banding_2_vertical = TableElement.new(parent: self).parse(style_node_child) when 'lastCol' @last_column = TableElement.new(parent: self).parse(style_node_child) when 'firstCol' @first_column = TableElement.new(parent: self).parse(style_node_child) when 'lastRow' @last_row = TableElement.new(parent: self).parse(style_node_child) when 'firstRow' @first_row = TableElement.new(parent: self).parse(style_node_child) when 'seCell' @southeast_cell = TableElement.new(parent: self).parse(style_node_child) when 'swCell' @southwest_cell = TableElement.new(parent: self).parse(style_node_child) when 'neCell' @northeast_cell = TableElement.new(parent: self).parse(style_node_child) when 'nwCell' @northwest_cell = TableElement.new(parent: self).parse(style_node_child) end end self end
ruby
{ "resource": "" }
q17844
OoxmlParser.ParagraphRun.parse
train
def parse(node) node.xpath('*').each do |node_child| case node_child.name when 'rPr' @properties = RunProperties.new(parent: self).parse(node_child) when 't' @t = Text.new(parent: self).parse(node_child) @text = t.text when 'tab' @tab = Tab.new(parent: self).parse(node_child) end end self end
ruby
{ "resource": "" }
q17845
OoxmlParser.XLSXWorkbook.all_formula_values
train
def all_formula_values(precision = 14) formulas = [] worksheets.each do |c_sheet| next unless c_sheet c_sheet.rows.each do |c_row| next unless c_row c_row.cells.each do |c_cell| next unless c_cell next unless c_cell.formula next if c_cell.formula.empty? text = c_cell.raw_text if StringHelper.numeric?(text) text = text.to_f.round(10).to_s[0..precision] elsif StringHelper.complex?(text) complex_number = Complex(text.tr(',', '.')) real_part = complex_number.real real_rounded = real_part.to_f.round(10).to_s[0..precision].to_f imag_part = complex_number.imag imag_rounded = imag_part.to_f.round(10).to_s[0..precision].to_f complex_rounded = Complex(real_rounded, imag_rounded) text = complex_rounded.to_s end formulas << text end end end formulas end
ruby
{ "resource": "" }
q17846
OoxmlParser.XLSXWorkbook.parse_shared_strings
train
def parse_shared_strings shared_strings_target = relationships.target_by_type('sharedString') return if shared_strings_target.empty? shared_string_file = "#{OOXMLDocumentObject.path_to_folder}/xl/#{shared_strings_target.first}" @shared_strings_table = SharedStringTable.new(parent: self).parse(shared_string_file) end
ruby
{ "resource": "" }
q17847
OoxmlParser.TablePosition.parse
train
def parse(node) node.attributes.each do |key, value| case key when 'leftFromText' @left = OoxmlSize.new(value.value.to_f) when 'rightFromText' @right = OoxmlSize.new(value.value.to_f) when 'topFromText' @top = OoxmlSize.new(value.value.to_f) when 'bottomFromText' @bottom = OoxmlSize.new(value.value.to_f) when 'tblpX' @position_x = OoxmlSize.new(value.value.to_f) when 'tblpY' @position_y = OoxmlSize.new(value.value.to_f) when 'vertAnchor' @vertical_anchor = value.value.to_sym when 'horzAnchor' @horizontal_anchor = value.value.to_sym when 'tblpXSpec' @horizontal_align_from_anchor = value.value.to_sym when 'tblpYSpec' @vertical_align_from_anchor = value.value.to_sym end end self end
ruby
{ "resource": "" }
q17848
OoxmlParser.Shape.parse
train
def parse(node, type) @type = type node.attribute('style').value.to_s.split(';').each do |property| if property.include?('margin-top') @properties.margins.top = property.split(':').last elsif property.include?('margin-left') @properties.margins.left = property.split(':').last elsif property.include?('margin-right') @properties.margins.right = property.split(':').last elsif property.include?('width') @properties.size.width = property.split(':').last elsif property.include?('height') @properties.size.height = property.split(':').last elsif property.include?('z-index') @properties.z_index = property.split(':').last elsif property.include?('position') @properties.position = property.split(':').last end end @properties.fill_color = Color.new(parent: self).parse_hex_string(node.attribute('fillcolor').value.to_s.sub('#', '').split(' ').first) unless node.attribute('fillcolor').nil? @properties.stroke.weight = node.attribute('strokeweight').value unless node.attribute('strokeweight').nil? @properties.stroke.color = Color.new(parent: self).parse_hex_string(node.attribute('strokecolor').value.to_s.sub('#', '').split(' ').first) unless node.attribute('strokecolor').nil? @elements = TextBox.parse_list(node.xpath('v:textbox').first, parent: self) unless node.xpath('v:textbox').first.nil? self end
ruby
{ "resource": "" }
q17849
OoxmlParser.TextField.parse
train
def parse(node) @id = node.attribute('id').value @type = node.attribute('type').value node.xpath('*').each do |text_field_node_child| case text_field_node_child.name when 't' @text = text_field_node_child.text end end self end
ruby
{ "resource": "" }
q17850
OoxmlParser.DocxColor.parse
train
def parse(node) node.xpath('*').each do |node_child| case node_child.name when 'blipFill' @type = :picture @value = DocxBlip.new(parent: self).parse(node_child) node_child.xpath('*').each do |fill_type_node_child| case fill_type_node_child.name when 'tile' @stretching_type = :tile when 'stretch' @stretching_type = :stretch when 'blip' fill_type_node_child.xpath('alphaModFix').each { |alpha_node| @alpha = alpha_node.attribute('amt').value.to_i / 1_000.0 } end end when 'solidFill' @type = :solid @value = Color.new(parent: self).parse_color_model(node_child) when 'gradFill' @type = :gradient @value = GradientColor.new(parent: self).parse(node_child) when 'pattFill' @type = :pattern @value = DocxPatternFill.new(parent: self).parse(node_child) end end self end
ruby
{ "resource": "" }
q17851
OoxmlParser.PageProperties.parse
train
def parse(node, default_paragraph, default_character) node.xpath('*').each do |pg_size_subnode| case pg_size_subnode.name when 'pgSz' @size = PageSize.new.parse(pg_size_subnode) when 'pgBorders' page_borders = Borders.new page_borders.display = pg_size_subnode.attribute('display').value.to_sym unless pg_size_subnode.attribute('display').nil? page_borders.offset_from = pg_size_subnode.attribute('offsetFrom').value.to_sym unless pg_size_subnode.attribute('offsetFrom').nil? pg_size_subnode.xpath('w:bottom').each do |bottom| page_borders.bottom = BordersProperties.new(parent: page_borders).parse(bottom) end pg_size_subnode.xpath('w:left').each do |left| page_borders.bottom = BordersProperties.new(parent: page_borders).parse(left) end pg_size_subnode.xpath('w:top').each do |top| page_borders.bottom = BordersProperties.new(parent: page_borders).parse(top) end pg_size_subnode.xpath('w:right').each do |right| page_borders.bottom = BordersProperties.new(parent: page_borders).parse(right) end @page_borders = page_borders when 'type' @type = pg_size_subnode.attribute('val').value when 'pgMar' @margins = PageMargins.new(parent: self).parse(pg_size_subnode) when 'pgNumType' @num_type = pg_size_subnode.attribute('fmt').value unless pg_size_subnode.attribute('fmt').nil? when 'formProt' @form_prot = pg_size_subnode.attribute('val').value when 'textDirection' @text_direction = pg_size_subnode.attribute('val').value when 'docGrid' @document_grid = DocumentGrid.new(parent: self).parse(pg_size_subnode) when 'titlePg' @title_page = option_enabled?(pg_size_subnode) when 'cols' @columns = Columns.new.parse(pg_size_subnode) when 'headerReference', 'footerReference' target = OOXMLDocumentObject.get_link_from_rels(pg_size_subnode.attribute('id').value) OOXMLDocumentObject.add_to_xmls_stack("word/#{target}") note = Note.parse(default_paragraph: default_paragraph, default_character: default_character, target: target, assigned_to: pg_size_subnode.attribute('type').value, type: File.basename(target).sub('.xml', ''), parent: self) @notes << note OOXMLDocumentObject.xmls_stack.pop when 'footnotePr' @footnote_properties = FootnoteProperties.new(parent: self).parse(pg_size_subnode) end end self end
ruby
{ "resource": "" }
q17852
OoxmlParser.ChartAxisTitle.parse
train
def parse(node) node.xpath('*').each do |node_child| case node_child.name when 'tx' node_child.xpath('c:rich/*').each do |rich_node_child| case rich_node_child.name when 'p' root_object.default_font_style = FontStyle.new(true) # Default font style for chart title always bold @elements << Paragraph.new(parent: self).parse(rich_node_child) root_object.default_font_style = FontStyle.new end end when 'layout' @layout = option_enabled?(node_child) when 'overlay' @overlay = option_enabled?(node_child) end end self end
ruby
{ "resource": "" }
q17853
OoxmlParser.XlsxDrawing.parse
train
def parse(node) node.xpath('*').each do |child_node| case child_node.name when 'from' @from = XlsxDrawingPositionParameters.new(parent: self).parse(child_node) when 'to' @to = XlsxDrawingPositionParameters.new(parent: self).parse(child_node) when 'sp' @shape = DocxShape.new(parent: self).parse(child_node) when 'grpSp' @grouping = ShapesGrouping.new(parent: self).parse(child_node) when 'pic' @picture = DocxPicture.new(parent: self).parse(child_node) when 'graphicFrame' @graphic_frame = GraphicFrame.new(parent: self).parse(child_node) when 'cxnSp' @shape = ConnectionShape.new(parent: self).parse(child_node) end end self end
ruby
{ "resource": "" }
q17854
OoxmlParser.Borders.parse
train
def parse(node) node.xpath('*').each do |node_child| case node_child.name when 'lnL', 'left' @left = TableCellLine.new(parent: self).parse(node_child) when 'lnR', 'right' @right = TableCellLine.new(parent: self).parse(node_child) when 'lnT', 'top' @top = TableCellLine.new(parent: self).parse(node_child) when 'lnB', 'bottom' @bottom = TableCellLine.new(parent: self).parse(node_child) when 'lnTlToBr', 'tl2br' @top_left_to_bottom_right = TableCellLine.new(parent: self).parse(node_child) when 'lnBlToTr', 'tr2bl' @top_right_to_bottom_left = TableCellLine.new(parent: self).parse(node_child) when 'insideV' @inner_vertical = TableCellLine.new(parent: self).parse(node_child) when 'insideH' @inner_horizontal = TableCellLine.new(parent: self).parse(node_child) end end self end
ruby
{ "resource": "" }
q17855
OoxmlParser.SlideHelper.transform_of_object
train
def transform_of_object(object) case object when :image elements.find { |e| e.is_a? Picture }.properties.transform when :chart elements.find { |e| e.is_a? GraphicFrame }.transform when :table elements.find { |e| e.is_a? GraphicFrame }.transform when :shape elements.find { |e| !e.shape_properties.preset.nil? }.shape_properties.transform else raise "Dont know this type object - #{object}" end end
ruby
{ "resource": "" }
q17856
OoxmlParser.BlipFill.parse
train
def parse(node) node.xpath('*').each do |node_child| case node_child.name when 'blip' @blip = Blip.new(parent: self).parse(node_child) when 'stretch' @stretch = Stretch.new(parent: self).parse(node_child) end end self end
ruby
{ "resource": "" }
q17857
OoxmlParser.OldDocxShapeProperties.parse
train
def parse(node) node.attributes.each do |key, value| case key when 'fillcolor' @fill_color = Color.new(parent: self).parse_hex_string(value.value.delete('#')) when 'opacity' @opacity = value.value.to_f when 'strokecolor' @stroke_color = Color.new(parent: self).parse_hex_string(value.value.delete('#')) when 'strokeweight' @stroke_weight = value.value.to_f end end self end
ruby
{ "resource": "" }
q17858
OoxmlParser.Slide.parse
train
def parse OOXMLDocumentObject.add_to_xmls_stack(@xml_path) @name = File.basename(@xml_path, '.*') node = parse_xml(OOXMLDocumentObject.current_xml) node.xpath('//p:sld/*').each do |node_child| case node_child.name when 'cSld' @common_slide_data = CommonSlideData.new(parent: self).parse(node_child) when 'timing' @timing = Timing.new(parent: self).parse(node_child) when 'transition' @transition = Transition.new(parent: self).parse(node_child) when 'AlternateContent' @alternate_content = PresentationAlternateContent.new(parent: self).parse(node_child) end end OOXMLDocumentObject.xmls_stack.pop @relationships = Relationships.new(parent: self).parse_file("#{OOXMLDocumentObject.path_to_folder}#{File.dirname(@xml_path)}/_rels/#{@name}.xml.rels") parse_note self end
ruby
{ "resource": "" }
q17859
OoxmlParser.DocxPicture.parse
train
def parse(node) node.xpath('*').each do |node_child| case node_child.name when 'blipFill' @path_to_image = DocxBlip.new(parent: self).parse(node_child) when 'spPr' @properties = DocxShapeProperties.new(parent: self).parse(node_child) when 'nvPicPr' @non_visual_properties = NonVisualShapeProperties.new(parent: self).parse(node_child) end end self end
ruby
{ "resource": "" }
q17860
OoxmlParser.GradientColor.parse
train
def parse(node) node.xpath('*').each do |node_child| case node_child.name when 'gsLst' node_child.xpath('*').each do |gradient_stop_node| @gradient_stops << GradientStop.new(parent: self).parse(gradient_stop_node) end when 'path' @path = node_child.attribute('path').value.to_sym when 'lin' @linear_gradient = LinearGradient.new(parent: self).parse(node_child) end end self end
ruby
{ "resource": "" }
q17861
OoxmlParser.Tab.parse
train
def parse(node) node.attributes.each do |key, value| case key when 'algn', 'val' @value = value_to_symbol(value) when 'leader' @leader = value_to_symbol(value) when 'pos' @position = OoxmlSize.new(value.value.to_f, position_unit(node)) end end self end
ruby
{ "resource": "" }
q17862
OoxmlParser.TableStyleInfo.parse
train
def parse(node) node.attributes.each do |key, value| case key when 'name' @name = value.value.to_s when 'showColumnStripes' @show_column_stripes = attribute_enabled?(value) when 'showFirstColumn' @show_first_column = attribute_enabled?(value) when 'showLastColumn' @show_last_column = attribute_enabled?(value) when 'showRowStripes' @show_row_stripes = attribute_enabled?(value) end end self end
ruby
{ "resource": "" }
q17863
OoxmlParser.FieldSimple.parse
train
def parse(node) node.attributes.each do |key, value| case key when 'instr' @instruction = value.value.to_s end end node.xpath('*').each do |node_child| case node_child.name when 'r' @runs << ParagraphRun.new(parent: self).parse(node_child) end end self end
ruby
{ "resource": "" }
q17864
OoxmlParser.PresentationPattern.parse
train
def parse(node) node.attributes.each do |key, value| case key when 'prst' @preset = value.value.to_sym end end node.xpath('*').each do |color_node| case color_node.name when 'fgClr' @foreground_color = Color.new(parent: self).parse_color(color_node.xpath('*').first) when 'bgClr' @background_color = Color.new(parent: self).parse_color(color_node.xpath('*').first) end end self end
ruby
{ "resource": "" }
q17865
OoxmlParser.DocumentSettings.parse
train
def parse settings_path = OOXMLDocumentObject.path_to_folder + 'word/settings.xml' return nil unless File.exist?(settings_path) doc = parse_xml(settings_path) doc.xpath('w:settings/*').each do |node_child| case node_child.name when 'defaultTabStop' @default_tab_stop = OoxmlSize.new.parse(node_child) end end self end
ruby
{ "resource": "" }
q17866
OoxmlParser.LineJoin.parse
train
def parse(node) node.xpath('*').each do |node_child| case node_child.name when 'round', 'bevel' @type = node_child.name.to_sym when 'miter' @type = :miter @limit = node_child.attribute('lim').value.to_f end end self end
ruby
{ "resource": "" }
q17867
OoxmlParser.ExtensionList.parse
train
def parse(node) node.xpath('*').each do |column_node| case column_node.name when 'ext' @extension_array << Extension.new(parent: self).parse(column_node) end end self end
ruby
{ "resource": "" }
q17868
OoxmlParser.XlsxCell.parse
train
def parse(node) node.attributes.each do |key, value| case key when 's' @style_index = value.value.to_i when 't' @type = value.value.to_s end end node.xpath('*').each do |node_child| case node_child.name when 'f' @formula = Formula.new(parent: self).parse(node_child) when 'v' @value = TextValue.new(parent: self).parse(node_child) end end parse_text_data self end
ruby
{ "resource": "" }
q17869
OoxmlParser.XlsxCell.get_shared_string
train
def get_shared_string(value) return '' if value == '' string = root_object.shared_strings_table.string_indexes[value.to_i] @character = string.run @raw_text = string.text end
ruby
{ "resource": "" }
q17870
OoxmlParser.ShapeTree.parse
train
def parse(node) node.xpath('*').each do |node_child| case node_child.name when 'sp' @elements << DocxShape.new(parent: self).parse(node_child).dup when 'pic' @elements << DocxPicture.new(parent: self).parse(node_child) when 'graphicFrame' @elements << GraphicFrame.new(parent: self).parse(node_child) when 'grpSp' @elements << ShapesGrouping.new(parent: self).parse(node_child) when 'cxnSp' @elements << ConnectionShape.new(parent: self).parse(node_child) end end self end
ruby
{ "resource": "" }
q17871
OoxmlParser.PresentationNotes.parse
train
def parse(file) node = parse_xml(file) node.xpath('p:notes/*').each do |node_child| case node_child.name when 'cSld' @common_slide_data = CommonSlideData.new(parent: self).parse(node_child) end end self end
ruby
{ "resource": "" }
q17872
OoxmlParser.TargetElement.parse
train
def parse(node) node.xpath('*').each do |node_child| case node_child.name when 'sldTgt' @type = :slide when 'sndTgt' @type = :sound @name = node_child.attribute('name').value @built_in = node_child.attribute('builtIn').value ? StringHelper.to_bool(node_child.attribute('builtIn').value) : false when 'spTgt' @type = :shape @id = node_child.attribute('spid').value when 'inkTgt' @type = :ink @id = node_child.attribute('spid').value end end self end
ruby
{ "resource": "" }
q17873
OoxmlParser.Table.parse
train
def parse(node, number = 0, default_table_properties = TableProperties.new) table_properties = default_table_properties.dup table_properties.jc = :left node.xpath('*').each do |node_child| case node_child.name when 'tblGrid' @grid = TableGrid.new(parent: self).parse(node_child) when 'tr' @rows << TableRow.new(parent: self).parse(node_child) when 'tblPr' @properties = TableProperties.new(parent: self).parse(node_child) end end @number = number self end
ruby
{ "resource": "" }
q17874
OoxmlParser.Matrix.parse
train
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
{ "resource": "" }
q17875
OoxmlParser.SDTProperties.parse
train
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
{ "resource": "" }
q17876
OoxmlParser.TextBody.parse
train
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
{ "resource": "" }
q17877
OoxmlParser.AnimationEffect.parse
train
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
{ "resource": "" }
q17878
OoxmlParser.Xf.parse
train
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
{ "resource": "" }
q17879
OoxmlParser.Pane.parse
train
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
{ "resource": "" }
q17880
OoxmlParser.PresentationComment.parse
train
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
{ "resource": "" }
q17881
OoxmlParser.TableStylePropertiesHelper.fill_empty_table_styles
train
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
{ "resource": "" }
q17882
OoxmlParser.FilterColumn.parse
train
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
{ "resource": "" }
q17883
OoxmlParser.TableCell.parse
train
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
{ "resource": "" }
q17884
OoxmlParser.Delimiter.parse
train
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
{ "resource": "" }
q17885
OoxmlParser.ChartAxis.parse
train
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
{ "resource": "" }
q17886
OoxmlParser.ChartLegend.parse
train
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
{ "resource": "" }
q17887
OoxmlParser.PresentationComments.parse
train
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
{ "resource": "" }
q17888
OoxmlParser.OoxmlSize.to_base_unit
train
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
{ "resource": "" }
q17889
OoxmlParser.DocumentProperties.parse
train
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
{ "resource": "" }
q17890
OoxmlParser.CommonNonVisualProperties.parse
train
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
{ "resource": "" }
q17891
OoxmlParser.HSLColor.to_rgb
train
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
{ "resource": "" }
q17892
OoxmlParser.TransitionProperties.parse
train
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
{ "resource": "" }
q17893
OoxmlParser.Inserted.parse
train
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
{ "resource": "" }
q17894
OoxmlParser.TableStyleProperties.parse
train
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
{ "resource": "" }
q17895
OoxmlParser.Background.parse
train
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
{ "resource": "" }
q17896
OoxmlParser.StructuredDocumentTag.parse
train
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
{ "resource": "" }
q17897
OoxmlParser.Autofilter.parse
train
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
{ "resource": "" }
q17898
OoxmlParser.Paragraph.parse
train
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
{ "resource": "" }
q17899
OoxmlParser.Extension.parse
train
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
{ "resource": "" }