Class: CTioga2::Graphics::Elements::TiogaElement
- Inherits:
-
Object
- Object
- CTioga2::Graphics::Elements::TiogaElement
- Includes:
- Log
- Defined in:
- lib/ctioga2/graphics/elements/element.rb
Overview
The base class for every single object that is drawn on Tioga’s output.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#clipped ⇒ Object
Whether the object is clipped by default or not.
- #depth ⇒ Object
-
#location ⇒ Object
Makes sure there is a location when one asks for it.
-
#parent ⇒ Object
The parent Container.
Instance Method Summary collapse
-
#do(f) ⇒ Object
This function must be called with a FigureMaker object to draw the contents of the TiogaElement onto it.
-
#initialize ⇒ TiogaElement
constructor
A new instance of TiogaElement.
-
#inspect(prefix = "") ⇒ Object
We plot everything but parent.
Methods included from Log
context, debug, error, fatal, #format_exception, #identify, info, init_logger, log_to, logger, set_level, #spawn, warn
Constructor Details
#initialize ⇒ TiogaElement
Returns a new instance of TiogaElement.
46 47 48 49 50 51 52 |
# File 'lib/ctioga2/graphics/elements/element.rb', line 46 def initialize() @clipped = true @depth = 50 # Hey, like xfig @gp_cache = {} end |
Instance Attribute Details
#clipped ⇒ Object
Whether the object is clipped by default or not.
40 41 42 |
# File 'lib/ctioga2/graphics/elements/element.rb', line 40 def clipped @clipped end |
#depth ⇒ Object
54 55 56 |
# File 'lib/ctioga2/graphics/elements/element.rb', line 54 def depth @depth || 50 end |
#location ⇒ Object
Makes sure there is a location when one asks for it.
59 60 61 62 |
# File 'lib/ctioga2/graphics/elements/element.rb', line 59 def location @location ||= Styles::LocationStyle.new return @location end |
#parent ⇒ Object
The parent Container.
33 34 35 |
# File 'lib/ctioga2/graphics/elements/element.rb', line 33 def parent @parent end |
Instance Method Details
#do(f) ⇒ Object
This function must be called with a FigureMaker object to draw the contents of the TiogaElement onto it. It calls #real_do, which should be redefined by the children. You can redefine do too if you need another debugging output.
68 69 70 71 72 |
# File 'lib/ctioga2/graphics/elements/element.rb', line 68 def do(f) debug { "plotting #{self.inspect}" } @gp_cache = {} real_do(f) end |
#inspect(prefix = "") ⇒ Object
We plot everything but parent. If a prefix is given, it is prepended to all lines but the first (for indentation)
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/ctioga2/graphics/elements/element.rb', line 76 def inspect(prefix="") ret = "#<#{self.class.name}:\n" for i in instance_variables next if i == "@parent" var = instance_variable_get(i) ret += "#{prefix} - #{i} -> " if var.is_a? TiogaElement ret += "#{var.inspect("#{prefix} ")}\n" else ret += "#{var.inspect}\n" end end ret += "#{prefix}>" return ret end |