Loading ...
Sorry, an error occurred while loading the content.

Re: [XP] Ruby Question

Expand Messages
  • Phlip
    ... Ruby lets you add methods to existing classes on the fly. Classes are objects, all the way up. ... It s YAML to declare a map (hash) entry with a key of
    Message 1 of 3 , Aug 26, 2005
    • 0 Attachment
      Various wrote:

      > It might be, but I don't know Ruby. All you need is the ability to add
      > methods to existing classes (called "loose methods" in Smalltalk). If
      > Ruby lets you do that, then you can use the same technique there.

      Ruby lets you add methods to existing classes on the fly. Classes are
      objects, all the way up.

      >> That in mind, I do see this in Rails:
      >>
      >> scaffold: someScafoldName
      >>
      >> What does the ':' mean? Is this a method call?

      It's YAML to declare a map (hash) entry with a key of 'scaffold' and value
      of 'someScaffoldName'.

      YAML is like XML without the <> cruft. I leverage YAML (and Ruby) here:

      http://www.zeroplayer.com/cgi-bin/wiki?TestWikiFormat

      No maps, though...

      --
      Phlip
      http://www.greencheese.org/ZeekLand <-- NOT a blog!!!
    • Mando Escamilla
      In this particular case, it s a symbol and not YAML. THere s a slight (but important) syntax differentiation between the two. YAML looks like this foo: bar
      Message 2 of 3 , Aug 26, 2005
      • 0 Attachment
        In this particular case, it's a symbol and not YAML. THere's a slight (but
        important) syntax differentiation between the two.

        YAML looks like this

        foo: bar
        baz: mu

        while symbols look like this

        foo :bar
        baz :mu

        In RubyOnRails, symbols are used as immutable strings to keep things
        consistent and memory-usage to a minimum. So, when you see something like

        scaffold :model_name

        what's really going on is you're calling the scaffold method with an
        argument of model_name.

        http://glu.ttono.us/articles/2005/08/19/understanding-ruby-symbols offers a
        great explanation of symbols, as does
        http://farm.tucows.com/blog/_archives/2005/8/23/1163240.html
        --
        Mando


        On 8/26/05, Phlip <phlip2005@...> wrote:
        >
        > Various wrote:
        >
        > > It might be, but I don't know Ruby. All you need is the ability to add
        > > methods to existing classes (called "loose methods" in Smalltalk). If
        > > Ruby lets you do that, then you can use the same technique there.
        >
        > Ruby lets you add methods to existing classes on the fly. Classes are
        > objects, all the way up.
        >
        > >> That in mind, I do see this in Rails:
        > >>
        > >> scaffold: someScafoldName
        > >>
        > >> What does the ':' mean? Is this a method call?
        >
        > It's YAML to declare a map (hash) entry with a key of 'scaffold' and value
        > of 'someScaffoldName'.
        >
        > YAML is like XML without the <> cruft. I leverage YAML (and Ruby) here:
        >
        > http://www.zeroplayer.com/cgi-bin/wiki?TestWikiFormat
        >
        > No maps, though...
        >
        > --
        > Phlip
        > http://www.greencheese.org/ZeekLand <-- NOT a blog!!!
        >
        >
        >
        > To Post a message, send it to: extremeprogramming@...
        >
        > To Unsubscribe, send a blank message to:
        > extremeprogramming-unsubscribe@...
        >
        > ad-free courtesy of objectmentor.com <http://objectmentor.com>
        > Yahoo! Groups Links
        >
        >
        >
        >
        >
        >
        >


        [Non-text portions of this message have been removed]
      • Chris Wheeler
        ... Mando, These links and the rest of your post were exactly what I was looking for. Thanks to all who helped me out! Chris. -- ... Chris Wheeler Extreme
        Message 3 of 3 , Aug 26, 2005
        • 0 Attachment
          >
          > http://glu.ttono.us/articles/2005/08/19/understanding-ruby-symbols offers
          > a
          > great explanation of symbols, as does
          > http://farm.tucows.com/blog/_archives/2005/8/23/1163240.html


          Mando,

          These links and the rest of your post were exactly what I was looking for.
          Thanks to all who helped me out!

          Chris.

          --
          ---------------------
          Chris Wheeler
          Extreme Programmer & Coach
          Visit my new site! http://www.agilelectric.com


          [Non-text portions of this message have been removed]
        Your message has been successfully submitted and would be delivered to recipients shortly.