I have a script I was testing to return the direction of something clockwise or counterclockwise to the direction I supply it. Here's my code:
class TestScript def clockwise_direction(direction) return [4,8,2,6][direction/2-1] end def counterclockwise_direction(direction) return [6,8,2,4][direction/2-1] end def reverse_direction(direction) return [8,6,4,2][direction/2-1] endendI THINK the syntax is correct, though I am a Ruby novice. But when I tried to use one of the functions in the script, I get an undefined method error. I'm positive I haven't made a typo. Can anyone stick this code in their own game and maybe figure out why it won't work the way I expected?
class TestScript def clockwise_direction(direction) return [4,8,2,6][direction/2-1] end def counterclockwise_direction(direction) return [6,8,2,4][direction/2-1] end def reverse_direction(direction) return [8,6,4,2][direction/2-1] endendI THINK the syntax is correct, though I am a Ruby novice. But when I tried to use one of the functions in the script, I get an undefined method error. I'm positive I haven't made a typo. Can anyone stick this code in their own game and maybe figure out why it won't work the way I expected?