Class: Lipa::Kind

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

Overview

Implemenation of kind(template) for description

Examples:

tree = Lipa::Tree.new :tree do 
  kind :some_kind do
    param1 "some_param"
  end

  some_kind :some_instance 
end
tree["some_instance"].param_1 #=> "some_param"

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, attrs = {}, &block) ⇒ Kind



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/lipa/kind.rb', line 42

def initialize(name, attrs = {}, &block)
  # OPTIMIZE: Make it shorter
  if attrs[:for]
    @for = attr[:for]
    attrs[:for] = nil
  else
    @for = :node
  end

  @attrs = attrs
  @name = name.to_sym
  @block = block if block_given?
end

Instance Attribute Details

#attrsObject (readonly)

Returns the value of attribute attrs.



41
42
43
# File 'lib/lipa/kind.rb', line 41

def attrs
  @attrs
end

#blockObject (readonly)

Returns the value of attribute block.



41
42
43
# File 'lib/lipa/kind.rb', line 41

def block
  @block
end

#forObject (readonly)

Returns the value of attribute for.



41
42
43
# File 'lib/lipa/kind.rb', line 41

def for
  @for
end

#nameObject (readonly)

Returns the value of attribute name.



41
42
43
# File 'lib/lipa/kind.rb', line 41

def name
  @name
end