Class: Mechanize::Form::MultiSelectList

Inherits:
Object
  • Object
show all
Defined in:
lib/saber/mechanize_ext.rb

Instance Method Summary collapse

Instance Method Details

#select_all_with_tagenObject Also known as: select_all

Select all options



71
72
73
74
# File 'lib/saber/mechanize_ext.rb', line 71

def select_all_with_tagen
  @text_value = []
  select_all_withoutout_tagen
end

#select_none_with_tagenObject Also known as: select_none

Select no options



63
64
65
66
# File 'lib/saber/mechanize_ext.rb', line 63

def select_none_with_tagen
  @text_value = []
  select_none_without_tagen
end

#text_valueObject



78
79
80
81
82
83
# File 'lib/saber/mechanize_ext.rb', line 78

def text_value
  value = []
  value.concat @text_value
  value.concat selected_options.map { |o| o.text }
  value
end

#text_value=(values) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
# File 'lib/saber/mechanize_ext.rb', line 85

def text_value=(values)
  select_none
  [values].flatten.each do |value|
    option = options.find { |o| o.text == value }
    if option.nil?
      @text_value.push(value)
    else
      option.select
    end
  end
end