Module: GraphImageDrawerModule

Included in:
GraphImageDrawerChunky, GraphImageDrawerRasem, GraphImageDrawerRmagick
Defined in:
lib/technical_graph/graph_image_drawer_module.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#drawerObject (readonly)

Returns the value of attribute drawer.



10
11
12
# File 'lib/technical_graph/graph_image_drawer_module.rb', line 10

def drawer
  @drawer
end

Instance Method Details

#deflate_string(str, level = 9) ⇒ Object



56
57
58
59
60
61
# 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) ⇒ Object



63
64
65
# File 'lib/technical_graph/graph_image_drawer_module.rb', line 63

def format_from_filename(file)
  file.gsub(/^.*\./, '')
end

#heightObject



16
17
18
# File 'lib/technical_graph/graph_image_drawer_module.rb', line 16

def height
  drawer.height
end

#initialize(drawer) ⇒ Object



5
6
7
8
# File 'lib/technical_graph/graph_image_drawer_module.rb', line 5

def initialize(drawer)
  @drawer = drawer
  create_blank_image
end

#loggerObject



28
29
30
# File 'lib/technical_graph/graph_image_drawer_module.rb', line 28

def logger
  drawer.logger
end

#optionsObject



24
25
26
# File 'lib/technical_graph/graph_image_drawer_module.rb', line 24

def options
  drawer.options
end

#random_filenameObject

Used for creating temp files



68
69
70
# File 'lib/technical_graph/graph_image_drawer_module.rb', line 68

def random_filename
  (0...16).map{65.+(rand(25)).chr}.join
end

#to_pngObject

Return binary PNG



44
45
46
# File 'lib/technical_graph/graph_image_drawer_module.rb', line 44

def to_png
  to_format('png')
end

#to_svgObject



48
49
50
# File 'lib/technical_graph/graph_image_drawer_module.rb', line 48

def to_svg
  to_format('svg')
end

#to_svgzObject



52
53
54
# File 'lib/technical_graph/graph_image_drawer_module.rb', line 52

def to_svgz
  drawer.deflate_string( to_format('svg') )
end

#truncate_stringObject



20
21
22
# File 'lib/technical_graph/graph_image_drawer_module.rb', line 20

def truncate_string
  drawer.truncate_string
end

#widthObject



12
13
14
# 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 }) ⇒ Object

Draw one or many axis



34
35
36
# 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 }) ⇒ Object

Draw one or many axis



39
40
41
# 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