Module: SVGPlot::Expansion

Included in:
Tag
Defined in:
lib/svgplot/meta.rb

Overview

Define processing for Expansion constants

Instance Method Summary collapse

Instance Method Details

#expand(tag, args) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/svgplot/meta.rb', line 46

def expand(tag, args)
  expansion = SVG_EXPANSION[tag.to_sym]
  fail("Unnamed parameters for #{tag} are not allowed!") unless expansion

  if expansion.is_a? Array
    parse_args(tag, expansion, args)
  elsif expansion.is_a? Proc
    expansion.call(args)
  else
    fail "Unexpected expansion mechanism: #{expansion.class}"
  end
end