Sha256: eceddddfa745b3c538a5cbb1d2aa4251346f5fca5f23fb58366ad66bfca6e34c

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

module Druid
  module Elements
    class SelectList < Element

      def self.finders
        super + [:value, :text]
      end

      def [](idx)
        Druid::Elements::Option.new(options[idx])
      end

      def options
        element.options
      end

      #
      # Select a value from the list
      #
      def select(value)
        element.select(value)
      end

      #
      # Select the options whose value attribute matches the Given
      # string
      #
      def select_value(value)
        element.select_value(value)
      end

      #
      # @return [Array<sTRING>] An array of strings representing the text value of the currently selected options.
      #
      def selected_options
        element.selected_options.map { |e| e.text }.compact
      end

      #
      # Returns true if the select list has one or more options where text or label matches the given value.
      #
      # @param [String, Regexp] value A value
      # @return [Boolean]
      def include? value
        element.include? value
      end

      #
      # Returns true if any of the selected options' text or label match the given value.
      # @param [String, Regexp] value A value
      # @return [Boolean]
      def selected? value
        element.selected? value
      end
    end

    Druid::Elements.tag_to_class[:select] = Druid::Elements::SelectList
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
druid-ts-1.1.4 lib/druid/elements/select_list.rb