Forum: Ruby Re: How to improve this kind of API?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F3b7b8756d0c7f71cc7460cc33aefaee?d=identicon&s=25 Berger, Daniel (Guest)
on 2006-02-09 20:52
(Received via mailing list)
> it always boils down to some widget attribute that can have a
>
> splitter3.expanded? :bottom_left
> Thanks in advance for your suggestions!
>
> Lyle

FWIW, I think what you've posted here looks good, so long as I could use
strings as well, e.g. splitter.expand("top_left").

Regards,

Dan
Cb48ca5059faf7409a5ab3745a964696?d=identicon&s=25 unknown (Guest)
on 2006-02-09 21:25
(Received via mailing list)
On Fri, 10 Feb 2006, Berger, Daniel wrote:

>> it always boils down to some widget attribute that can have a
>>
>> splitter3.expanded? :bottom_left
>> Thanks in advance for your suggestions!
>>
>> Lyle
>
> FWIW, I think what you've posted here looks good, so long as I could use
> strings as well, e.g. splitter.expand("top_left").

indeed.  a symbols only api is evil - makes reading config info from
files/yaml a pain.

a config method is also quite nice

   splitter.configure {
     expand 'top_left'
     something 'foobar'
   }

which should also take a hash

   splitter.configured(
     'expand' => 'top_left',
     'something' => 'foobar'
   )

which makes

   splitter.configure(YAML::load(IO:;read('config.yml')))

a one liner.

if config.yml has

   ---
   expand : top_left
   something : foobar

in it.

regards.

-a
0276239ca57aee241d4b41379587fa20?d=identicon&s=25 Lyle Johnson (Guest)
on 2006-02-09 21:46
(Received via mailing list)
On 2/9/06, ara.t.howard@noaa.gov <ara.t.howard@noaa.gov> wrote:

> indeed.  a symbols only api is evil - makes reading config info from
> files/yaml a pain....

<snip>

>    something : foobar
>
> in it.

How would one specify (especially in the YAML representation) that
both the "top_left" and "top_right" bits for "expand" should be set?
Would it look something like this:

    ---
    expand:
      - top_left
      -top_right
    something: foobar

I don't have as much exposure to YAML as I probably should. ;)
Cb48ca5059faf7409a5ab3745a964696?d=identicon&s=25 Ara.T.Howard (Guest)
on 2006-02-09 22:42
(Received via mailing list)
On Thu, 9 Feb 2006, Lyle Johnson wrote:

>>
> How would one specify (especially in the YAML representation) that
> both the "top_left" and "top_right" bits for "expand" should be set?
> Would it look something like this:
>
>    ---
>    expand:
>      - top_left
>      -top_right
>    something: foobar
>
> I don't have as much exposure to YAML as I probably should. ;)

exactly right.

btw.  it's easy to figure out:


   harp:~ > ruby -r yaml -e' y "expand" => ["top_left", "top_right"],
"foo" => "bar" '
   ---
   expand:
   - top_left
   - top_right
   foo: bar


cheers.

-a
This topic is locked and can not be replied to.