Class: Trackplot::Component

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
lib/trackplot/component.rb

Instance Method Summary collapse

Constructor Details

#initialize(data:, **options, &block) ⇒ Component

Returns a new instance of Component.



10
11
12
13
# File 'lib/trackplot/component.rb', line 10

def initialize(data:, **options, &block)
  @builder = ChartBuilder.new(data, **options)
  @block = block
end

Instance Method Details

#callObject



15
16
17
18
# File 'lib/trackplot/component.rb', line 15

def call
  @block&.call(@builder)
  @builder.render(self)
end