refactor code

master
Kanezoh 2021-06-16 11:59:04 +09:00
parent 0df9f07aef
commit c2411e73eb
3 changed files with 4 additions and 5 deletions

View File

@ -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

View File

@ -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

View File

@ -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