Module: GraphImageDrawerModule
- Included in:
- GraphImageDrawerChunky, GraphImageDrawerRasem, GraphImageDrawerRmagick
- Defined in:
- lib/technical_graph/graph_image_drawer_module.rb
Instance Attribute Summary collapse
-
#drawer ⇒ Object
readonly
Returns the value of attribute drawer.
Instance Method Summary collapse
- #deflate_string(str, level = 9) ⇒ Object
- #format_from_filename(file) ⇒ Object
- #height ⇒ Object
- #initialize(drawer) ⇒ Object
- #logger ⇒ Object
- #options ⇒ Object
-
#random_filename ⇒ Object
Used for creating temp files.
-
#to_png ⇒ Object
Return binary PNG.
- #to_svg ⇒ Object
- #to_svgz ⇒ Object
- #truncate_string ⇒ Object
- #width ⇒ Object
-
#x_axis(x_array, options = { :color => 'black', :width => 1 }) ⇒ Object
Draw one or many axis.
-
#y_axis(y_array, options = { :color => 'black', :width => 1 }) ⇒ Object
Draw one or many axis.
Instance Attribute Details
#drawer ⇒ Object (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 |
#height ⇒ Object
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 |
#logger ⇒ Object
28 29 30 |
# File 'lib/technical_graph/graph_image_drawer_module.rb', line 28 def logger drawer.logger end |
#options ⇒ Object
24 25 26 |
# File 'lib/technical_graph/graph_image_drawer_module.rb', line 24 def drawer. end |
#random_filename ⇒ Object
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_png ⇒ Object
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_svg ⇒ Object
48 49 50 |
# File 'lib/technical_graph/graph_image_drawer_module.rb', line 48 def to_svg to_format('svg') end |
#to_svgz ⇒ Object
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_string ⇒ Object
20 21 22 |
# File 'lib/technical_graph/graph_image_drawer_module.rb', line 20 def truncate_string drawer.truncate_string end |
#width ⇒ Object
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, = { :color => 'black', :width => 1 }) axis(x_array, [], ) 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, = { :color => 'black', :width => 1 }) axis([], y_array, ) end |