summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/workbook/worksheet/cell_serializer.rb
diff options
context:
space:
mode:
authorPaul Kmiec <[email protected]>2023-05-04 16:31:08 -0700
committerPaul Kmiec <[email protected]>2023-05-04 18:02:55 -0700
commitfabe8cb2571c8865270247ca78ddc01d493a9ee1 (patch)
tree27fe0b0df8c9bec8f746d92a0d128cad197027b2 /lib/axlsx/workbook/worksheet/cell_serializer.rb
parentfef93ec8ae2caf8a3f8310dbf8101c103e5905e4 (diff)
downloadcaxlsx-fabe8cb2571c8865270247ca78ddc01d493a9ee1.tar.gz
caxlsx-fabe8cb2571c8865270247ca78ddc01d493a9ee1.zip
Fix tests / code to work with frozen string literals
Diffstat (limited to 'lib/axlsx/workbook/worksheet/cell_serializer.rb')
-rw-r--r--lib/axlsx/workbook/worksheet/cell_serializer.rb44
1 files changed, 22 insertions, 22 deletions
diff --git a/lib/axlsx/workbook/worksheet/cell_serializer.rb b/lib/axlsx/workbook/worksheet/cell_serializer.rb
index 3c8f87dc..b4c16b57 100644
--- a/lib/axlsx/workbook/worksheet/cell_serializer.rb
+++ b/lib/axlsx/workbook/worksheet/cell_serializer.rb
@@ -9,8 +9,8 @@ module Axlsx
# @param [Integer] column_index The index of the cell's column
# @param [String] str The string to apend serialization to.
# @return [String]
- def to_xml_string(row_index, column_index, cell, str = '')
- str << ('<c r="' << Axlsx::cell_r(column_index, row_index) << '" s="' << cell.style.to_s << '" ')
+ def to_xml_string(row_index, column_index, cell, str = +'')
+ str << (+'<c r="' << Axlsx::cell_r(column_index, row_index) << '" s="' << cell.style.to_s << '" ')
return str << '/>' if cell.value.nil?
method = cell.type
@@ -21,7 +21,7 @@ module Axlsx
# builds an xml text run based on this cells attributes.
# @param [String] str The string instance this run will be concated to.
# @return [String]
- def run_xml_string(cell, str = '')
+ def run_xml_string(cell, str = +'')
if cell.is_text_run?
valid = RichTextRun::INLINE_STYLES - [:value, :type]
data = Hash[Axlsx.instance_values_for(cell).map { |k, v| [k.to_sym, v] }]
@@ -30,7 +30,7 @@ module Axlsx
elsif cell.contains_rich_text?
cell.value.to_xml_string(str)
else
- str << ('<t>' << cell.clean_value << '</t>')
+ str << (+'<t>' << cell.clean_value << '</t>')
end
str
end
@@ -39,7 +39,7 @@ module Axlsx
# @param [Cell] cell The cell that is being serialized
# @param [String] str The string the serialized content will be appended to.
# @return [String]
- def iso_8601(cell, str = '')
+ def iso_8601(cell, str = +'')
value_serialization 'd', cell.value, str
end
@@ -47,7 +47,7 @@ module Axlsx
# @param [Cell] cell The cell that is being serialized
# @param [String] str The string the serialized content will be appended to.
# @return [String]
- def date(cell, str = '')
+ def date(cell, str = +'')
value_serialization false, DateTimeConverter::date_to_serial(cell.value).to_s, str
end
@@ -55,7 +55,7 @@ module Axlsx
# @param [Cell] cell The cell that is being serialized
# @param [String] str The string the serialized content will be appended to.
# @return [String]
- def time(cell, str = '')
+ def time(cell, str = +'')
value_serialization false, DateTimeConverter::time_to_serial(cell.value).to_s, str
end
@@ -63,7 +63,7 @@ module Axlsx
# @param [Cell] cell The cell that is being serialized
# @param [String] str The string the serialized content will be appended to.
# @return [String]
- def boolean(cell, str = '')
+ def boolean(cell, str = +'')
value_serialization 'b', cell.value.to_s, str
end
@@ -71,7 +71,7 @@ module Axlsx
# @param [Cell] cell The cell that is being serialized
# @param [String] str The string the serialized content will be appended to.
# @return [String]
- def float(cell, str = '')
+ def float(cell, str = +'')
numeric cell, str
end
@@ -79,7 +79,7 @@ module Axlsx
# @param [Cell] cell The cell that is being serialized
# @param [String] str The string the serialized content will be appended to.
# @return [String]
- def integer(cell, str = '')
+ def integer(cell, str = +'')
numeric cell, str
end
@@ -87,25 +87,25 @@ module Axlsx
# @param [Cell] cell The cell that is being serialized
# @param [String] str The string the serialized content will be appended to.
# @return [String]
- def formula_serialization(cell, str = '')
- str << ('t="str"><f>' << cell.clean_value.to_s.sub('=', '') << '</f>')
- str << ('<v>' << cell.formula_value.to_s << '</v>') unless cell.formula_value.nil?
+ def formula_serialization(cell, str = +'')
+ str << (+'t="str"><f>' << cell.clean_value.to_s.sub('=', '') << '</f>')
+ str << (+'<v>' << cell.formula_value.to_s << '</v>') unless cell.formula_value.nil?
end
# Serializes cells that are type array formula
# @param [Cell] cell The cell that is being serialized
# @param [String] str The string the serialized content will be appended to.
# @return [String]
- def array_formula_serialization(cell, str = '')
- str << ('t="str">' << '<f t="array" ref="' << cell.r << '">' << cell.clean_value.to_s.sub('{=', '').sub(/}$/, '') << '</f>')
- str << ('<v>' << cell.formula_value.to_s << '</v>') unless cell.formula_value.nil?
+ def array_formula_serialization(cell, str = +'')
+ str << (+'t="str">' << '<f t="array" ref="' << cell.r << '">' << cell.clean_value.to_s.sub('{=', '').sub(/}$/, '') << '</f>')
+ str << (+'<v>' << cell.formula_value.to_s << '</v>') unless cell.formula_value.nil?
end
# Serializes cells that are type inline_string
# @param [Cell] cell The cell that is being serialized
# @param [String] str The string the serialized content will be appended to.
# @return [String]
- def inline_string_serialization(cell, str = '')
+ def inline_string_serialization(cell, str = +'')
str << 't="inlineStr"><is>'
run_xml_string cell, str
str << '</is>'
@@ -115,7 +115,7 @@ module Axlsx
# @param [Cell] cell The cell that is being serialized
# @param [String] str The string the serialized content will be appended to.
# @return [String]
- def string(cell, str = '')
+ def string(cell, str = +'')
if cell.is_array_formula?
array_formula_serialization cell, str
elsif cell.is_formula?
@@ -153,13 +153,13 @@ module Axlsx
private
- def numeric(cell, str = '')
+ def numeric(cell, str = +'')
value_serialization 'n', cell.value, str
end
- def value_serialization(serialization_type, serialization_value, str = '')
- str << ('t="' << serialization_type.to_s << '"') if serialization_type
- str << ('><v>' << serialization_value.to_s << '</v>')
+ def value_serialization(serialization_type, serialization_value, str = +'')
+ str << (+'t="' << serialization_type.to_s << '"') if serialization_type
+ str << (+'><v>' << serialization_value.to_s << '</v>')
end
end
end