Class: Tagz::Tag
- Inherits:
-
Object
- Object
- Tagz::Tag
- Defined in:
- lib/tagz/tagz.rb
Overview
– Tag ++
Instance Attribute Summary collapse
-
#attrs ⇒ Object
readonly
Attributes hash.
-
#contents ⇒ Object
readonly
Contents string.
-
#name ⇒ Object
readonly
Tag name.
-
#proc ⇒ Object
readonly
Block proc.
Instance Method Summary collapse
-
#initialize(name, contents = nil, attrs = {}, &block) ⇒ Tag
constructor
:nodoc:.
-
#tag(*args, &block) ⇒ Object
Append tag to contents.
-
#to_s ⇒ Object
Return tag string.
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
#attrs ⇒ Object (readonly)
Attributes hash.
71 72 73 |
# File 'lib/tagz/tagz.rb', line 71 def attrs @attrs end |
#contents ⇒ Object (readonly)
Contents string.
66 67 68 |
# File 'lib/tagz/tagz.rb', line 66 def contents @contents end |
#name ⇒ Object (readonly)
Tag name.
61 62 63 |
# File 'lib/tagz/tagz.rb', line 61 def name @name end |
#proc ⇒ Object (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_s ⇒ Object
Return tag string.
95 96 97 |
# File 'lib/tagz/tagz.rb', line 95 def to_s create_tag name, contents, attrs, &proc end |