Class: RuPov::Base

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = '') {|_self| ... } ⇒ Base

Returns a new instance of Base.

Yields:

  • (_self)

Yield Parameters:

  • _self (RuPov::Base)

    the object that the method was called on



7
8
9
10
11
# File 'lib/rupov.rb', line 7

def initialize( name='' )
    @name = name
    @children = []
    yield(self) if block_given? and self.class == Base
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/rupov.rb', line 6

def name
  @name
end

Instance Method Details

#<<(child) ⇒ Object



18
19
20
# File 'lib/rupov.rb', line 18

def <<( child )
    @children << child
end

#to_sObject



12
13
14
15
16
17
# File 'lib/rupov.rb', line 12

def to_s
    result = "#{name}#{name.length>0?' ':''}{\n"
    @children.each { |child| result << child.to_s.rstrip+"\n" }
    result << "}"
    result
end