summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx.rb
diff options
context:
space:
mode:
authorPaul Kmiec <[email protected]>2023-05-13 14:51:41 -0700
committerPaul Kmiec <[email protected]>2023-05-15 13:55:04 -0700
commit71b358f0c73c73f88275b4c1c89fdf5372281ada (patch)
treed53313e1898462abbc958ca83d37212a7521f423 /lib/axlsx.rb
parent4627bcce04ade9c17e1d0c169100a6288195f6ac (diff)
downloadcaxlsx-71b358f0c73c73f88275b4c1c89fdf5372281ada.tar.gz
caxlsx-71b358f0c73c73f88275b4c1c89fdf5372281ada.zip
Corrected rubocop offenses in lib/axlsx.rb / test/tc_axlsx.rb
Diffstat (limited to 'lib/axlsx.rb')
-rw-r--r--lib/axlsx.rb46
1 files changed, 23 insertions, 23 deletions
diff --git a/lib/axlsx.rb b/lib/axlsx.rb
index 6e6a317d..30683458 100644
--- a/lib/axlsx.rb
+++ b/lib/axlsx.rb
@@ -1,29 +1,29 @@
# frozen_string_literal: true
require 'htmlentities'
-require 'axlsx/version.rb'
+require 'axlsx/version'
require 'marcel'
-require 'axlsx/util/simple_typed_list.rb'
-require 'axlsx/util/constants.rb'
-require 'axlsx/util/validators.rb'
-require 'axlsx/util/accessors.rb'
+require 'axlsx/util/simple_typed_list'
+require 'axlsx/util/constants'
+require 'axlsx/util/validators'
+require 'axlsx/util/accessors'
require 'axlsx/util/serialized_attributes'
require 'axlsx/util/options_parser'
require 'axlsx/util/mime_type_utils'
require 'axlsx/util/buffered_zip_output_stream'
require 'axlsx/util/zip_command'
-require 'axlsx/stylesheet/styles.rb'
+require 'axlsx/stylesheet/styles'
-require 'axlsx/doc_props/app.rb'
-require 'axlsx/doc_props/core.rb'
-require 'axlsx/content_type/content_type.rb'
-require 'axlsx/rels/relationships.rb'
+require 'axlsx/doc_props/app'
+require 'axlsx/doc_props/core'
+require 'axlsx/content_type/content_type'
+require 'axlsx/rels/relationships'
-require 'axlsx/drawing/drawing.rb'
-require 'axlsx/workbook/workbook.rb'
-require 'axlsx/package.rb'
+require 'axlsx/drawing/drawing'
+require 'axlsx/workbook/workbook'
+require 'axlsx/package'
# required gems
require 'nokogiri'
require 'zip'
@@ -35,9 +35,9 @@ require 'time'
begin
if Gem.loaded_specs.has_key?("axlsx_styler")
- raise StandardError.new("Please remove `axlsx_styler` from your Gemfile, the associated functionality is now built-in to `caxlsx` directly.")
+ raise StandardError, "Please remove `axlsx_styler` from your Gemfile, the associated functionality is now built-in to `caxlsx` directly."
end
-rescue
+rescue StandardError
# Do nothing
end
@@ -53,7 +53,7 @@ module Axlsx
#
# Defining as a class method on Axlsx to refrain from monkeypatching Object for all users of this gem.
def self.instance_values_for(object)
- Hash[object.instance_variables.map { |name| [name.to_s[1..-1], object.instance_variable_get(name)] }]
+ object.instance_variables.to_h { |name| [name.to_s[1..], object.instance_variable_get(name)] }
end
# determines the cell range for the items provided
@@ -105,7 +105,7 @@ module Axlsx
row_index = (numbers_str.to_i - 1)
- return [col_index, row_index]
+ [col_index, row_index]
end
# converts the column index into alphabetical values.
@@ -147,9 +147,9 @@ module Axlsx
# @param [String] range A cell range, for example A1:D5
# @return [Array]
def self.range_to_a(range)
- range.match(/^(\w+?\d+)\:(\w+?\d+)$/)
- start_col, start_row = name_to_indices($1)
- end_col, end_row = name_to_indices($2)
+ range =~ /^(\w+?\d+):(\w+?\d+)$/
+ start_col, start_row = name_to_indices(::Regexp.last_match(1))
+ end_col, end_row = name_to_indices(::Regexp.last_match(2))
(start_row..end_row).to_a.map do |row_num|
(start_col..end_col).to_a.map do |col_num|
cell_r(col_num, row_num)
@@ -163,7 +163,7 @@ module Axlsx
def self.camel(s = "", all_caps = true)
s = s.to_s
s = s.capitalize if all_caps
- s.gsub(/_(.)/) { $1.upcase }
+ s.gsub(/_(.)/) { ::Regexp.last_match(1).upcase }
end
# returns the provided string with all invalid control charaters
@@ -184,7 +184,7 @@ module Axlsx
# @param [Object] value The value to process
# @return [Object]
def self.booleanize(value)
- if value == true || value == false
+ if BOOLEAN_VALUES.include?(value)
value ? 1 : 0
else
value
@@ -195,7 +195,7 @@ module Axlsx
# @param [Hash] Hash to merge into
# @param [Hash] Hash to be added
def self.hash_deep_merge(first_hash, second_hash)
- first_hash.merge(second_hash) do |key, this_val, other_val|
+ first_hash.merge(second_hash) do |_key, this_val, other_val|
if this_val.is_a?(Hash) && other_val.is_a?(Hash)
Axlsx.hash_deep_merge(this_val, other_val)
else