diff --git a/src/mechanize/form/field.cr b/src/mechanize/form/field.cr index 0dbd854..b0c7f69 100644 --- a/src/mechanize/form/field.cr +++ b/src/mechanize/form/field.cr @@ -1,15 +1,15 @@ class MechanizeCr::FormContent::Field - getter :node property value : String? getter name : String getter type : String getter raw_value : String? + getter node : Node | Myhtml::Node def initialize(node : Node | Myhtml::Node, value=nil) - @node = node - @name = node.fetch("name", "") - @value = value || node.fetch("value", nil) - @type = node.fetch("type", "") + @node = node + @name = node.fetch("name", "") + @value = value || node.fetch("value", nil) + @type = node.fetch("type", "") @raw_value = @value end diff --git a/src/mechanize/form/multi_select_list.cr b/src/mechanize/form/multi_select_list.cr index ec3526e..a6f674c 100644 --- a/src/mechanize/form/multi_select_list.cr +++ b/src/mechanize/form/multi_select_list.cr @@ -2,16 +2,16 @@ require "./option" class MechanizeCr::FormContent::MultiSelectList getter node : Myhtml::Node - property values : Array(String) getter name : String getter type : String + property values : Array(String) property options : Array(FormContent::Option) def initialize(node : Myhtml::Node) - @node = node - @name = node.fetch("name", "") - @type = node.fetch("type", "") - @values = Array(String).new + @node = node + @name = node.fetch("name", "") + @type = node.fetch("type", "") + @values = Array(String).new @options = Array(FormContent::Option).new node.css("option").each { |n| @options << FormContent::Option.new(n, self) diff --git a/src/mechanize/form/option.cr b/src/mechanize/form/option.cr index 149e5c6..0c06e2c 100644 --- a/src/mechanize/form/option.cr +++ b/src/mechanize/form/option.cr @@ -1,14 +1,15 @@ class MechanizeCr::FormContent::Option getter select_list : FormContent::MultiSelectList - getter node : Myhtml::Node - getter text : String - getter value : String - getter selected : Bool + getter node : Myhtml::Node + getter text : String + getter value : String + getter selected : Bool + def initialize(node, select_list) - @node = node - @text = node.inner_text - @value = (node["value"] || node.inner_text) - @selected = node.has_key?("selected") + @node = node + @text = node.inner_text + @value = (node["value"] || node.inner_text) + @selected = node.has_key?("selected") @select_list = select_list # The select list this option belongs to end diff --git a/src/mechanize/form/radio_button.cr b/src/mechanize/form/radio_button.cr index fb2c04f..fa3a413 100644 --- a/src/mechanize/form/radio_button.cr +++ b/src/mechanize/form/radio_button.cr @@ -3,7 +3,7 @@ class MechanizeCr::FormContent::RadioButton < MechanizeCr::FormContent::Field def initialize(node : Node | Myhtml::Node, form : Form) @checked = !!node.fetch("checked", nil) - @form = form + @form = form super(node) end