summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/workbook/worksheet
diff options
context:
space:
mode:
authorGeremia Taglialatela <[email protected]>2023-05-17 11:17:45 +0200
committerGeremia Taglialatela <[email protected]>2023-05-24 10:03:50 +0200
commit84a7132924b1c56f712a830b4e016a3c033923bf (patch)
tree1bccc27e18be9287d568cd4c6313dbe33495acad /lib/axlsx/workbook/worksheet
parent14b7da239879d5299775c48666b43f3016add8ec (diff)
downloadcaxlsx-84a7132924b1c56f712a830b4e016a3c033923bf.tar.gz
caxlsx-84a7132924b1c56f712a830b4e016a3c033923bf.zip
Do not use collection literal in loops
Also refactors Page margins to avoid code duplication
Diffstat (limited to 'lib/axlsx/workbook/worksheet')
-rw-r--r--lib/axlsx/workbook/worksheet/page_margins.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/axlsx/workbook/worksheet/page_margins.rb b/lib/axlsx/workbook/worksheet/page_margins.rb
index 4d133c5a..9c2ddd8e 100644
--- a/lib/axlsx/workbook/worksheet/page_margins.rb
+++ b/lib/axlsx/workbook/worksheet/page_margins.rb
@@ -29,7 +29,10 @@ module Axlsx
parse_options options
end
- serializable_attributes :left, :right, :bottom, :top, :header, :footer
+ # Possible margins to set
+ MARGIN_KEYS = [:left, :right, :top, :bottom, :header, :footer].freeze
+
+ serializable_attributes(*MARGIN_KEYS)
# Default left and right margin (in inches)
DEFAULT_LEFT_RIGHT = 0.75
@@ -65,10 +68,10 @@ module Axlsx
attr_reader :footer
# Set some or all margins at once.
- # @param [Hash] margins the margins to set (possible keys are :left, :right, :top, :bottom, :header and :footer).
+ # @param [Hash] margins the margins to set. See {MARGIN_KEYS} for a list of possible keys.
def set(margins)
margins.select do |k, v|
- next unless [:left, :right, :top, :bottom, :header, :footer].include? k
+ next unless MARGIN_KEYS.include? k
send("#{k}=", v)
end