model node

master
Kanezoh 2021-05-19 21:23:52 +09:00
parent f2f450ba60
commit 16e4c7aed3
3 changed files with 11 additions and 5 deletions

View File

@ -25,7 +25,9 @@ class Mechanize
form = MechanizeCr::Form.new(node)
query.each do |k,v|
form.fields << MechanizeCr::FormContent::Field.new({"name" => k}, v)
node = Node.new
node["name"] = k
form.fields << MechanizeCr::FormContent::Field.new(node, v)
end
#post_form(uri, form, headers)
end

View File

@ -2,7 +2,7 @@ class MechanizeCr::FormContent::CheckBox < MechanizeCr::FormContent::Field
property :checked
property :form
def initialize(node : Node, value : String = node["value"])
def initialize(node : Node, value : String = node.fetch("value", ""))
@checked = !!node["checked"]
@form = form
super(node)

View File

@ -1,10 +1,14 @@
class MechanizeCr::FormContent::Field
property :node, :value
def initialize(node : Hash(String, String), value : String = node["value"])
property :node, :value, :name
def initialize(node : Node, value : String = node.fetch("value", ""), name : String = node.fetch("name", ""))
@node = node
#@name = Mechanize::Util.html_unescape(node['name'])
@name = name
#@raw_value = value
@value = value
#@type = node['type']
end
def query_value
[[@name, @value || ""]]
end
end