Class: Inkcite::View::TagStack
- Inherits:
-
Object
- Object
- Inkcite::View::TagStack
- Defined in:
- lib/inkcite/view/tag_stack.rb
Instance Attribute Summary collapse
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
Instance Method Summary collapse
-
#<<(opt) ⇒ Object
(also: #push)
Pushes a new set of options onto the stack for this tag.
-
#initialize(tag, ctx) ⇒ TagStack
constructor
A new instance of TagStack.
-
#opts ⇒ Object
Retrieves the most recent set of options for this tag.
-
#pop ⇒ Object
Pops the most recent tag off of the stack.
Constructor Details
#initialize(tag, ctx) ⇒ TagStack
Returns a new instance of TagStack.
9 10 11 12 13 |
# File 'lib/inkcite/view/tag_stack.rb', line 9 def initialize tag, ctx @tag = tag @ctx = ctx @opts = [] end |
Instance Attribute Details
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
5 6 7 |
# File 'lib/inkcite/view/tag_stack.rb', line 5 def tag @tag end |
Instance Method Details
#<<(opt) ⇒ Object Also known as: push
Pushes a new set of options onto the stack for this tag.
16 17 18 |
# File 'lib/inkcite/view/tag_stack.rb', line 16 def << opt @opts << opt end |
#opts ⇒ Object
Retrieves the most recent set of options for this tag.
22 23 24 |
# File 'lib/inkcite/view/tag_stack.rb', line 22 def opts @opts.last || {} end |
#pop ⇒ Object
Pops the most recent tag off of the stack.
27 28 29 30 31 32 33 34 |
# File 'lib/inkcite/view/tag_stack.rb', line 27 def pop if @opts.empty? @ctx.error 'Attempt to close an unopened tag', { :tag => tag } nil else @opts.pop end end |