Class: Chop::Form::Select

Inherits:
Field
  • Object
show all
Defined in:
lib/chop/form.rb

Instance Attribute Summary

Attributes inherited from Field

#field, #label, #path, #session, #value

Instance Method Summary collapse

Methods inherited from Field

candidates, for, from

Instance Method Details

#fill_in!Object



100
101
102
# File 'lib/chop/form.rb', line 100

def fill_in!
  session.select value, from: label
end

#get_valueObject



104
105
106
107
108
# File 'lib/chop/form.rb', line 104

def get_value
  if selected_value = field.value
    field.find("option[value='#{selected_value}']").text
  end
end

#matches?Boolean

Returns:

  • (Boolean)


96
97
98
# File 'lib/chop/form.rb', line 96

def matches?
  field.tag_name == "select" && !field[:multiple]
end