Class: Inkcite::View::TagStack

Inherits:
Object
  • Object
show all
Defined in:
lib/inkcite/view/tag_stack.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#tagObject (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

#optsObject

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

#popObject

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