Hi,
I have some code that has to be used by more than one method in the same
class. Would I create a module for this or is there a better way?
eg.
module QuestionSequencer
class Sequence
def sequence_questions
initial_now_playing_length = play_list[0].length
now_playing = play_list[0]
clone_number = 3
order = "random" # $$$Variable
if order == "random"
now_playing_temp = Array.new
for i in 1..clone_number
now_playing = now_playing.dup.shuffle
now_playing_temp = now_playing_temp + now_playing
end
now_playing = now_playing_temp
for d in 1..clone_number # Check for sequential duplicates:
if now_playing[(initial_now_playing_length * d) -1 ]
=now_playing[initial_now_playing_length * d]
value = now_playing.delete_at(initial_now_playing_length *
d)
now_playing.insert(now_playing.length, value) # Reinsert
the item in a new position
end
end
else # Sequential
now_playing = now_playing.dup * clone_number
end
now_playing
end
end
end
in method:
now_playing = play_list.sequence_questions
in model:
include QuestionSequencer
This is not working but would like to know if I'm at least going in the
correct direction.
Thanks,
Dave
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/db738b6b3851e15e7d928d79c39b26e4%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.