Class: Campo::Haml_Ruby_Insert

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

Constant Summary

Constants inherited from Base

Base::DEFAULT

Instance Attribute Summary

Attributes inherited from Base

#attributes, #fields

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, #password, #radio, #select, #submit, #text, #textarea

Methods included from Iding

#id_tag

Methods included from Childish

#push=

Constructor Details

#initialize(s) ⇒ Haml_Ruby_Insert

Returns a new instance of Haml_Ruby_Insert.

Raises:

  • (ArgumentError)


318
319
320
321
322
323
324
325
326
# File 'lib/campo.rb', line 318

def initialize( s )
  raise ArgumentError, "you may only pass a string to Haml_Ruby_Insert/bit_of_ruby" unless s.kind_of?( String )
  super( nil ) # no name needed
  @s = s.start_with?( '=' ) ? s : "= " + s.to_s

  self.on_output do |n=0, tab=2|
    (" " * n * tab) + @s
  end
end