Class: Prawn::GraphicStateStack
- Inherits:
-
Object
- Object
- Prawn::GraphicStateStack
- Defined in:
- lib/prawn/document/graphics_state.rb
Instance Attribute Summary (collapse)
-
- (Object) stack
Returns the value of attribute stack.
Instance Method Summary (collapse)
- - (Object) current_state
- - (Boolean) empty?
-
- (GraphicStateStack) initialize(previous_state = nil)
constructor
A new instance of GraphicStateStack.
- - (Boolean) present?
- - (Object) restore_graphic_state
- - (Object) save_graphic_state(graphic_state = nil)
Constructor Details
- (GraphicStateStack) initialize(previous_state = nil)
A new instance of GraphicStateStack
14 15 16 |
# File 'lib/prawn/document/graphics_state.rb', line 14 def initialize(previous_state = nil) self.stack = [GraphicState.new(previous_state)] end |
Instance Attribute Details
- (Object) stack
Returns the value of attribute stack
12 13 14 |
# File 'lib/prawn/document/graphics_state.rb', line 12 def stack @stack end |
Instance Method Details
- (Object) current_state
30 31 32 |
# File 'lib/prawn/document/graphics_state.rb', line 30 def current_state stack.last end |
- (Boolean) empty?
38 39 40 |
# File 'lib/prawn/document/graphics_state.rb', line 38 def empty? stack.empty? end |
- (Boolean) present?
34 35 36 |
# File 'lib/prawn/document/graphics_state.rb', line 34 def present? stack.size > 0 end |
- (Object) restore_graphic_state
22 23 24 25 26 27 28 |
# File 'lib/prawn/document/graphics_state.rb', line 22 def restore_graphic_state if stack.empty? raise Prawn::Errors::EmptyGraphicStateStack, "\n You have reached the end of the graphic state stack" end stack.pop end |
- (Object) save_graphic_state(graphic_state = nil)
18 19 20 |
# File 'lib/prawn/document/graphics_state.rb', line 18 def save_graphic_state(graphic_state = nil) stack.push(GraphicState.new(graphic_state || current_state)) end |