Class: Campo::Label

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

Constant Summary collapse

DEFAULT =
{ for: nil }

Instance Attribute Summary collapse

Attributes included from Childish

#parent

Instance Method Summary collapse

Methods inherited from Base

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

Methods included from Convenience

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

Methods included from Iding

#id_tag

Methods included from Childish

#push=

Constructor Details

#initialize(name, inner = nil, attributes = {}) ⇒ Label

Returns a new instance of Label.



489
490
491
492
493
494
495
496
497
498
499
500
501
# File 'lib/campo.rb', line 489

def initialize( name, inner=nil, attributes={} )
  if inner.kind_of? Hash
    attributes = inner
    inner = nil
  end
  super( name, attributes )

  @inner = inner

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

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



487
488
489
# File 'lib/campo.rb', line 487

def attributes
  @attributes
end

#fieldsObject (readonly)

Returns the value of attribute fields.



487
488
489
# File 'lib/campo.rb', line 487

def fields
  @fields
end