ice_cube
ice_cube copied to clipboard
Fix Syntax Error in ice_cube gem for Ruby 3.0+ Compatibility
This pull request addresses a syntax error in the ice_cube gem that occurs when using Ruby 3.0 or later. The error is caused by the use of a shorthand syntax for block parameters that is not supported in earlier Ruby versions.
Current Error
SyntaxError:
/usr/local/bundle/bundler/gems/ice_cube-db4715e37368/lib/ice_cube/schedule.rb:163: syntax error, unexpected ')', expecting local variable or method
def each_occurrence(&)
^
/usr/local/bundle/bundler/gems/ice_cube-db4715e37368/lib/ice_cube/schedule.rb:164: syntax error, unexpected ')'
...rate_occurrences(start_time, &).to_a
... ^
/usr/local/bundle/bundler/gems/ice_cube-db4715e37368/lib/ice_cube/schedule.rb:502: syntax error, unexpected `end', expecting end-of-input
This PR modifies the each_occurrence method to use the traditional block syntax, which is compatible with both older and newer Ruby versions. The changes are as follows:
# Old code
def each_occurrence(&)
generate_occurrences(start_time, &).to_a
end
# New code
def each_occurrence(&block)
generate_occurrences(start_time, &block).to_a
end
This change maintains the functionality while ensuring compatibility across Ruby versions.