From c2411e73eb328881e00ff10ba7fd683f128818aa Mon Sep 17 00:00:00 2001 From: Kanezoh Date: Wed, 16 Jun 2021 11:59:04 +0900 Subject: [PATCH] refactor code --- src/mechanize/form/check_box.cr | 4 ++-- src/mechanize/http/agent.cr | 4 ++-- src/mechanize/node.cr | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/mechanize/form/check_box.cr b/src/mechanize/form/check_box.cr index 3f63318..3e3218b 100644 --- a/src/mechanize/form/check_box.cr +++ b/src/mechanize/form/check_box.cr @@ -2,10 +2,10 @@ class MechanizeCr::FormContent::CheckBox < MechanizeCr::FormContent::Field property :checked property :form - def initialize(node : Node | Myhtml::Node, value : String = node.fetch("value", "")) + def initialize(node : Node | Myhtml::Node, value = "") @checked = !!node["checked"] @form = form - super(node) + super(node, value) end def check diff --git a/src/mechanize/http/agent.cr b/src/mechanize/http/agent.cr index 7931a0e..2fef4dc 100644 --- a/src/mechanize/http/agent.cr +++ b/src/mechanize/http/agent.cr @@ -6,8 +6,8 @@ module MechanizeCr class Agent property :request_headers, :context, :cookies property history : Array(MechanizeCr::Page) - def initialize(@context : Mechanize | Nil = nil, history = Array(MechanizeCr::Page).new) - @history = history + def initialize(@context : Mechanize | Nil = nil) + @history = Array(MechanizeCr::Page).new @request_headers = ::HTTP::Headers.new @context = context @cookies = Hash(String, ::HTTP::Cookies).new diff --git a/src/mechanize/node.cr b/src/mechanize/node.cr index 571ef08..b464b0b 100644 --- a/src/mechanize/node.cr +++ b/src/mechanize/node.cr @@ -6,7 +6,6 @@ class Node < Hash(String,String) end end - # This is a real Node got from html. struct Myhtml::Node delegate :[], to: attributes