Class: Victor::Component

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Marshaling
Defined in:
lib/victor/component.rb

Instance Method Summary collapse

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

#bodyObject

Subclasses MUST implement this

Raises:

  • (NotImplementedError)


14
15
16
# File 'lib/victor/component.rb', line 14

def body
  raise(NotImplementedError, "#{self.class.name} must implement `body'")
end

#heightObject

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

#marshalingObject

Marshaling data



11
# File 'lib/victor/component.rb', line 11

def marshaling = i[width height x y svg merged_css]

#styleObject

Subclasses MAY override these methods, OR assign instance vars



30
# File 'lib/victor/component.rb', line 30

def style = @style ||= {}

#svgObject

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

#widthObject



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

#xObject



31
# File 'lib/victor/component.rb', line 31

def x = @x ||= 0

#yObject



32
# File 'lib/victor/component.rb', line 32

def y = @y ||= 0