Class: Campo::Fieldset

Inherits:
Base
  • Object
show all
Defined in:
lib/campo/campo.rb

Constant Summary

Constants inherited from Base

Base::DEFAULT

Instance Attribute Summary

Attributes inherited from Base

#attributes, #attributes The element's html attributes., #fields, #fields The element's child elements.

Attributes included from Childish

#parent

Instance Method Summary collapse

Methods inherited from Base

#each, #labelled, #on_output, #output, output, quotable, unhash

Methods included from Convenience

#bit_of_ruby, #checkbox, #fieldset, #hidden, #input, #literal, #password, #radio, #select, #submit, #text, #textarea

Methods included from Iding

#id_tag

Methods included from Childish

#push=

Constructor Details

#initialize(text = nil, attributes = {}) ⇒ Fieldset

Returns a new instance of Fieldset.

Parameters:

  • text (String, nil) (defaults to: nil)

    Text for the legend tag

  • attributes (Hash) (defaults to: {})

    Hash of html attributes



666
667
668
669
670
671
672
673
674
675
676
677
678
# File 'lib/campo/campo.rb', line 666

def initialize( text=nil, attributes={} )
  if text.kind_of? Hash
    attributes = text
    text = nil
  end
  super( nil, attributes )
  @attributes.delete(:name)
  
  self.on_output do |n=0, tab=2|
    %Q!#{" " * n * tab}%fieldset{ #{Base.unhash( @attributes )} }! 
  end
  @fields.unshift Legend.new( text ) unless text.nil?
end