Class: PDF::Core::GraphicStateStack
- Inherits:
-
Object
- Object
- PDF::Core::GraphicStateStack
- Defined in:
- lib/pdf/core/graphics_state.rb
Overview
Graphics state saving and restoring
Instance Attribute Summary collapse
-
#stack ⇒ Object
Graphic state stack.
Instance Method Summary collapse
-
#current_state ⇒ GraphicState
Current graphic state.
-
#empty? ⇒ Boolean
Tells whether there are no saved graphic states.
-
#initialize(previous_state = nil) ⇒ GraphicStateStack
constructor
A new instance of GraphicStateStack.
-
#present? ⇒ Boolean
Tells whether there are any saved graphic states.
-
#restore_graphic_state ⇒ void
Restores previous graphic state.
-
#save_graphic_state(graphic_state = nil) ⇒ void
Pushes graphic state onto stack.
Constructor Details
#initialize(previous_state = nil) ⇒ GraphicStateStack
Returns a new instance of GraphicStateStack.
Source Code
lib/pdf/core/graphics_state.rb, line 11
11 | def initialize(previous_state = nil) |
12 | self.stack = [GraphicState.new(previous_state)] |
13 | end
|
Instance Attribute Details
#stack ⇒ Object
Graphic state stack
Source Code
lib/pdf/core/graphics_state.rb, line 8
8 | def stack |
9 | @stack
|
10 | end
|
Instance Method Details
#current_state ⇒ GraphicState
Current graphic state
Source Code
lib/pdf/core/graphics_state.rb, line 37
37 | def current_state |
38 | stack.last |
39 | end
|
#empty? ⇒ Boolean
Tells whether there are no saved graphic states
Source Code
lib/pdf/core/graphics_state.rb, line 53
53 | def empty? |
54 | stack.empty? |
55 | end
|
#present? ⇒ Boolean
Tells whether there are any saved graphic states
Source Code
lib/pdf/core/graphics_state.rb, line 45
45 | def present? |
46 | !stack.empty? |
47 | end
|
#restore_graphic_state ⇒ void
This method returns an undefined value.
Restores previous graphic state
Source Code
lib/pdf/core/graphics_state.rb, line 26
26 | def restore_graphic_state |
27 | if stack.empty? |
28 | raise PDF::Core::Errors::EmptyGraphicStateStack, |
29 | "\n You have reached the end of the graphic state stack" |
30 | end
|
31 | stack.pop |
32 | end
|
#save_graphic_state(graphic_state = nil) ⇒ void
This method returns an undefined value.
Pushes graphic state onto stack
Source Code
lib/pdf/core/graphics_state.rb, line 19
19 | def save_graphic_state(graphic_state = nil) |
20 | stack.push(GraphicState.new(graphic_state || current_state)) |
21 | end
|