Class: ChartBibz::ViewComponents::CanvasViewComponent

Inherits:
ApplicationViewComponent show all
Defined in:
lib/chart_bibz/view_components/canvas_view_component.rb

Overview

Generate the canvas view through the render method

Constant Summary collapse

WIDTH =

Constants

400
HEIGHT =
400

Instance Attribute Summary

Attributes inherited from ApplicationViewComponent

#output_buffer

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ void

Parameters:

  • args (Hash) (defaults to: {})

    The html options



13
14
15
# File 'lib/chart_bibz/view_components/canvas_view_component.rb', line 13

def initialize(args = {})
  @args = args
end

Instance Method Details

#idString

Returns The canvas html id.

Returns:

  • (String)

    The canvas html id



24
25
26
# File 'lib/chart_bibz/view_components/canvas_view_component.rb', line 24

def id
  html_options[:id]
end

#renderString

Generate the html canvas

Returns:

  • (String)

    The html canvas



19
20
21
# File 'lib/chart_bibz/view_components/canvas_view_component.rb', line 19

def render
  tag.canvas(**html_options)
end