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 :checked
property :form property :form
def initialize(node : Node | Myhtml::Node, value : String = node.fetch("value", "")) def initialize(node : Node | Myhtml::Node, value = "")
@checked = !!node["checked"] @checked = !!node["checked"]
@form = form @form = form
super(node) super(node, value)
end end
def check def check

View File

@ -6,8 +6,8 @@ module MechanizeCr
class Agent class Agent
property :request_headers, :context, :cookies property :request_headers, :context, :cookies
property history : Array(MechanizeCr::Page) property history : Array(MechanizeCr::Page)
def initialize(@context : Mechanize | Nil = nil, history = Array(MechanizeCr::Page).new) def initialize(@context : Mechanize | Nil = nil)
@history = history @history = Array(MechanizeCr::Page).new
@request_headers = ::HTTP::Headers.new @request_headers = ::HTTP::Headers.new
@context = context @context = context
@cookies = Hash(String, ::HTTP::Cookies).new @cookies = Hash(String, ::HTTP::Cookies).new

View File

@ -6,7 +6,6 @@ class Node < Hash(String,String)
end end
end end
# This is a real Node got from html. # This is a real Node got from html.
struct Myhtml::Node struct Myhtml::Node
delegate :[], to: attributes delegate :[], to: attributes