Class: Aurita::GUI::Fieldset

Inherits:
Element
  • Object
show all
Defined in:
lib/aurita-gui/form/fieldset.rb

Instance Attribute Summary collapse

Attributes inherited from Element

#attrib, #parent, #tag, #type

Instance Method Summary collapse

Methods inherited from Element

#+, #[], #[]=, #clear_floating, #dom_id, #dom_id=, #each, #empty?, #id, #id=, #length, #method_missing, #string, #to_ary

Constructor Details

#initialize(params, &block) ⇒ Fieldset

Returns a new instance of Fieldset.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/aurita-gui/form/fieldset.rb', line 10

def initialize(params, &block)
  params[:tag] = :fieldset
  @name = params[:name]
  @elements = []
  if block_given? then
    yield.each { |field_element|
      add(field_element)
    }
  end
  legend_element   = params[:legend]
  legend_element ||= params[:label]
  set_legend(legend_element)
  params.delete(:legend)
  params.delete(:label)
  params.delete(:name)
  super(params, &block)
end

Dynamic Method Handling

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

Instance Attribute Details

#labelObject Also known as: legend

Returns the value of attribute label.



8
9
10
# File 'lib/aurita-gui/form/fieldset.rb', line 8

def label
  @label
end

#legend=(field) ⇒ Object Also known as: set_legend, label=

Sets the attribute legend

Parameters:

  • value

    the value to set the attribute legend to.



8
9
10
# File 'lib/aurita-gui/form/fieldset.rb', line 8

def legend=(value)
  @legend = value
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/aurita-gui/form/fieldset.rb', line 8

def name
  @name
end

Instance Method Details

#add(field_element) ⇒ Object



39
40
41
# File 'lib/aurita-gui/form/fieldset.rb', line 39

def add(field_element)
  @elements << field_element
end

#contentObject



43
44
45
46
47
48
49
50
# File 'lib/aurita-gui/form/fieldset.rb', line 43

def content
  if @legend then
    @content = [ @legend, @elements ]
  else 
    @content = @elements
  end
  return @content
end