mechanize:Mechanize::Form#build_query

以下のような HTML で

<html>
<head>
<title>form test</title>
</head>
<body>

<form method="post" action="cgi/foo00.cgi" name="form1">
</form>

<form method="post" action="cgi/foo01.cgi" name="form2">
</form>

</body>
</html>
>> require 'mechanize'
=> true
>> agent = Mechanize.new
=> #<Mechanize:0xb7464594 ...
>> page = agent.get('http://127.0.0.1:8080/test01_form.html')
=> #<Mechanize::Page
 {url #<URI::HTTP:0xb7460cdc URL:http://127.0.0.1:8080/test01_form.html>}
 {meta}
 {title "form test"}
 {iframes}
 {frames}
 {links}
 {forms
  #<Mechanize::Form
   {name "form1"}
   {method "POST"}
   {action "cgi/foo00.cgi"}
   {fields}
   {radiobuttons}
   {checkboxes}
   {file_uploads}
   {buttons}>
  #<Mechanize::Form
   {name "form2"}
   {method "POST"}
   {action "cgi/foo01.cgi"}
   {fields}
   {radiobuttons}
   {checkboxes}
   {file_uploads}
   {buttons}>}>

>> f = page.form('form1')
=> #<Mechanize::Form
 {name "form1"}
 {method "POST"}
 {action "cgi/foo00.cgi"}
 {fields}
 {radiobuttons}
 {checkboxes}
 {file_uploads}
 {buttons}>

>> f.build_query
=> []

以下のような HTML で

<html>
<head>
<title>form test</title>
</head>
<body>

<form method="get" action="cgi/foo00.cgi" name="form1">
  <input type="text" name="text1" />
  <input type="hidden" name="hidden1" />
  <textarea name="textarea1" rows="4" cols="40">foo</textarea>
</form>

</body>
</html>
>> require 'mechanize'
=> true
>> agent = Mechanize.new
=> #<Mechanize:0xb74dd5ac ...
>> page = agent.get('http://127.0.0.1:8080/test10_form.html')
=> #<Mechanize::Page
 {url #<URI::HTTP:0xb74d9cf4 URL:http://127.0.0.1:8080/test10_form.html>}
 {meta}
 {title "form test"}
 {iframes}
 {frames}
 {links}
 {forms
  #<Mechanize::Form
   {name "form1"}
   {method "GET"}
   {action "cgi/foo00.cgi"}
   {fields
    #<Mechanize::Form::Text:0xb74d1270
     @name="text1",
     @node=
      #(Element:0x..fdba68a0a {
        name = "input",
        attributes = [
          #(Attr:0x..fdba67010 { name = "type", value = "text" }),
          #(Attr:0x..fdba67006 { name = "name", value = "text1" })]
        }),
     @value="">
    #<Mechanize::Form::Hidden:0xb74d10a4
     @name="hidden1",
     @node=
      #(Element:0x..fdba689ba {
        name = "input",
        attributes = [
          #(Attr:0x..fdba65b2a { name = "type", value = "hidden" }),
          #(Attr:0x..fdba65b20 { name = "name", value = "hidden1" })]
        }),
     @value="">
    #<Mechanize::Form::Field:0xb74d0938
     @name="textarea1",
     @node=
      #(Element:0x..fdba684d8 {
        name = "textarea",
        attributes = [
          #(Attr:0x..fdba64676 { name = "name", value = "textarea1" }),
          #(Attr:0x..fdba6466c { name = "rows", value = "4" }),
          #(Attr:0x..fdba64662 { name = "cols", value = "40" })],
        children = [ #(Text "foo")]
        }),
     @value="foo">}
   {radiobuttons}
   {checkboxes}
   {file_uploads}
   {buttons}>}>

>> f = page.form('form1')
=> #<Mechanize::Form
  ...
>> f.build_query
=> [["text1", ""], ["hidden1", ""], ["textarea1", "foo"]]