summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/drawing
diff options
context:
space:
mode:
authorGeremia Taglialatela <[email protected]>2023-06-10 11:48:13 +0200
committerGeremia Taglialatela <[email protected]>2023-06-10 11:48:13 +0200
commitee14c1bf5c6aaa96867eb4b90b510f91c3a614f8 (patch)
tree63a893a73f1cc51003edf218fed178bb93c604d7 /lib/axlsx/drawing
parentcfb516062de3d0725b3245cc328f96d702d662d3 (diff)
downloadcaxlsx-ee14c1bf5c6aaa96867eb4b90b510f91c3a614f8.tar.gz
caxlsx-ee14c1bf5c6aaa96867eb4b90b510f91c3a614f8.zip
Fix safe Style/ColonMethodCall offenses
Caxlsx is using both `.` and `::`, 220 occurrences vs 280 to invoke methods on `Axlsx` module. This commit standardizes the approach towards `.`, which will also allow shorter lines. Performance is not affected ``` Comparison: Axlsx.validate: 8515252.3 i/s Axlsx::validate: 8512863.7 i/s - same-ish: difference falls within error ```
Diffstat (limited to 'lib/axlsx/drawing')
-rw-r--r--lib/axlsx/drawing/area_series.rb6
-rw-r--r--lib/axlsx/drawing/axis.rb10
-rw-r--r--lib/axlsx/drawing/cat_axis.rb6
-rw-r--r--lib/axlsx/drawing/chart.rb10
-rw-r--r--lib/axlsx/drawing/d_lbls.rb2
-rw-r--r--lib/axlsx/drawing/hyperlink.rb6
-rw-r--r--lib/axlsx/drawing/line_series.rb6
-rw-r--r--lib/axlsx/drawing/marker.rb10
-rw-r--r--lib/axlsx/drawing/num_data.rb2
-rw-r--r--lib/axlsx/drawing/num_data_source.rb2
-rw-r--r--lib/axlsx/drawing/num_val.rb4
-rw-r--r--lib/axlsx/drawing/one_cell_anchor.rb4
-rw-r--r--lib/axlsx/drawing/pic.rb8
-rw-r--r--lib/axlsx/drawing/pie_series.rb2
-rw-r--r--lib/axlsx/drawing/scatter_series.rb6
-rw-r--r--lib/axlsx/drawing/ser_axis.rb4
-rw-r--r--lib/axlsx/drawing/series.rb2
-rw-r--r--lib/axlsx/drawing/series_title.rb4
-rw-r--r--lib/axlsx/drawing/str_val.rb2
-rw-r--r--lib/axlsx/drawing/title.rb4
-rw-r--r--lib/axlsx/drawing/view_3D.rb4
21 files changed, 52 insertions, 52 deletions
diff --git a/lib/axlsx/drawing/area_series.rb b/lib/axlsx/drawing/area_series.rb
index 30bd9402..0e3d8928 100644
--- a/lib/axlsx/drawing/area_series.rb
+++ b/lib/axlsx/drawing/area_series.rb
@@ -52,19 +52,19 @@ module Axlsx
# @see show_marker
def show_marker=(v)
- Axlsx::validate_boolean(v)
+ Axlsx.validate_boolean(v)
@show_marker = v
end
# @see marker_symbol
def marker_symbol=(v)
- Axlsx::validate_marker_symbol(v)
+ Axlsx.validate_marker_symbol(v)
@marker_symbol = v
end
# @see smooth
def smooth=(v)
- Axlsx::validate_boolean(v)
+ Axlsx.validate_boolean(v)
@smooth = v
end
diff --git a/lib/axlsx/drawing/axis.rb b/lib/axlsx/drawing/axis.rb
index dfef7890..ed3df5f1 100644
--- a/lib/axlsx/drawing/axis.rb
+++ b/lib/axlsx/drawing/axis.rb
@@ -109,15 +109,15 @@ module Axlsx
# The number format format code for this axis
# default :General
- def format_code=(v) Axlsx::validate_string(v); @format_code = v; end
+ def format_code=(v) Axlsx.validate_string(v); @format_code = v; end
# Specify if gridlines should be shown for this axis
# default true
- def gridlines=(v) Axlsx::validate_boolean(v); @gridlines = v; end
+ def gridlines=(v) Axlsx.validate_boolean(v); @gridlines = v; end
# Specify if axis should be removed from the chart
# default false
- def delete=(v) Axlsx::validate_boolean(v); @delete = v; end
+ def delete=(v) Axlsx.validate_boolean(v); @delete = v; end
# specifies how the perpendicular axis is crossed
# must be one of [:autoZero, :min, :max]
@@ -126,9 +126,9 @@ module Axlsx
# Specify the degree of label rotation to apply to labels
# default true
def label_rotation=(v)
- Axlsx::validate_int(v)
+ Axlsx.validate_int(v)
adjusted = v.to_i * 60000
- Axlsx::validate_angle(adjusted)
+ Axlsx.validate_angle(adjusted)
@label_rotation = adjusted
end
diff --git a/lib/axlsx/drawing/cat_axis.rb b/lib/axlsx/drawing/cat_axis.rb
index d26e3dc9..d078eb6f 100644
--- a/lib/axlsx/drawing/cat_axis.rb
+++ b/lib/axlsx/drawing/cat_axis.rb
@@ -45,15 +45,15 @@ module Axlsx
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
+ def tick_lbl_skip=(v) Axlsx.validate_unsigned_int(v); @tick_lbl_skip = v; end
alias :tickLblSkip= :tick_lbl_skip=
# @see tick_mark_skip
- def tick_mark_skip=(v) Axlsx::validate_unsigned_int(v); @tick_mark_skip = v; end
+ def tick_mark_skip=(v) Axlsx.validate_unsigned_int(v); @tick_mark_skip = v; end
alias :tickMarkSkip= :tick_mark_skip=
# From the docs: This element specifies that this axis is a date or text axis based on the data that is used for the axis labels, not a specific choice.
- def auto=(v) Axlsx::validate_boolean(v); @auto = v; end
+ def auto=(v) Axlsx.validate_boolean(v); @auto = v; end
# specifies how the perpendicular axis is crossed
# must be one of [:ctr, :l, :r]
diff --git a/lib/axlsx/drawing/chart.rb b/lib/axlsx/drawing/chart.rb
index 63a12641..1e0b3fb6 100644
--- a/lib/axlsx/drawing/chart.rb
+++ b/lib/axlsx/drawing/chart.rb
@@ -62,7 +62,7 @@ module Axlsx
# Configures the vary_colors options for this chart
# @param [Boolean] v The value to set
- def vary_colors=(v) Axlsx::validate_boolean(v); @vary_colors = v; end
+ def vary_colors=(v) Axlsx.validate_boolean(v); @vary_colors = v; end
# The title object for the chart.
# @return [Title]
@@ -149,13 +149,13 @@ module Axlsx
# Show the legend in the chart
# @param [Boolean] v
# @return [Boolean]
- def show_legend=(v) Axlsx::validate_boolean(v); @show_legend = v; end
+ def show_legend=(v) Axlsx.validate_boolean(v); @show_legend = v; end
# How to display blank values
# @see display_blanks_as
# @param [Symbol] v
# @return [Symbol]
- def display_blanks_as=(v) Axlsx::validate_display_blanks_as(v); @display_blanks_as = v; end
+ def display_blanks_as=(v) Axlsx.validate_display_blanks_as(v); @display_blanks_as = v; end
# The style for the chart.
# see ECMA Part 1 ยง21.2.2.196
@@ -194,12 +194,12 @@ module Axlsx
# Whether only data from visible cells should be plotted.
# @param [Boolean] v
# @return [Boolean]
- def plot_visible_only=(v) Axlsx::validate_boolean(v); @plot_visible_only = v; end
+ def plot_visible_only=(v) Axlsx.validate_boolean(v); @plot_visible_only = v; end
# Whether the chart area shall have rounded corners.
# @param [Boolean] v
# @return [Boolean]
- def rounded_corners=(v) Axlsx::validate_boolean(v); @rounded_corners = v; end
+ def rounded_corners=(v) Axlsx.validate_boolean(v); @rounded_corners = v; end
# Serializes the object
# @param [String] str
diff --git a/lib/axlsx/drawing/d_lbls.rb b/lib/axlsx/drawing/d_lbls.rb
index 7e3936cc..7a42c51c 100644
--- a/lib/axlsx/drawing/d_lbls.rb
+++ b/lib/axlsx/drawing/d_lbls.rb
@@ -78,7 +78,7 @@ module Axlsx
%w(d_lbl_pos show_legend_key show_val show_cat_name show_ser_name show_percent show_bubble_size show_leader_lines).each do |key|
next unless instance_vals.key?(key) && !instance_vals[key].nil?
- str << "<c:#{Axlsx::camel(key, false)} val='#{instance_vals[key]}' />"
+ str << "<c:#{Axlsx.camel(key, false)} val='#{instance_vals[key]}' />"
end
str << '</c:dLbls>'
end
diff --git a/lib/axlsx/drawing/hyperlink.rb b/lib/axlsx/drawing/hyperlink.rb
index acf3b8d2..682aae29 100644
--- a/lib/axlsx/drawing/hyperlink.rb
+++ b/lib/axlsx/drawing/hyperlink.rb
@@ -52,7 +52,7 @@ module Axlsx
# @see endSnd
# @param [Boolean] v The boolean value indicating the termination of playing sounds on click
# @return [Boolean]
- def end_snd=(v) Axlsx::validate_boolean(v); @end_snd = v end
+ def end_snd=(v) Axlsx.validate_boolean(v); @end_snd = v end
alias :endSnd= :end_snd=
# indicates that the link has already been clicked.
@@ -62,7 +62,7 @@ module Axlsx
# @see highlightClick
# @param [Boolean] v The value to assign
- def highlight_click=(v) Axlsx::validate_boolean(v); @highlight_click = v end
+ def highlight_click=(v) Axlsx.validate_boolean(v); @highlight_click = v end
alias :highlightClick= :highlight_click=
# From the specs: Specifies whether to add this URI to the history when navigating to it. This allows for the viewing of this presentation without the storing of history information on the viewing machine. If this attribute is omitted, then a value of 1 or true is assumed.
@@ -71,7 +71,7 @@ module Axlsx
# @see history
# param [Boolean] v The value to assing
- def history=(v) Axlsx::validate_boolean(v); @history = v end
+ def history=(v) Axlsx.validate_boolean(v); @history = v end
# From the specs: Specifies the target frame that is to be used when opening this hyperlink. When the hyperlink is activated this attribute is used to determine if a new window is launched for viewing or if an existing one can be used. If this attribute is omitted, than a new window is opened.
# @return [String]
diff --git a/lib/axlsx/drawing/line_series.rb b/lib/axlsx/drawing/line_series.rb
index 9f8e09e3..13492419 100644
--- a/lib/axlsx/drawing/line_series.rb
+++ b/lib/axlsx/drawing/line_series.rb
@@ -52,19 +52,19 @@ module Axlsx
# @see show_marker
def show_marker=(v)
- Axlsx::validate_boolean(v)
+ Axlsx.validate_boolean(v)
@show_marker = v
end
# @see marker_symbol
def marker_symbol=(v)
- Axlsx::validate_marker_symbol(v)
+ Axlsx.validate_marker_symbol(v)
@marker_symbol = v
end
# @see smooth
def smooth=(v)
- Axlsx::validate_boolean(v)
+ Axlsx.validate_boolean(v)
@smooth = v
end
diff --git a/lib/axlsx/drawing/marker.rb b/lib/axlsx/drawing/marker.rb
index a1801eb9..ec476297 100644
--- a/lib/axlsx/drawing/marker.rb
+++ b/lib/axlsx/drawing/marker.rb
@@ -34,13 +34,13 @@ module Axlsx
attr_reader :rowOff
# @see col
- def col=(v) Axlsx::validate_unsigned_int v; @col = v end
+ def col=(v) Axlsx.validate_unsigned_int v; @col = v end
# @see colOff
- def colOff=(v) Axlsx::validate_int v; @colOff = v end
+ def colOff=(v) Axlsx.validate_int v; @colOff = v end
# @see row
- def row=(v) Axlsx::validate_unsigned_int v; @row = v end
+ def row=(v) Axlsx.validate_unsigned_int v; @row = v end
# @see rowOff
- def rowOff=(v) Axlsx::validate_int v; @rowOff = v end
+ def rowOff=(v) Axlsx.validate_int v; @rowOff = v end
# shortcut to set the column, row position for this marker
# @param col the column for the marker, a Cell object or a string reference like "B7"
@@ -68,7 +68,7 @@ module Axlsx
# @see Chart#start_at
def parse_coord_args(x, y = 0)
if x.is_a?(String)
- x, y = *Axlsx::name_to_indices(x)
+ x, y = *Axlsx.name_to_indices(x)
end
if x.is_a?(Cell)
x, y = *x.pos
diff --git a/lib/axlsx/drawing/num_data.rb b/lib/axlsx/drawing/num_data.rb
index 356926b2..3ad23cb4 100644
--- a/lib/axlsx/drawing/num_data.rb
+++ b/lib/axlsx/drawing/num_data.rb
@@ -31,7 +31,7 @@ module Axlsx
# @see format_code
def format_code=(v = 'General')
- Axlsx::validate_string(v)
+ Axlsx.validate_string(v)
@format_code = v
end
diff --git a/lib/axlsx/drawing/num_data_source.rb b/lib/axlsx/drawing/num_data_source.rb
index 0845ad31..b4081aae 100644
--- a/lib/axlsx/drawing/num_data_source.rb
+++ b/lib/axlsx/drawing/num_data_source.rb
@@ -17,7 +17,7 @@ module Axlsx
@f = nil
@data = @data_type.new(options)
if options[:data] && options[:data].first.is_a?(Cell)
- @f = Axlsx::cell_range(options[:data])
+ @f = Axlsx.cell_range(options[:data])
end
parse_options options
end
diff --git a/lib/axlsx/drawing/num_val.rb b/lib/axlsx/drawing/num_val.rb
index 862d22ae..a945fb65 100644
--- a/lib/axlsx/drawing/num_val.rb
+++ b/lib/axlsx/drawing/num_val.rb
@@ -18,13 +18,13 @@ module Axlsx
# @see format_code
def format_code=(v)
- Axlsx::validate_string(v)
+ Axlsx.validate_string(v)
@format_code = v
end
# serialize the object
def to_xml_string(idx, str = +'')
- Axlsx::validate_unsigned_int(idx)
+ Axlsx.validate_unsigned_int(idx)
unless v.to_s.empty?
str << '<c:pt idx="' << idx.to_s << '" formatCode="' << format_code << '"><c:v>' << v.to_s << '</c:v></c:pt>'
end
diff --git a/lib/axlsx/drawing/one_cell_anchor.rb b/lib/axlsx/drawing/one_cell_anchor.rb
index 402b51ab..22b09944 100644
--- a/lib/axlsx/drawing/one_cell_anchor.rb
+++ b/lib/axlsx/drawing/one_cell_anchor.rb
@@ -60,10 +60,10 @@ module Axlsx
#
# @see height
- def height=(v) Axlsx::validate_unsigned_int(v); @height = v; end
+ def height=(v) Axlsx.validate_unsigned_int(v); @height = v; end
# @see width
- def width=(v) Axlsx::validate_unsigned_int(v); @width = v; end
+ def width=(v) Axlsx.validate_unsigned_int(v); @width = v; end
# The index of this anchor in the drawing
# @return [Integer]
diff --git a/lib/axlsx/drawing/pic.rb b/lib/axlsx/drawing/pic.rb
index 08beb2d9..630d8d96 100644
--- a/lib/axlsx/drawing/pic.rb
+++ b/lib/axlsx/drawing/pic.rb
@@ -78,7 +78,7 @@ module Axlsx
end
def image_src=(v)
- Axlsx::validate_string(v)
+ Axlsx.validate_string(v)
if remote?
RegexValidator.validate('Pic.image_src', /\A#{URI::DEFAULT_PARSER.make_regexp}\z/, v)
RestrictionValidator.validate 'Pic.image_src', ALLOWED_MIME_TYPES, MimeTypeUtils.get_mime_type_from_uri(v)
@@ -91,13 +91,13 @@ module Axlsx
end
# @see name
- def name=(v) Axlsx::validate_string(v); @name = v; end
+ def name=(v) Axlsx.validate_string(v); @name = v; end
# @see descr
- def descr=(v) Axlsx::validate_string(v); @descr = v; end
+ def descr=(v) Axlsx.validate_string(v); @descr = v; end
# @see remote
- def remote=(v) Axlsx::validate_boolean(v); @remote = v; end
+ def remote=(v) Axlsx.validate_boolean(v); @remote = v; end
def remote?
remote == 1 || remote.to_s == 'true'
diff --git a/lib/axlsx/drawing/pie_series.rb b/lib/axlsx/drawing/pie_series.rb
index 091267f4..416cd93c 100644
--- a/lib/axlsx/drawing/pie_series.rb
+++ b/lib/axlsx/drawing/pie_series.rb
@@ -39,7 +39,7 @@ module Axlsx
def colors=(v) DataTypeValidator.validate "BarSeries.colors", [Array], v; @colors = v end
# @see explosion
- def explosion=(v) Axlsx::validate_unsigned_int(v); @explosion = v; end
+ def explosion=(v) Axlsx.validate_unsigned_int(v); @explosion = v; end
# Serializes the object
# @param [String] str
diff --git a/lib/axlsx/drawing/scatter_series.rb b/lib/axlsx/drawing/scatter_series.rb
index a287a112..865c6f85 100644
--- a/lib/axlsx/drawing/scatter_series.rb
+++ b/lib/axlsx/drawing/scatter_series.rb
@@ -43,7 +43,7 @@ module Axlsx
@smooth = [:smooth, :smoothMarker].include?(chart.scatter_style)
else
# Set smoothing according to the option provided
- Axlsx::validate_boolean(options[:smooth])
+ Axlsx.validate_boolean(options[:smooth])
@smooth = options[:smooth]
end
@ln_width = options[:ln_width] unless options[:ln_width].nil?
@@ -62,7 +62,7 @@ module Axlsx
# @see smooth
def smooth=(v)
- Axlsx::validate_boolean(v)
+ Axlsx.validate_boolean(v)
@smooth = v
end
@@ -73,7 +73,7 @@ module Axlsx
# @see marker_symbol
def marker_symbol=(v)
- Axlsx::validate_marker_symbol(v)
+ Axlsx.validate_marker_symbol(v)
@marker_symbol = v
end
diff --git a/lib/axlsx/drawing/ser_axis.rb b/lib/axlsx/drawing/ser_axis.rb
index 4fea58e5..24eb0926 100644
--- a/lib/axlsx/drawing/ser_axis.rb
+++ b/lib/axlsx/drawing/ser_axis.rb
@@ -22,11 +22,11 @@ module Axlsx
end
# @see tickLblSkip
- def tick_lbl_skip=(v) Axlsx::validate_unsigned_int(v); @tick_lbl_skip = v; end
+ def tick_lbl_skip=(v) Axlsx.validate_unsigned_int(v); @tick_lbl_skip = v; end
alias :tickLblSkip= :tick_lbl_skip=
# @see tickMarkSkip
- def tick_mark_skip=(v) Axlsx::validate_unsigned_int(v); @tick_mark_skip = v; end
+ def tick_mark_skip=(v) Axlsx.validate_unsigned_int(v); @tick_mark_skip = v; end
alias :tickMarkSkip= :tick_mark_skip=
# Serializes the object
diff --git a/lib/axlsx/drawing/series.rb b/lib/axlsx/drawing/series.rb
index 5a91dd44..134cd7d0 100644
--- a/lib/axlsx/drawing/series.rb
+++ b/lib/axlsx/drawing/series.rb
@@ -40,7 +40,7 @@ module Axlsx
end
# @see order
- def order=(v) Axlsx::validate_unsigned_int(v); @order = v; end
+ def order=(v) Axlsx.validate_unsigned_int(v); @order = v; end
# @see title
def title=(v)
diff --git a/lib/axlsx/drawing/series_title.rb b/lib/axlsx/drawing/series_title.rb
index 08e5e909..366fc175 100644
--- a/lib/axlsx/drawing/series_title.rb
+++ b/lib/axlsx/drawing/series_title.rb
@@ -7,11 +7,11 @@ module Axlsx
# @param [String] str
# @return [String]
def to_xml_string(str = +'')
- clean_value = Axlsx::trust_input ? @text.to_s : ::CGI.escapeHTML(Axlsx::sanitize(@text.to_s))
+ clean_value = Axlsx.trust_input ? @text.to_s : ::CGI.escapeHTML(Axlsx.sanitize(@text.to_s))
str << '<c:tx>'
str << '<c:strRef>'
- str << '<c:f>' << Axlsx::cell_range([@cell]) << '</c:f>'
+ str << '<c:f>' << Axlsx.cell_range([@cell]) << '</c:f>'
str << '<c:strCache>'
str << '<c:ptCount val="1"/>'
str << '<c:pt idx="0">'
diff --git a/lib/axlsx/drawing/str_val.rb b/lib/axlsx/drawing/str_val.rb
index 86663cec..8bae630d 100644
--- a/lib/axlsx/drawing/str_val.rb
+++ b/lib/axlsx/drawing/str_val.rb
@@ -24,7 +24,7 @@ module Axlsx
# serialize the object
def to_xml_string(idx, str = +'')
- Axlsx::validate_unsigned_int(idx)
+ Axlsx.validate_unsigned_int(idx)
unless v.to_s.empty?
str << '<c:pt idx="' << idx.to_s << '"><c:v>' << ::CGI.escapeHTML(v.to_s) << '</c:v></c:pt>'
end
diff --git a/lib/axlsx/drawing/title.rb b/lib/axlsx/drawing/title.rb
index 84687a32..8fa79e52 100644
--- a/lib/axlsx/drawing/title.rb
+++ b/lib/axlsx/drawing/title.rb
@@ -69,11 +69,11 @@ module Axlsx
def to_xml_string(str = +'')
str << '<c:title>'
unless empty?
- clean_value = Axlsx::trust_input ? @text.to_s : ::CGI.escapeHTML(Axlsx::sanitize(@text.to_s))
+ clean_value = Axlsx.trust_input ? @text.to_s : ::CGI.escapeHTML(Axlsx.sanitize(@text.to_s))
str << '<c:tx>'
if @cell.is_a?(Cell)
str << '<c:strRef>'
- str << '<c:f>' << Axlsx::cell_range([@cell]) << '</c:f>'
+ str << '<c:f>' << Axlsx.cell_range([@cell]) << '</c:f>'
str << '<c:strCache>'
str << '<c:ptCount val="1"/>'
str << '<c:pt idx="0">'
diff --git a/lib/axlsx/drawing/view_3D.rb b/lib/axlsx/drawing/view_3D.rb
index 5b29b296..c3f5838d 100644
--- a/lib/axlsx/drawing/view_3D.rb
+++ b/lib/axlsx/drawing/view_3D.rb
@@ -82,7 +82,7 @@ module Axlsx
alias :depthPercent= :depth_percent=
# @see r_ang_ax
- def r_ang_ax=(v) Axlsx::validate_boolean(v); @r_ang_ax = v; end
+ def r_ang_ax=(v) Axlsx.validate_boolean(v); @r_ang_ax = v; end
alias :rAngAx= :r_ang_ax=
# @see perspective
@@ -111,7 +111,7 @@ module Axlsx
val = Axlsx.instance_values_for(self)[name]
return "" if val.nil?
- format("<%s:%s val='%s'/>", namespace, Axlsx::camel(name, false), val)
+ format("<%s:%s val='%s'/>", namespace, Axlsx.camel(name, false), val)
end
end
end