class DataPoint

Constants

CRITERIA
DEFAULT_SHAPE
OVERLAY

Public Class Methods

configure_shape_criteria(*matchers) click to toggle source
# File lib/SVG/Graph/DataPoint.rb, line 11
def DataPoint.configure_shape_criteria(*matchers)
  CRITERIA.push(*matchers)
end
new(x, y, line) click to toggle source
# File lib/SVG/Graph/DataPoint.rb, line 18
def initialize(x, y, line)
  @x = x
  @y = y
  @line = line
end
reset_shape_criteria() click to toggle source
# File lib/SVG/Graph/DataPoint.rb, line 14
def DataPoint.reset_shape_criteria
  CRITERIA.clear
end

Public Instance Methods

shape(description=nil) click to toggle source
# File lib/SVG/Graph/DataPoint.rb, line 23
def shape(description=nil)
  shapes = CRITERIA.select {|criteria|
    criteria.size == 2
  }.collect {|regexp, proc|
    proc.call(@x, @y, @line) if description =~ regexp
  }.compact
  shapes = [DEFAULT_SHAPE.call(@x, @y, @line)] if shapes.empty?

  overlays = CRITERIA.select { |criteria|
    criteria.last == OVERLAY
  }.collect { |regexp, proc|
    proc.call(@x, @y, @line) if description =~ regexp
  }.compact

  return shapes + overlays
end