Method: Gruff::Base#initialize

Defined in:
lib/gruff/base.rb

#initialize(target_width = DEFAULT_TARGET_WIDTH) ⇒ Base

If one numerical argument is given, the graph is drawn at 4/3 ratio according to the given width (800 results in 800x600, 400 gives 400x300, etc.).

Or, send a geometry string for other ratios (‘800x400’, ‘400x225’).

Looks for Bitstream Vera as the default font. Expects an environment var of MAGICK_FONT_PATH to be set. (Uses RMagick’s default font otherwise.)



176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/gruff/base.rb', line 176

def initialize(target_width=DEFAULT_TARGET_WIDTH)
  @top_margin = @bottom_margin = @left_margin = @right_margin = 20.0

  if not Numeric === target_width
    geometric_width, geometric_height = target_width.split('x')
    @columns = geometric_width.to_f
    @rows = geometric_height.to_f
  else
    @columns = target_width.to_f
    @rows = target_width.to_f * 0.75
  end

  # Call any other initializers -- open-ended to allow for
  # subclass extensions
  self.class.instance_methods.
  select{|m| m.to_s =~ /^initialize_/o}.each do |initializer|
  self.send(initializer)
  end

  reset_themes
  theme_keynote
end