mechanize:Mechanize::Form#buttons_with, #buttons
以下のような HTML で
<html> <head> <title>form test</title> </head> <body> <form method="get" action="cgi/foo00.cgi" name="form1"> <input type="submit" value="Send" /> <input type="reset" value="Cancel" /> </form> </body> </html>
>> require 'mechanize' => true >> agent = Mechanize.new => #<Mechanize:0xb7440540 ... >> page = agent.get('http://127.0.0.1:8080/test11_button.html') => #<Mechanize::Page {url #<URI::HTTP:0xb743cbc0 URL:http://127.0.0.1:8080/test11_button.html>} {meta} {title "form test"} {iframes} {frames} {links} {forms #<Mechanize::Form {name "form1"} {method "GET"} {action "cgi/foo00.cgi"} {fields} {radiobuttons} {checkboxes} {file_uploads} {buttons #<Mechanize::Form::Submit:0xb74341dc @name=nil, @node= #(Element:0x..fdba1a17a { name = "input", attributes = [ #(Attr:0x..fdba18690 { name = "type", value = "submit" }), #(Attr:0x..fdba18686 { name = "value", value = "Send" })] }), @value="Send">}>}> >> f = page.form('form1') => #<Mechanize::Form {name "form1"} {method "GET"} {action "cgi/foo00.cgi"} {fields} {radiobuttons} {checkboxes} {file_uploads} {buttons #<Mechanize::Form::Submit:0xb74341dc @name=nil, @node= #(Element:0x..fdba1a17a { name = "input", attributes = [ #(Attr:0x..fdba18690 { name = "type", value = "submit" }), #(Attr:0x..fdba18686 { name = "value", value = "Send" })] }), @value="Send">}> >> f.buttons_with => [#<Mechanize::Form::Submit:0xb74341dc @name=nil, @value="Send", @node=#<Nokogiri::XML::Element:0x..fdba1a17a name="input" attributes=[#<Nokogiri::XML::Attr:0x..fdba18690 name="type" value="submit">, #<Nokogiri::XML::Attr:0x..fdba18686 name="value" value="Send">]>>] >> f.buttons_with.size => 1 >> f.button_with => #<Mechanize::Form::Submit:0xb74341dc @name=nil, @value="Send", @node=#<Nokogiri::XML::Element:0x..fdba1a17a name="input" attributes=[#<Nokogiri::XML::Attr:0x..fdba18690 name="type" value="submit">, #<Nokogiri::XML::Attr:0x..fdba18686 name="value" value="Send">]>> >> f.buttons => [#<Mechanize::Form::Submit:0xb74341dc @name=nil, @value="Send", @node=#<Nokogiri::XML::Element:0x..fdba1a17a name="input" attributes=[#<Nokogiri::XML::Attr:0x..fdba18690 name="type" value="submit">, #<Nokogiri::XML::Attr:0x..fdba18686 name="value" value="Send">]>>] >> f.button => #<Mechanize::Form::Submit:0xb74341dc @name=nil, @value="Send", @node=#<Nokogiri::XML::Element:0x..fdba1a17a name="input" attributes=[#<Nokogiri::XML::Attr:0x..fdba18690 name="type" value="submit">, #<Nokogiri::XML::Attr:0x..fdba18686 name="value" value="Send">]>>
複数形の _with の場合は、「attr_reader :fields, :buttons, :file_uploads, :radiobuttons, :checkboxes」があるので _with の alias ではないらしい〜(なので引数は取れないはず)