Class: TwitterBootstrapMarkup::Select

Inherits:
Tag
  • Object
show all
Extended by:
InputSize::ClassMethods
Includes:
InputSize::InstanceMethods
Defined in:
lib/twitter_bootstrap_markup/select.rb

Constant Summary

Constants included from Popover

Popover::POSITIONS

Constants included from Tooltip

Tooltip::POSITIONS

Instance Attribute Summary

Attributes inherited from Tag

#attributes, #children, #name

Instance Method Summary collapse

Methods inherited from Tag

#append, block, inline, #prepend, #to_s

Methods included from SidePosition

#pull_left, #pull_right

Methods included from Popover

#popover

Methods included from Tooltip

#tooltip

Constructor Details

#initialize(*args, &block) ⇒ Select

Returns a new instance of Select.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/twitter_bootstrap_markup/select.rb', line 6

def initialize(*args, &block)
  @options = args.shift || [] unless block_given?
  attributes = args.shift || {}
  @selected_value = attributes.delete(:selected_value)
  prompt = attributes.delete(:prompt)

  if block_given?
    super(:select, attributes, &block)
  else
    super(:select, attributes) {}
    append_options
  end

  prepend Tag.new(:option, prompt, :value => '') {} if prompt
end