Class: Campo::Label

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

Constant Summary collapse

DEFAULT =
{ for: nil }

Instance Attribute Summary collapse

Attributes inherited from Base

#attributes The element's html attributes., #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(for_element, inner = nil, attributes = {}) ⇒ Label

Returns a new instance of Label.



702
703
704
705
706
707
708
709
710
711
712
713
714
# File 'lib/campo/campo.rb', line 702

def initialize( for_element, inner=nil, attributes={} )
  if inner.kind_of? Hash
    attributes = inner
    inner = nil
  end
  super( nil, attributes.merge(for: for_element) )

  @inner = inner

  self.on_output do |n=0, tab=2|
    %Q!#{" " * n * tab}%label{ #{Base.unhash( @attributes )} }\n#{" " * (n + 1) * tab}#{@inner}! 
  end
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



700
701
702
# File 'lib/campo/campo.rb', line 700

def attributes
  @attributes
end

#fieldsObject (readonly)

Returns the value of attribute fields.



700
701
702
# File 'lib/campo/campo.rb', line 700

def fields
  @fields
end