module GraphImageDrawerModule

encoding: utf-8

Attributes

drawer[R]

Public Class Methods

new(drawer) click to toggle source
# File lib/technical_graph/graph_image_drawer_module.rb, line 5
def initialize(drawer)
  @drawer = drawer
  create_blank_image
end

Public Instance Methods

deflate_string(str, level = 9) click to toggle source
# File lib/technical_graph/graph_image_drawer_module.rb, line 56
def deflate_string(str, level = 9)
  z = Zlib::Deflate.new(level)
  dst = z.deflate(str, Zlib::FINISH)
  z.close
  dst
end
format_from_filename(file) click to toggle source
# File lib/technical_graph/graph_image_drawer_module.rb, line 63
def format_from_filename(file)
  file.gsub(/^.*\./, '')
end
height() click to toggle source
# File lib/technical_graph/graph_image_drawer_module.rb, line 16
def height
  drawer.height
end
logger() click to toggle source
# File lib/technical_graph/graph_image_drawer_module.rb, line 28
def logger
  drawer.logger
end
options() click to toggle source
# File lib/technical_graph/graph_image_drawer_module.rb, line 24
def options
  drawer.options
end
random_filename() click to toggle source

Used for creating temp files

# File lib/technical_graph/graph_image_drawer_module.rb, line 68
def random_filename
  (0...16).map{65.+(rand(25)).chr}.join
end
to_png() click to toggle source

Return binary PNG

# File lib/technical_graph/graph_image_drawer_module.rb, line 44
def to_png
  to_format('png')
end
to_svg() click to toggle source
# File lib/technical_graph/graph_image_drawer_module.rb, line 48
def to_svg
  to_format('svg')
end
to_svgz() click to toggle source
# File lib/technical_graph/graph_image_drawer_module.rb, line 52
def to_svgz
  drawer.deflate_string( to_format('svg') )
end
truncate_string() click to toggle source
# File lib/technical_graph/graph_image_drawer_module.rb, line 20
def truncate_string
  drawer.truncate_string
end
width() click to toggle source
# File lib/technical_graph/graph_image_drawer_module.rb, line 12
def width
  drawer.width
end
x_axis(x_array, options = { :color => 'black', :width => 1 }) click to toggle source

Draw one or many axis

# File lib/technical_graph/graph_image_drawer_module.rb, line 34
def x_axis(x_array, options = { :color => 'black', :width => 1 })
  axis(x_array, [], options)
end
y_axis(y_array, options = { :color => 'black', :width => 1 }) click to toggle source

Draw one or many axis

# File lib/technical_graph/graph_image_drawer_module.rb, line 39
def y_axis(y_array, options = { :color => 'black', :width => 1 })
  axis([], y_array, options)
end