Class: PDF::Core::GraphicStateStack
- Inherits:
-
Object
- Object
- PDF::Core::GraphicStateStack
- Defined in:
- lib/pdf/core/graphics_state.rb
Instance Attribute Summary collapse
-
#stack ⇒ Object
Returns the value of attribute stack.
Instance Method Summary collapse
- #current_state ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(previous_state = nil) ⇒ GraphicStateStack
constructor
A new instance of GraphicStateStack.
- #present? ⇒ Boolean
- #restore_graphic_state ⇒ Object
- #save_graphic_state(graphic_state = nil) ⇒ Object
Constructor Details
#initialize(previous_state = nil) ⇒ GraphicStateStack
Returns a new instance of GraphicStateStack.
15 16 17 |
# File 'lib/pdf/core/graphics_state.rb', line 15 def initialize(previous_state = nil) self.stack = [GraphicState.new(previous_state)] end |
Instance Attribute Details
#stack ⇒ Object
Returns the value of attribute stack.
13 14 15 |
# File 'lib/pdf/core/graphics_state.rb', line 13 def stack @stack end |
Instance Method Details
#current_state ⇒ Object
31 32 33 |
# File 'lib/pdf/core/graphics_state.rb', line 31 def current_state stack.last end |
#empty? ⇒ Boolean
39 40 41 |
# File 'lib/pdf/core/graphics_state.rb', line 39 def empty? stack.empty? end |
#present? ⇒ Boolean
35 36 37 |
# File 'lib/pdf/core/graphics_state.rb', line 35 def present? !stack.empty? end |
#restore_graphic_state ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/pdf/core/graphics_state.rb', line 23 def restore_graphic_state if stack.empty? raise PDF::Core::Errors::EmptyGraphicStateStack, "\n You have reached the end of the graphic state stack" end stack.pop end |
#save_graphic_state(graphic_state = nil) ⇒ Object
19 20 21 |
# File 'lib/pdf/core/graphics_state.rb', line 19 def save_graphic_state(graphic_state = nil) stack.push(GraphicState.new(graphic_state || current_state)) end |