Can ruby do this?

First of all, it’s easy to deduce from the nature of my question that I
am complete beginner as far as Ruby is concerned.

I was wondering is Ruby capable of creating a website that is able to
rotate images say, once per hour;

  • have a timer that counts from 60 to 0 mins that is linked to that
    image rotation;
  • all while being able to get images for said rotation (in certain
    order) from a folder I earlier specified.

I am sorry if I didn’t formulate my question correctly, but this is as
near as I can get to verbally expressing my problem on a forum,
considering I am not native English speaker.

Thanks in advance

Yes it can but it would be better to use jquery for that purpose.

Google “jquery image slider” and you will see many examples

Hello Goran ~

You can use ruby for your purpose. Though what you want to look into
is called a service or daemon. There are external gem projects if you
just need the functionality or you could look into how to create it by
hand. Another technique would be to build your rotation function to
trigger based on get request. Either way you will need to create a
state for comparing previous time to the new time before rendering the
page.

~

On Thu, Jan 31, 2013 at 9:20 PM, Goran S. [email protected] wrote:

I was wondering is Ruby capable of creating a website that is able to
rotate images say, once per hour;

  • have a timer that counts from 60 to 0 mins that is linked to that
    image rotation;
  • all while being able to get images for said rotation (in certain
    order) from a folder I earlier specified.

I’m not exactly sure what you want here – are you talking about a
page that stays on user’s browser for hours at a time? Or do you mean
to change the image downloaded by many users over the course of a day
once per hour?

Both are quite doable in Ruby, although the implementation would be
somewhat different.

In the first case, where you want the web page to be sitting around
being viewed for hours, you could do it with a page refresh to reload
the entire page and the new image, or you could do it with an AJAX
call to just load the image.

Or, depending on how many images (and how big they are) you’re talking
about, you wouldn’t even need an AJAX call, you could download all the
images and just use a JavaScript timer to swap the images. (This is
typically referred to as a carousel; google “JavaScript carousel”.)

In the second case, you wouldn’t actually need a timer, per se, just
store a Time when the current image expires. Then, when the site is
loaded, check to see if the time has passed and substitute the next
image and set a new expiration time.