model node
parent
f2f450ba60
commit
16e4c7aed3
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue