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



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

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

#get_valueObject



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

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

#matches?Boolean

Returns:

  • (Boolean)


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

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