Class: MarkdownExec::LinkHistory
Instance Method Summary collapse
-
#initialize ⇒ LinkHistory
constructor
A new instance of LinkHistory.
-
#peek ⇒ Object
Peeks at the most recent LinkState, returns an empty LinkState if stack is empty.
-
#pop ⇒ Object
Pops the most recent LinkState off the stack, returns an empty LinkState if stack is empty.
- #prior_state_exist? ⇒ Boolean
-
#push(link_state) ⇒ Object
Pushes a LinkState onto the stack.
Constructor Details
#initialize ⇒ LinkHistory
Returns a new instance of LinkHistory.
51 52 53 |
# File 'lib/link_history.rb', line 51 def initialize @history = [] end |
Instance Method Details
#peek ⇒ Object
Peeks at the most recent LinkState, returns an empty LinkState if stack is empty.
56 57 58 |
# File 'lib/link_history.rb', line 56 def peek @history.last || LinkState.empty end |
#pop ⇒ Object
Pops the most recent LinkState off the stack, returns an empty LinkState if stack is empty.
61 62 63 |
# File 'lib/link_history.rb', line 61 def pop @history.pop || LinkState.empty end |
#prior_state_exist? ⇒ Boolean
65 66 67 |
# File 'lib/link_history.rb', line 65 def prior_state_exist? peek.document_filename.present? end |
#push(link_state) ⇒ Object
Pushes a LinkState onto the stack.
70 71 72 |
# File 'lib/link_history.rb', line 70 def push(link_state) @history.push(link_state) end |