Class: Celerity::Option

Represents an option in a select list.

Constants

ATTRIBUTES
BASE_ATTRIBUTES | [:selected, :disabled, :label, :value]
DEFAULT_HOW
:text
TAGS
[ Identifier.new('option')]

Constructor Summary

This class inherits a constructor from Celerity::Element.

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Celerity::Element

public String method_missing(meth, *args, &blk)

Dynamically get element attributes.

Meta Tags

Parameters:

Returns:

[String]

The resulting attribute.

Raises:

[NoMethodError]

if the element doesn’t support this attribute.

See Also:

ATTRIBUTES constant for a list of valid methods for a given element.
[View source]


235
236
237
238
239
240
241
242
243
244
245
# File 'lib/celerity/element.rb', line 235

def method_missing(meth, *args, &blk)
  assert_exists

  meth = selector_to_attribute(meth)

  if self.class::ATTRIBUTES.include?(meth) || (self.class == Element && @object.hasAttribute(meth.to_s))
    return @object.getAttribute(meth.to_s)
  end
  Log.warn "Element\#method_missing calling super with #{meth.inspect}"
  super
end

Public Visibility

Public Instance Method Summary

#label
#selected?

Is this option selected?.

Public Instance Methods Included from Celerity::DisabledElement

assert_enabled, disabled?, enabled?

Public Instance Method Details

label

public label
[View source]


26
27
28
29
30
# File 'lib/celerity/elements/option.rb', line 26

def label
  # overrides Container#label
  assert_exists
  @object.getLabelAttribute
end

selected?

public selected?

Is this option selected?

[View source]


21
22
23
24
# File 'lib/celerity/elements/option.rb', line 21

def selected?
  assert_exists
  @object.isSelected
end