Class: Victor::Component
- Inherits:
-
Object
- Object
- Victor::Component
- Extended by:
- Forwardable
- Includes:
- Marshaling
- Defined in:
- lib/victor/component.rb
Instance Method Summary collapse
-
#append(component) ⇒ Object
(also: #embed)
Appending/Embedding - DSL for the ‘#body` implementation.
-
#body ⇒ Object
Subclasses MUST implement this.
-
#height ⇒ Object
Subclasses MUST override these methods, OR assign instance vars.
-
#marshaling ⇒ Object
Marshaling data.
-
#style ⇒ Object
Subclasses MAY override these methods, OR assign instance vars.
-
#svg ⇒ Object
SVG / CSS.
- #width ⇒ Object
- #x ⇒ Object
- #y ⇒ Object
Methods included from Marshaling
#encode_with, #init_with, #marshal_dump, #marshal_load
Instance Method Details
#append(component) ⇒ Object Also known as: embed
Appending/Embedding - DSL for the ‘#body` implementation
35 36 37 38 |
# File 'lib/victor/component.rb', line 35 def append(component) svg_instance.append component.svg merged_css.merge! component.merged_css end |
#body ⇒ Object
Subclasses MUST implement this
14 15 16 |
# File 'lib/victor/component.rb', line 14 def body raise(NotImplementedError, "#{self.class.name} must implement `body'") end |
#height ⇒ Object
Subclasses MUST override these methods, OR assign instance vars
19 20 21 22 |
# File 'lib/victor/component.rb', line 19 def height @height || raise(NotImplementedError, "#{self.class.name} must implement `height' or `@height'") end |
#marshaling ⇒ Object
Marshaling data
11 |
# File 'lib/victor/component.rb', line 11 def marshaling = i[width height x y svg merged_css] |
#style ⇒ Object
Subclasses MAY override these methods, OR assign instance vars
30 |
# File 'lib/victor/component.rb', line 30 def style = @style ||= {} |
#svg ⇒ Object
SVG / CSS
42 43 44 45 46 47 48 |
# File 'lib/victor/component.rb', line 42 def svg @svg ||= begin body svg_instance.css = merged_css svg_instance end end |
#width ⇒ Object
24 25 26 27 |
# File 'lib/victor/component.rb', line 24 def width @width || raise(NotImplementedError, "#{self.class.name} must implement `width' or `@width'") end |
#x ⇒ Object
31 |
# File 'lib/victor/component.rb', line 31 def x = @x ||= 0 |
#y ⇒ Object
32 |
# File 'lib/victor/component.rb', line 32 def y = @y ||= 0 |