From 23b2748e0ff87539375c2aec9c7e23c8240b71d6 Mon Sep 17 00:00:00 2001 From: Kanezoh Date: Thu, 17 Jun 2021 15:43:00 +0900 Subject: [PATCH] refactor form --- src/mechanize/form.cr | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/mechanize/form.cr b/src/mechanize/form.cr index bb71b3b..cc0315a 100644 --- a/src/mechanize/form.cr +++ b/src/mechanize/form.cr @@ -70,19 +70,16 @@ class MechanizeCr::Form {% end %} private def parse - @fields = Array(FormContent::Field).new - @checkboxes = Array(FormContent::CheckBox).new - @radiobuttons = Array(FormContent::RadioButton).new @node.css("input").not_nil!.each do |html_node| html_node = html_node.as(Myhtml::Node) type = (html_node["type"] || "text").downcase case type when "checkbox" - @checkboxes << FormContent::CheckBox.new(html_node, self) + checkboxes << FormContent::CheckBox.new(html_node, self) when "radio" - @radiobuttons << FormContent::RadioButton.new(html_node, self) + radiobuttons << FormContent::RadioButton.new(html_node, self) else - @fields << FormContent::Field.new(html_node) + fields << FormContent::Field.new(html_node) end end end