Class: Aozora2Html::StyleStack
- Inherits:
-
Object
- Object
- Aozora2Html::StyleStack
- Defined in:
- lib/aozora2html/style_stack.rb
Overview
スタイルの状態管理用スタック
スタイルの入れ子を扱えるようにスタック構造になっている。各要素は‘[コマンド文字列, 閉じる際に使うHTML文字列]`という2要素の配列になっている。
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize ⇒ StyleStack
constructor
A new instance of StyleStack.
- #last ⇒ Object
- #last_command ⇒ Object
- #pop ⇒ Object
- #push(elem) ⇒ Object
Constructor Details
#initialize ⇒ StyleStack
Returns a new instance of StyleStack.
9 10 11 |
# File 'lib/aozora2html/style_stack.rb', line 9 def initialize @stack = [] end |
Instance Method Details
#empty? ⇒ Boolean
17 18 19 |
# File 'lib/aozora2html/style_stack.rb', line 17 def empty? @stack.empty? end |
#last ⇒ Object
25 26 27 |
# File 'lib/aozora2html/style_stack.rb', line 25 def last @stack.last end |
#last_command ⇒ Object
29 30 31 |
# File 'lib/aozora2html/style_stack.rb', line 29 def last_command @stack.last[0] end |
#pop ⇒ Object
21 22 23 |
# File 'lib/aozora2html/style_stack.rb', line 21 def pop @stack.pop end |
#push(elem) ⇒ Object
13 14 15 |
# File 'lib/aozora2html/style_stack.rb', line 13 def push(elem) @stack.push(elem) end |