summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/axlsx/drawing/cat_axis.rb2
-rw-r--r--lib/axlsx/drawing/line_3D_chart.rb2
-rw-r--r--lib/axlsx/drawing/pic.rb2
-rw-r--r--lib/axlsx/drawing/title.rb10
-rw-r--r--lib/axlsx/drawing/view_3D.rb4
-rw-r--r--lib/axlsx/stylesheet/dxf.rb2
-rw-r--r--lib/axlsx/stylesheet/styles.rb12
-rw-r--r--lib/axlsx/util/storage.rb2
-rw-r--r--lib/axlsx/workbook/workbook.rb10
-rw-r--r--lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb2
-rw-r--r--lib/axlsx/workbook/worksheet/auto_filter/filters.rb4
-rw-r--r--lib/axlsx/workbook/worksheet/col.rb2
-rw-r--r--lib/axlsx/workbook/worksheet/data_bar.rb12
-rw-r--r--lib/axlsx/workbook/worksheet/sheet_view.rb2
14 files changed, 34 insertions, 34 deletions
diff --git a/lib/axlsx/drawing/cat_axis.rb b/lib/axlsx/drawing/cat_axis.rb
index 2f40f29f..d26e3dc9 100644
--- a/lib/axlsx/drawing/cat_axis.rb
+++ b/lib/axlsx/drawing/cat_axis.rb
@@ -42,7 +42,7 @@ module Axlsx
alias :tickMarkSkip :tick_mark_skip
# regex for validating label offset
- LBL_OFFSET_REGEX = /0*(([0-9])|([1-9][0-9])|([1-9][0-9][0-9])|1000)/
+ LBL_OFFSET_REGEX = /0*(([0-9])|([1-9][0-9])|([1-9][0-9][0-9])|1000)/.freeze
# @see tick_lbl_skip
def tick_lbl_skip=(v) Axlsx::validate_unsigned_int(v); @tick_lbl_skip = v; end
diff --git a/lib/axlsx/drawing/line_3D_chart.rb b/lib/axlsx/drawing/line_3D_chart.rb
index f9f9606e..60572785 100644
--- a/lib/axlsx/drawing/line_3D_chart.rb
+++ b/lib/axlsx/drawing/line_3D_chart.rb
@@ -26,7 +26,7 @@ module Axlsx
alias :gapDepth :gap_depth
# validation regex for gap amount percent
- GAP_AMOUNT_PERCENT = /0*(([0-9])|([1-9][0-9])|([1-4][0-9][0-9])|500)%/
+ GAP_AMOUNT_PERCENT = /0*(([0-9])|([1-9][0-9])|([1-4][0-9][0-9])|500)%/.freeze
# the category axis
# @return [Axis]
diff --git a/lib/axlsx/drawing/pic.rb b/lib/axlsx/drawing/pic.rb
index fa08bd83..320a5254 100644
--- a/lib/axlsx/drawing/pic.rb
+++ b/lib/axlsx/drawing/pic.rb
@@ -30,7 +30,7 @@ module Axlsx
end
# allowed mime types
- ALLOWED_MIME_TYPES = %w(image/jpeg image/png image/gif)
+ ALLOWED_MIME_TYPES = %w(image/jpeg image/png image/gif).freeze
# The name to use for this picture
# @return [String]
diff --git a/lib/axlsx/drawing/title.rb b/lib/axlsx/drawing/title.rb
index 2e4037fb..84687a32 100644
--- a/lib/axlsx/drawing/title.rb
+++ b/lib/axlsx/drawing/title.rb
@@ -20,11 +20,11 @@ module Axlsx
def initialize(title = "", title_size = "")
self.cell = title if title.is_a?(Cell)
self.text = title.to_s unless title.is_a?(Cell)
- if title_size.to_s.empty?
- self.text_size = "1600"
- else
- self.text_size = title_size.to_s
- end
+ self.text_size = if title_size.to_s.empty?
+ "1600"
+ else
+ title_size.to_s
+ end
end
# @see text
diff --git a/lib/axlsx/drawing/view_3D.rb b/lib/axlsx/drawing/view_3D.rb
index 9b1b5cb2..9b3489a3 100644
--- a/lib/axlsx/drawing/view_3D.rb
+++ b/lib/axlsx/drawing/view_3D.rb
@@ -18,10 +18,10 @@ module Axlsx
end
# Validation for hPercent
- H_PERCENT_REGEX = /0*(([5-9])|([1-9][0-9])|([1-4][0-9][0-9])|500)/
+ H_PERCENT_REGEX = /0*(([5-9])|([1-9][0-9])|([1-4][0-9][0-9])|500)/.freeze
# validation for depthPercent
- DEPTH_PERCENT_REGEX = /0*(([2-9][0-9])|([1-9][0-9][0-9])|(1[0-9][0-9][0-9])|2000)/
+ DEPTH_PERCENT_REGEX = /0*(([2-9][0-9])|([1-9][0-9][0-9])|(1[0-9][0-9][0-9])|2000)/.freeze
# x rotation for the chart
# must be between -90 and 90
diff --git a/lib/axlsx/stylesheet/dxf.rb b/lib/axlsx/stylesheet/dxf.rb
index 8c32a75f..2c10443a 100644
--- a/lib/axlsx/stylesheet/dxf.rb
+++ b/lib/axlsx/stylesheet/dxf.rb
@@ -8,7 +8,7 @@ module Axlsx
# The order in which the child elements is put in the XML seems to
# be important for Excel
- CHILD_ELEMENTS = [:font, :numFmt, :fill, :alignment, :border, :protection]
+ CHILD_ELEMENTS = [:font, :numFmt, :fill, :alignment, :border, :protection].freeze
# does not support extList (ExtensionList)
# The cell alignment for this style
diff --git a/lib/axlsx/stylesheet/styles.rb b/lib/axlsx/stylesheet/styles.rb
index 2bad15e8..5fe7b305 100644
--- a/lib/axlsx/stylesheet/styles.rb
+++ b/lib/axlsx/stylesheet/styles.rb
@@ -265,12 +265,12 @@ module Axlsx
alignment = parse_alignment_options options
protection = parse_protection_options options
- case options[:type]
- when :dxf
- style = Dxf.new :fill => fill, :font => font, :numFmt => numFmt, :border => border, :alignment => alignment, :protection => protection
- else
- style = Xf.new :fillId => fill || 0, :fontId => font || 0, :numFmtId => numFmt || 0, :borderId => border || 0, :alignment => alignment, :protection => protection, :applyFill => !fill.nil?, :applyFont => !font.nil?, :applyNumberFormat => !numFmt.nil?, :applyBorder => !border.nil?, :applyAlignment => !alignment.nil?, :applyProtection => !protection.nil?
- end
+ style = case options[:type]
+ when :dxf
+ Dxf.new :fill => fill, :font => font, :numFmt => numFmt, :border => border, :alignment => alignment, :protection => protection
+ else
+ Xf.new :fillId => fill || 0, :fontId => font || 0, :numFmtId => numFmt || 0, :borderId => border || 0, :alignment => alignment, :protection => protection, :applyFill => !fill.nil?, :applyFont => !font.nil?, :applyNumberFormat => !numFmt.nil?, :applyBorder => !border.nil?, :applyAlignment => !alignment.nil?, :applyProtection => !protection.nil?
+ end
if options[:type] == :xf
xf_index = (cellXfs << style)
diff --git a/lib/axlsx/util/storage.rb b/lib/axlsx/util/storage.rb
index 1e12b2d4..00cd6b3c 100644
--- a/lib/axlsx/util/storage.rb
+++ b/lib/axlsx/util/storage.rb
@@ -35,7 +35,7 @@ module Axlsx
COLORS = {
:red => 0,
:black => 1
- }
+ }.freeze
# The color of this node in the directory tree. Defaults to black if not specified
# @return [Integer] color
diff --git a/lib/axlsx/workbook/workbook.rb b/lib/axlsx/workbook/workbook.rb
index 2c6e0491..e6e2f06f 100644
--- a/lib/axlsx/workbook/workbook.rb
+++ b/lib/axlsx/workbook/workbook.rb
@@ -202,11 +202,11 @@ module Axlsx
styled_cells.each do |cell|
current_style = styles.style_index[cell.style]
- if current_style
- new_style = Axlsx.hash_deep_merge(current_style, cell.raw_style)
- else
- new_style = cell.raw_style
- end
+ new_style = if current_style
+ Axlsx.hash_deep_merge(current_style, cell.raw_style)
+ else
+ cell.raw_style
+ end
cell.style = styles.add_style(new_style)
end
diff --git a/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb b/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb
index 16096a52..e5c3ef77 100644
--- a/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb
+++ b/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb
@@ -28,7 +28,7 @@ module Axlsx
serializable_attributes :col_id, :hidden_button, :show_button
# Allowed filters
- FILTERS = [:filters] # , :top10, :custom_filters, :dynamic_filters, :color_filters, :icon_filters]
+ FILTERS = [:filters].freeze # , :top10, :custom_filters, :dynamic_filters, :color_filters, :icon_filters]
# Zero-based index indicating the AutoFilter column to which this filter information applies.
# @return [Integer]
diff --git a/lib/axlsx/workbook/worksheet/auto_filter/filters.rb b/lib/axlsx/workbook/worksheet/auto_filter/filters.rb
index 38bafe85..95e1b885 100644
--- a/lib/axlsx/workbook/worksheet/auto_filter/filters.rb
+++ b/lib/axlsx/workbook/worksheet/auto_filter/filters.rb
@@ -24,7 +24,7 @@ module Axlsx
serializable_attributes :blank, :calendar_type
# Allowed calendar types
- CALENDAR_TYPES = %w(gregorian gregorianUs gregorianMeFrench gregorianArabic hijri hebrew taiwan japan thai korea saka gregorianXlitEnglish gregorianXlitFrench none)
+ CALENDAR_TYPES = %w(gregorian gregorianUs gregorianMeFrench gregorianArabic hijri hebrew taiwan japan thai korea saka gregorianXlitEnglish gregorianXlitFrench none).freeze
# Flag indicating whether to filter by blank.
# @return [Boolean]
@@ -157,7 +157,7 @@ module Axlsx
serializable_attributes :date_time_grouping, :year, :month, :day, :hour, :minute, :second
# Allowed date time groupings
- DATE_TIME_GROUPING = %w(year month day hour minute second)
+ DATE_TIME_GROUPING = %w(year month day hour minute second).freeze
# Grouping level
# This must be one of year, month, day, hour, minute or second.
diff --git a/lib/axlsx/workbook/worksheet/col.rb b/lib/axlsx/workbook/worksheet/col.rb
index ff942d32..38ac7454 100644
--- a/lib/axlsx/workbook/worksheet/col.rb
+++ b/lib/axlsx/workbook/worksheet/col.rb
@@ -88,7 +88,7 @@ module Axlsx
# @see Col#outline
def outline_level=(v)
Axlsx.validate_unsigned_numeric(v)
- raise ArgumentError, 'outlineLevel must be between 0 and 7' unless 0 <= v && v <= 7
+ raise ArgumentError, 'outlineLevel must be between 0 and 7' unless v >= 0 && v <= 7
@outline_level = v
end
diff --git a/lib/axlsx/workbook/worksheet/data_bar.rb b/lib/axlsx/workbook/worksheet/data_bar.rb
index 482bd029..0dcdc8a8 100644
--- a/lib/axlsx/workbook/worksheet/data_bar.rb
+++ b/lib/axlsx/workbook/worksheet/data_bar.rb
@@ -38,7 +38,7 @@ module Axlsx
serializable_attributes :min_length, :max_length, :show_value
# instance values that must be serialized as their own elements - e.g. not attributes.
- CHILD_ELEMENTS = [:value_objects, :color]
+ CHILD_ELEMENTS = [:value_objects, :color].freeze
# minLength attribute
# The minimum length of the data bar, as a percentage of the cell width.
@@ -117,11 +117,11 @@ module Axlsx
def initialize_cfvos(cfvos)
self.class.default_cfvos.each_with_index.map do |default, index|
- if index < cfvos.size
- value_objects << Cfvo.new(default.merge(cfvos[index]))
- else
- value_objects << Cfvo.new(default)
- end
+ value_objects << if index < cfvos.size
+ Cfvo.new(default.merge(cfvos[index]))
+ else
+ Cfvo.new(default)
+ end
end
end
end
diff --git a/lib/axlsx/workbook/worksheet/sheet_view.rb b/lib/axlsx/workbook/worksheet/sheet_view.rb
index 73e7533e..b64920bb 100644
--- a/lib/axlsx/workbook/worksheet/sheet_view.rb
+++ b/lib/axlsx/workbook/worksheet/sheet_view.rb
@@ -50,7 +50,7 @@ module Axlsx
:view, :top_left_cell, :color_id, :zoom_scale
# instance values that must be serialized as their own elements - e.g. not attributes.
- CHILD_ELEMENTS = [:pane, :selections]
+ CHILD_ELEMENTS = [:pane, :selections].freeze
# The pane object for the sheet view
# @return [Pane]