On Sat, 4 Feb 2006, why the lucky stiff wrote:

> ara.t.howard / noaa.gov wrote:
>
>> which toggled the yaml output style from the standard one to an inline one. 
>> it
>> blows up now (1.8.4) with
>> 
>>   NoMethodError: undefined method `<<' for nil:NilClass
>> 
> Yeah, you can't write directly to the output stream any longer.  But the 
> emitter is much smarter, more capable now (and utterly non-rdoc'd).
>
> In current versions, you can define a `to_yaml_style' method which expects a 
> symbol describing how to output the object.  In this case, you'll want to 
> reply with :inline.
>
> >> hsh = {'to' => 'ara.t.howard / noaa.gov', 'x-mail-count' => 178223, 'from' 
> => 'why / ruby-lang.org'}
> >> def hsh.to_yaml_style; :inline end
> => nil
> >> y [hsh, {'Subject' => 'Re: YAML::quick_emit api change'}]
> ---
> - {from: why / ruby-lang.org, x-mail-count: 178223, to: ara.t.howard / noaa.gov}
> - Subject: "Re: YAML::quick_emit api change"
> => nil

since i need to toggle i'll probably do

   class OrderedHash
     attr_accessor "to_yaml_style"
   end

   oh.to_yaml_style = :inline

but is a nil value by default ok?  or do i need

   class OrderedHash
     attr_accessor "to_yaml_style"
     def to_yaml_style
       @to_yaml_style ||= :some_default
     end
   end

??

any thoughts on how to conditionally define this stuff by RUBY_VERSION?  my
old method worked with 1.8.1 and 1.8.2 - maybe

   if RUBY_VERSION >= "1.8.4"
     new_way
   else
     old_way
   end

??

>> i checked in the docs and am reading the source now - but the fix isn't 
>> jumping
>> out at me.  any ideas?
>
> I just need to improve the rdoc.  What a sorry state I've left us all in!

heh.  you won't here me complaining!  the people that complain about lack of
docs are people who don't write libraries or who don't write that many - it's
hard enough writing code.  let them eat cake.

-a

-- 
happiness is not something ready-made.  it comes from your own actions.
- h.h. the 14th dali lama