Skip to content

Commit

Permalink
[fix] Fixed setting properties that could be an integer or string in …
Browse files Browse the repository at this point in the history
…newer versions of Ruby (5m)
  • Loading branch information
kobsy committed Feb 19, 2024
1 parent 4498cdb commit 127a496
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/openxml/drawingml/properties/percentage_property.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Properties
class PercentageProperty < ValueProperty

def valid?
value =~ OpenXml::DrawingML::ST_Percentage
value.is_a?(String) && value =~ OpenXml::DrawingML::ST_Percentage
end

def invalid_message
Expand Down
2 changes: 1 addition & 1 deletion lib/openxml/drawingml/properties/space_after.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class SpaceAfter < SimplePropertyContainerProperty

def initialize(value)
super()
target_property = value =~ /%/ ? :spacing_percent= : :spacing_points=
target_property = value.is_a?(String) && value =~ /%/ ? :spacing_percent= : :spacing_points=
public_send(target_property, value)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/openxml/drawingml/properties/space_before.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class SpaceBefore < SimplePropertyContainerProperty

def initialize(value)
super()
target_property = value =~ /%/ ? :spacing_percent= : :spacing_points=
target_property = value.is_a?(String) && value =~ /%/ ? :spacing_percent= : :spacing_points=
public_send(target_property, value)
end

Expand Down

0 comments on commit 127a496

Please sign in to comment.