Class: CTioga::TiogaElement
- Inherits:
-
Object
- Object
- CTioga::TiogaElement
- Defined in:
- lib/CTioga/elements/base.rb
Overview
The base class for every single object that has to appear at one point as a command in the tioga plot. It provides only one function: do(f), which will be used by subclasses to do what they need.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#parent ⇒ Object
The parent element.
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.
-
#inspect(prefix = "") ⇒ Object
We plot everything but parent.
-
#need_style? ⇒ Boolean
this function returns true if the object needs a CurveStyle parameter.
Methods included from Log
#identify, #init_logger, #logger, #logger_options, #spawn
Methods included from Debug
#debug_figmaker, #debug_patterns, #debug_puts, #figmaker_options, #test_pattern, #test_pattern_right
Instance Attribute Details
#parent ⇒ Object
The parent element.
31 32 33 |
# File 'lib/CTioga/elements/base.rb', line 31 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 the function real_do, which should be redefined by the children. You can redefine do too if you need another debugging output.
38 39 40 41 |
# File 'lib/CTioga/elements/base.rb', line 38 def do(f) debug "plotting #{self.inspect}" 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)
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/CTioga/elements/base.rb', line 50 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 |
#need_style? ⇒ Boolean
this function returns true if the object needs a CurveStyle parameter.
44 45 46 |
# File 'lib/CTioga/elements/base.rb', line 44 def need_style? return false end |