diff options
| author | Geremia Taglialatela <[email protected]> | 2023-06-15 09:30:29 +0200 |
|---|---|---|
| committer | Geremia Taglialatela <[email protected]> | 2023-06-15 09:30:29 +0200 |
| commit | 988c79b8d7602c67f7b761269383129609cf63a7 (patch) | |
| tree | 036d742dc625ea43028326d869a06e35ef9952b1 /lib | |
| parent | e74c75b95d39fb51512387031e79f50e52a5874a (diff) | |
| download | caxlsx-988c79b8d7602c67f7b761269383129609cf63a7.tar.gz caxlsx-988c79b8d7602c67f7b761269383129609cf63a7.zip | |
Fix redundant self offenses
No performance gain, this can be seen as a cosmetic change to have
shorter lines
Diffstat (limited to 'lib')
22 files changed, 32 insertions, 32 deletions
diff --git a/lib/axlsx/doc_props/core.rb b/lib/axlsx/doc_props/core.rb index 8dbe4cf4..4e98ac8e 100644 --- a/lib/axlsx/doc_props/core.rb +++ b/lib/axlsx/doc_props/core.rb @@ -27,7 +27,7 @@ module Axlsx str << '<cp:coreProperties xmlns:cp="' << CORE_NS << '" xmlns:dc="' << CORE_NS_DC << '" ' str << 'xmlns:dcmitype="' << CORE_NS_DCMIT << '" xmlns:dcterms="' << CORE_NS_DCT << '" ' str << 'xmlns:xsi="' << CORE_NS_XSI << '">' - str << '<dc:creator>' << self.creator << '</dc:creator>' + str << '<dc:creator>' << creator << '</dc:creator>' str << '<dcterms:created xsi:type="dcterms:W3CDTF">' << (created || Time.now).strftime('%Y-%m-%dT%H:%M:%S') << 'Z</dcterms:created>' str << '<cp:revision>0</cp:revision>' str << '</cp:coreProperties>' diff --git a/lib/axlsx/drawing/d_lbls.rb b/lib/axlsx/drawing/d_lbls.rb index 7a42c51c..0602a8df 100644 --- a/lib/axlsx/drawing/d_lbls.rb +++ b/lib/axlsx/drawing/d_lbls.rb @@ -38,7 +38,7 @@ module Axlsx [:show_legend_key, :show_val, :show_cat_name, :show_ser_name, :show_percent, :show_bubble_size, :show_leader_lines].each do |attr| - self.send("#{attr}=", false) + send("#{attr}=", false) end end diff --git a/lib/axlsx/drawing/drawing.rb b/lib/axlsx/drawing/drawing.rb index c927a6c9..997a7af0 100644 --- a/lib/axlsx/drawing/drawing.rb +++ b/lib/axlsx/drawing/drawing.rb @@ -108,7 +108,7 @@ module Axlsx # An array of hyperlink objects associated with this drawings images # @return [Array] def hyperlinks - links = self.images.select { |a| a.hyperlink.is_a?(Hyperlink) } + links = images.select { |a| a.hyperlink.is_a?(Hyperlink) } links.map(&:hyperlink) end diff --git a/lib/axlsx/drawing/marker.rb b/lib/axlsx/drawing/marker.rb index ec476297..0d6e0077 100644 --- a/lib/axlsx/drawing/marker.rb +++ b/lib/axlsx/drawing/marker.rb @@ -58,7 +58,7 @@ module Axlsx # @return [String] def to_xml_string(str = +'') [:col, :colOff, :row, :rowOff].each do |k| - str << '<xdr:' << k.to_s << '>' << self.send(k).to_s << '</xdr:' << k.to_s << '>' + str << '<xdr:' << k.to_s << '>' << send(k).to_s << '</xdr:' << k.to_s << '>' end end diff --git a/lib/axlsx/package.rb b/lib/axlsx/package.rb index 4f793d41..34add29b 100644 --- a/lib/axlsx/package.rb +++ b/lib/axlsx/package.rb @@ -106,7 +106,7 @@ module Axlsx end confirm_valid, zip_command = parse_serialize_options(options, secondary_options) - return false unless !confirm_valid || self.validate.empty? + return false unless !confirm_valid || validate.empty? zip_provider = if zip_command ZipCommand.new(zip_command) @@ -130,7 +130,7 @@ module Axlsx workbook.apply_styles end - return false unless !confirm_valid || self.validate.empty? + return false unless !confirm_valid || validate.empty? Relationship.initialize_ids_cache stream = BufferedZipOutputStream.write_buffer do |zip| diff --git a/lib/axlsx/stylesheet/dxf.rb b/lib/axlsx/stylesheet/dxf.rb index 2c10443a..dc9c2e1c 100644 --- a/lib/axlsx/stylesheet/dxf.rb +++ b/lib/axlsx/stylesheet/dxf.rb @@ -69,7 +69,7 @@ module Axlsx # Dxf elements have no attributes. All of the instance variables # are child elements. CHILD_ELEMENTS.each do |element| - self.send(element).to_xml_string(str) if self.send(element) + send(element).to_xml_string(str) if send(element) end str << '</dxf>' end diff --git a/lib/axlsx/stylesheet/gradient_stop.rb b/lib/axlsx/stylesheet/gradient_stop.rb index b0d66683..d4df9b3b 100644 --- a/lib/axlsx/stylesheet/gradient_stop.rb +++ b/lib/axlsx/stylesheet/gradient_stop.rb @@ -31,7 +31,7 @@ module Axlsx # @return [String] def to_xml_string(str = +'') str << '<stop position="' << position.to_s << '">' - self.color.to_xml_string(str) + color.to_xml_string(str) str << '</stop>' end end diff --git a/lib/axlsx/stylesheet/table_style.rb b/lib/axlsx/stylesheet/table_style.rb index 4bfd7cf5..95d10ce0 100644 --- a/lib/axlsx/stylesheet/table_style.rb +++ b/lib/axlsx/stylesheet/table_style.rb @@ -44,7 +44,7 @@ module Axlsx # @return [String] def to_xml_string(str = +'') str << '<tableStyle ' - serialized_attributes str, { count: self.size } + serialized_attributes str, { count: size } str << '>' each { |table_style_el| table_style_el.to_xml_string(str) } str << '</tableStyle>' diff --git a/lib/axlsx/stylesheet/table_styles.rb b/lib/axlsx/stylesheet/table_styles.rb index b5f50b90..fec2a0f6 100644 --- a/lib/axlsx/stylesheet/table_styles.rb +++ b/lib/axlsx/stylesheet/table_styles.rb @@ -35,7 +35,7 @@ module Axlsx # @return [String] def to_xml_string(str = +'') str << '<tableStyles ' - serialized_attributes str, { count: self.size } + serialized_attributes str, { count: size } str << '>' each { |table_style| table_style.to_xml_string(str) } str << '</tableStyles>' diff --git a/lib/axlsx/stylesheet/xf.rb b/lib/axlsx/stylesheet/xf.rb index 6d4aab66..0ea97f20 100644 --- a/lib/axlsx/stylesheet/xf.rb +++ b/lib/axlsx/stylesheet/xf.rb @@ -138,8 +138,8 @@ module Axlsx str << '<xf ' serialized_attributes str str << '>' - alignment.to_xml_string(str) if self.alignment - protection.to_xml_string(str) if self.protection + alignment.to_xml_string(str) if alignment + protection.to_xml_string(str) if protection str << '</xf>' end end diff --git a/lib/axlsx/util/options_parser.rb b/lib/axlsx/util/options_parser.rb index 526a3aed..73faa224 100644 --- a/lib/axlsx/util/options_parser.rb +++ b/lib/axlsx/util/options_parser.rb @@ -10,7 +10,7 @@ module Axlsx def parse_options(options = {}) options.each do |key, value| key = :"#{key}=" - self.send(key, value) if !value.nil? && self.respond_to?(key) + send(key, value) if !value.nil? && respond_to?(key) end end end diff --git a/lib/axlsx/util/storage.rb b/lib/axlsx/util/storage.rb index b9b84a37..ac5e9ebc 100644 --- a/lib/axlsx/util/storage.rb +++ b/lib/axlsx/util/storage.rb @@ -133,7 +133,7 @@ module Axlsx @left = @right = @child = -1 @sector = @size = @created = @modified = 0 options.each do |o| - self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}=" + send("#{o[0]}=", o[1]) if respond_to? "#{o[0]}=" end @color ||= COLORS[:black] @type ||= (data.nil? ? TYPES[:storage] : TYPES[:stream]) diff --git a/lib/axlsx/workbook/workbook.rb b/lib/axlsx/workbook/workbook.rb index c3597700..5f6dcff7 100644 --- a/lib/axlsx/workbook/workbook.rb +++ b/lib/axlsx/workbook/workbook.rb @@ -396,7 +396,7 @@ module Axlsx # @return [Cell, Array] def [](cell_def) sheet_name = cell_def.split('!')[0] if cell_def.include?('!') - worksheet = self.worksheets.find { |s| s.name == sheet_name } + worksheet = worksheets.find { |s| s.name == sheet_name } raise ArgumentError, 'Unknown Sheet' unless sheet_name && worksheet.is_a?(Worksheet) worksheet[cell_def.gsub(/.+!/, "")] diff --git a/lib/axlsx/workbook/worksheet/cell.rb b/lib/axlsx/workbook/worksheet/cell.rb index 67f84fbc..1e4eab78 100644 --- a/lib/axlsx/workbook/worksheet/cell.rb +++ b/lib/axlsx/workbook/worksheet/cell.rb @@ -375,11 +375,11 @@ module Axlsx # @param [Cell, String] target The last cell, or str ref for the cell in the merge range def merge(target) start, stop = if target.is_a?(String) - [self.r, target] + [r, target] elsif target.is_a?(Cell) Axlsx.sort_cells([self, target]).map(&:r) end - self.row.worksheet.merge_cells "#{start}:#{stop}" unless stop.nil? + row.worksheet.merge_cells "#{start}:#{stop}" unless stop.nil? end # Serializes the cell @@ -483,7 +483,7 @@ module Axlsx return unless INLINE_STYLES.include?(attr.to_sym) Axlsx.send(validator, value) unless validator.nil? - self.instance_variable_set :"@#{attr}", value + instance_variable_set :"@#{attr}", value @is_text_run = true end @@ -530,14 +530,14 @@ module Axlsx case type when :date - self.style = STYLE_DATE if self.style.zero? + self.style = STYLE_DATE if style.zero? if !v.is_a?(Date) && v.respond_to?(:to_date) v.to_date else v end when :time - self.style = STYLE_DATE if self.style.zero? + self.style = STYLE_DATE if style.zero? if !v.is_a?(Time) && v.respond_to?(:to_time) v.to_time else diff --git a/lib/axlsx/workbook/worksheet/cell_serializer.rb b/lib/axlsx/workbook/worksheet/cell_serializer.rb index 5567c4d6..2124a7f4 100644 --- a/lib/axlsx/workbook/worksheet/cell_serializer.rb +++ b/lib/axlsx/workbook/worksheet/cell_serializer.rb @@ -16,7 +16,7 @@ module Axlsx return str << '/>' if cell.value.nil? method = cell.type - self.send(method, cell, str) + send(method, cell, str) str << '</c>' end diff --git a/lib/axlsx/workbook/worksheet/color_scale.rb b/lib/axlsx/workbook/worksheet/color_scale.rb index e48de3bb..84ece25b 100644 --- a/lib/axlsx/workbook/worksheet/color_scale.rb +++ b/lib/axlsx/workbook/worksheet/color_scale.rb @@ -22,7 +22,7 @@ module Axlsx # color_scale = Axlsx::ColorScale.two_tone # @see examples/example.rb conditional formatting examples. def two_tone - self.new + new end # A builder for three tone color gradient @@ -31,9 +31,9 @@ module Axlsx # color_scale = Axlsx::ColorScale.three_tone # @see examples/example.rb conditional formatting examples. def three_tone - self.new({ type: :min, val: 0, color: 'FFF8696B' }, - { type: :percent, val: '50', color: 'FFFFEB84' }, - { type: :max, val: 0, color: 'FF63BE7B' }) + new({ type: :min, val: 0, color: 'FFF8696B' }, + { type: :percent, val: '50', color: 'FFFFEB84' }, + { type: :max, val: 0, color: 'FF63BE7B' }) end end # A simple typed list of cfvos diff --git a/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb b/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb index f848d1be..85ef886e 100644 --- a/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +++ b/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb @@ -208,7 +208,7 @@ module Axlsx str << '<cfRule ' serialized_attributes str str << '>' - str << '<formula>' << [*self.formula].join('</formula><formula>') << '</formula>' if @formula + str << '<formula>' << [*formula].join('</formula><formula>') << '</formula>' if @formula @color_scale.to_xml_string(str) if @color_scale && @type == :colorScale @data_bar.to_xml_string(str) if @data_bar && @type == :dataBar @icon_set.to_xml_string(str) if @icon_set && @type == :iconSet diff --git a/lib/axlsx/workbook/worksheet/data_bar.rb b/lib/axlsx/workbook/worksheet/data_bar.rb index 74158d98..95e54742 100644 --- a/lib/axlsx/workbook/worksheet/data_bar.rb +++ b/lib/axlsx/workbook/worksheet/data_bar.rb @@ -100,7 +100,7 @@ module Axlsx # @param [Color|String] v The color object, or rgb string value to apply def color=(v) @color = v if v.is_a? Color - self.color.rgb = v if v.is_a? String + color.rgb = v if v.is_a? String end # Serialize this object to an xml string @@ -109,7 +109,7 @@ module Axlsx def to_xml_string(str = +'') serialized_tag('dataBar', str) do value_objects.to_xml_string(str) - self.color.to_xml_string(str) + color.to_xml_string(str) end end diff --git a/lib/axlsx/workbook/worksheet/rich_text_run.rb b/lib/axlsx/workbook/worksheet/rich_text_run.rb index 4934523d..b2cd8a51 100644 --- a/lib/axlsx/workbook/worksheet/rich_text_run.rb +++ b/lib/axlsx/workbook/worksheet/rich_text_run.rb @@ -199,7 +199,7 @@ module Axlsx return unless INLINE_STYLES.include?(attr.to_sym) Axlsx.send(validator, value) unless validator.nil? - self.instance_variable_set :"@#{attr}", value + instance_variable_set :"@#{attr}", value end # Serializes the RichTextRun diff --git a/lib/axlsx/workbook/worksheet/row_breaks.rb b/lib/axlsx/workbook/worksheet/row_breaks.rb index 381dc0b6..98409ab4 100644 --- a/lib/axlsx/workbook/worksheet/row_breaks.rb +++ b/lib/axlsx/workbook/worksheet/row_breaks.rb @@ -26,7 +26,7 @@ module Axlsx def to_xml_string(str = +'') return if empty? - str << '<rowBreaks count="' << self.size.to_s << '" manualBreakCount="' << self.size.to_s << '">' + str << '<rowBreaks count="' << size.to_s << '" manualBreakCount="' << size.to_s << '">' each { |brk| brk.to_xml_string(str) } str << '</rowBreaks>' end diff --git a/lib/axlsx/workbook/worksheet/table_style_info.rb b/lib/axlsx/workbook/worksheet/table_style_info.rb index 3793d488..218e313e 100644 --- a/lib/axlsx/workbook/worksheet/table_style_info.rb +++ b/lib/axlsx/workbook/worksheet/table_style_info.rb @@ -34,7 +34,7 @@ module Axlsx # explicitly be disabled or all will show. def initialize_defaults %w(show_first_column show_last_column show_row_stripes show_column_stripes).each do |attr| - self.send("#{attr}=", 0) + send("#{attr}=", 0) end end diff --git a/lib/axlsx/workbook/worksheet/worksheet.rb b/lib/axlsx/workbook/worksheet/worksheet.rb index 47373d75..081f50d8 100644 --- a/lib/axlsx/workbook/worksheet/worksheet.rb +++ b/lib/axlsx/workbook/worksheet/worksheet.rb @@ -711,7 +711,7 @@ module Axlsx # @note The XLSX format does not support worksheet-specific styles. Even when using this method # you're still working with the single global {Axlsx::Styles} object in the workbook. def styles - @styles ||= self.workbook.styles + @styles ||= workbook.styles end # shortcut level to specify the outline level for a series of rows |
