Class: ChartJS::SaveFile

Inherits:
Object
  • Object
show all
Defined in:
lib/chart_js/chart/file.rb,
lib/chart_js/chart/bar_chart/file.rb,
lib/chart_js/chart/line_chart/file.rb,
lib/chart_js/chart/radar_chart/file.rb

Instance Method Summary collapse

Constructor Details

#initialize(path, html: false) ⇒ SaveFile

Returns a new instance of SaveFile.



7
8
9
10
# File 'lib/chart_js/chart/file.rb', line 7

def initialize(path, html: false)
  path(path)
  @html = html if html
end

Instance Method Details

#path(value = nil) ⇒ Object



12
13
14
15
# File 'lib/chart_js/chart/file.rb', line 12

def path(value = nil)
  return @path if value.nil?
  @path = value
end

#save!(path: @path, html: @html) ⇒ Object



17
18
19
20
21
22
# File 'lib/chart_js/chart/file.rb', line 17

def save!(path: @path, html: @html)
  File.open(path, "w") do |file|
    file.write(html)
    file.close
  end
end