[#409331] Capture HTML table data, pass to Ruby, pass back and display result in HTML text field — Hubert Wagner <lists@...>

Hello :

11 messages 2013/08/04

[#409336] Rakefile Error - Please Help — "Jennifer T." <lists@...>

Hi,

13 messages 2013/08/04
[#409341] Re: Rakefile Error - Please Help — Hassan Schroeder <hassan.schroeder@...> 2013/08/04

On Sun, Aug 4, 2013 at 7:41 AM, Jennifer T. <lists@ruby-forum.com> wrote:

Re: Saving with yaml

From: Sandor Szs <sandor.szuecs@...>
Date: 2013-08-06 17:40:13 UTC
List: ruby-talk #404603
On 8/6/13 5:41 PM, Green Eco wrote:
> Hi,
> =

> I have a question. :-) I have already found a lot in the web but that
> does not really helped me. This far my code looks like this:
> =

> =

> to save:
> =

> require "yaml"
> =

> @characters =3D ["Molly", "Trade"]
> @saves =3D {location: "Southeaster",
>   hunger: 10,
>   life: 76
>   }
> @settings =3D {display: "1360*960",
>   render: "high",
>   saves: "manual"
>   }
> =

> output =3D File.new("Saves.yaml", "w") do |file|
>   YAML.dump
> end
> output.write YAML.dump(@characters) # Wie sichert man mehrere

For example:
File.open("Saves.yaml", "w") do |file|
  file.write(YAML.dump(@characters))
  file.write(YAML.dump(@saves))
  file.write(YAML.dump(@settings))
end

or

File.open("Saves.yaml", "w") do |file|
  [@characters,@saves,@settings].each do |item|
    file.write(YAML.dump(item))
  end
end

or even better:

File.open("Saves.yaml", "w") do |file|
  file.write(YAML.dump([@characters,@saves,@settings]))
end
YAML.load File.read "Saves.yaml"
# =3D> [["Molly", "Trade"], {:location=3D>"Southeaster", :hunger=3D>10,
:life=3D>76}, {:display=3D>"1360*960", :render=3D>"high", :saves=3D>"manual=
"}]


-- =

All the best, Sandor Sz=FCcs
_______________________________________________
ruby-talk mailing list
ruby-talk@ruby-lang.org
http://lists.ruby-lang.org/cgi-bin/mailman/listinfo/ruby-talk

In This Thread