Class: Tagz::Tag

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

Overview

– Tag ++

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, contents = nil, attrs = {}, &block) ⇒ Tag

:nodoc:



80
81
82
83
# File 'lib/tagz/tagz.rb', line 80

def initialize name, contents = nil, attrs = {}, &block
  @name, @contents, @attrs, @proc = name, (contents || ''), attrs, block
  block.yield_or_eval self if block
end

Instance Attribute Details

#attrsObject (readonly)

Attributes hash.



71
72
73
# File 'lib/tagz/tagz.rb', line 71

def attrs
  @attrs
end

#contentsObject (readonly)

Contents string.



66
67
68
# File 'lib/tagz/tagz.rb', line 66

def contents
  @contents
end

#nameObject (readonly)

Tag name.



61
62
63
# File 'lib/tagz/tagz.rb', line 61

def name
  @name
end

#procObject (readonly)

Block proc.



76
77
78
# File 'lib/tagz/tagz.rb', line 76

def proc
  @proc
end

Instance Method Details

#tag(*args, &block) ⇒ Object

Append tag to contents.



88
89
90
# File 'lib/tagz/tagz.rb', line 88

def tag *args, &block
  @contents << Tagz.tag(*args, &block).to_s
end

#to_sObject

Return tag string.



95
96
97
# File 'lib/tagz/tagz.rb', line 95

def to_s
  create_tag name, contents, attrs, &proc
end