Class: RubyPost::BaseGraphData

Inherits:
BaseDrawCommand show all
Defined in:
lib/graph.rb

Overview

Base class for all graph data. There are some commands, such as autogrid that must be called after the data is entered with gdraw. There are others that must be set before the call, such as setcoords. These macro ensure that order is maintained

Direct Known Subclasses

GraphFile

Instance Attribute Summary

Attributes inherited from BaseDrawCommand

#drawable

Instance Method Summary collapse

Methods inherited from BaseDrawCommand

#add_option, #color, #colour, #compile_options, #rotate, #scale, #set_drawable, #translate

Methods inherited from Object

#compile

Constructor Details

#initializeBaseGraphData

Returns a new instance of BaseGraphData.



60
61
62
63
64
# File 'lib/graph.rb', line 60

def initialize
  super()
  @pre_commands = Array.new
  @post_commands = Array.new
end

Instance Method Details

#add_coords(coords) ⇒ Object



90
91
92
# File 'lib/graph.rb', line 90

def add_coords(coords)
  add_pre_command(coords)
end

#add_grid(grid) ⇒ Object

add a grid to the graph. This is always done as a post command in metapost



82
83
84
# File 'lib/graph.rb', line 82

def add_grid(grid)
  add_post_command(grid)
end

#add_label(coords) ⇒ Object

add a label to this graph data



95
96
97
# File 'lib/graph.rb', line 95

def add_label(coords)
  add_post_command(coords)
end

#add_post_command(c) ⇒ Object



70
71
72
# File 'lib/graph.rb', line 70

def add_post_command(c)
  @post_commands.push(c)
end

#add_pre_command(c) ⇒ Object



66
67
68
# File 'lib/graph.rb', line 66

def add_pre_command(c)
  @pre_commands.push(c)
end

#add_range(range) ⇒ Object



86
87
88
# File 'lib/graph.rb', line 86

def add_range(range)
  add_pre_command(range)
end

#compile_post_commandsObject



99
100
101
102
103
# File 'lib/graph.rb', line 99

def compile_post_commands
  str = String.new
  @post_commands.each { |c| str = str + c.compile }
  return str
end

#compile_pre_commandsObject



74
75
76
77
78
# File 'lib/graph.rb', line 74

def compile_pre_commands
  str = String.new
  @pre_commands.each { |c| str = str + c.compile }
  return str
end