On 28 Dec 2008, at 13:04, zero0x wrote:
>
> --------
>
> So I created a new class, called timetable, and I would like to create
> methods like 1_1, 1_1=, 1_2, 1_2= - getters and setters for each
> lesson of each day.
>
Well you'll have to pick different names because 1_1 isn't a legal
method name
> By the way, the timetable has a result set from active record as a
> private variable, and I turned it into hash, so that I could access it
> by @subject_lessons['1_1'] etc.
>
> In PHP, there's a __call method, which would do something like this:
>
> function __call($function, $arguments)
> {
> $this->subject_lessons[$function] = $arguments[0];
> }
>
Still not entirely clear to me what this does, but I'd be surprised if
some combination of method_missing and send didn't get you there.
Fred
> So I need something like this in Ruby. Hope someone will help me :)
> Thank you guys very much! :)
>
> ---
>
> By the way Ruby is beautiful but it is pretty different from PHP (I'm
> working in PHP for like 4 years, and in Ruby for like few days)
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---