Class: Aurita::GUI::Buffered_Element

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

Overview

class

Instance Attribute Summary

Attributes inherited from Element

#attrib, #force_closing_tag, #parent, #tag

Instance Method Summary collapse

Methods inherited from Element

#+, #<<, #[], #[]=, #add_class, #clear_floating, #css_classes, #find_by_dom_id, #get_content, #has_content?, #id, #id=, #recurse, #remove_class, #set_content, #string, #swap, #to_ary, #type=

Methods included from Marshal_Helper_Class_Methods

#marshal_load

Methods included from Marshal_Helper

#marshal_dump

Constructor Details

#initialize(buffer, *args, &block) ⇒ Buffered_Element

Returns a new instance of Buffered_Element.



477
478
479
480
# File 'lib/aurita-gui/element.rb', line 477

def initialize(buffer, *args, &block)
  @output_buffer = buffer
  super(*args, &block)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, value = nil, &block) ⇒ Object



482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
# File 'lib/aurita-gui/element.rb', line 482

def method_missing(meth, value=nil, &block)
  if block_given? then
    @attrib[:class] = meth
    @attrib.update(value) if value.is_a? Hash
    c = yield
    c = [ c ] unless c.is_a?(Array)
    __setobj__(c)

    return string()
  elsif !value.nil? && !meth.to_s.include?('=') then
    @attrib[:class] = meth
    case value
    when Hash then
      @attrib.update(value)
      c = value[:content] 
      c = [ c ] if (c && !c.is_a?(Array))
      __setobj__(c) if c
    when String then
      __setobj__([value])
    end

    return string()
  else
    return @attrib[meth] unless value or meth.to_s.include? '='
    @attrib[meth.to_s.gsub('=','').intern] = value
  end
end