class CTioga2::MetaBuilder::Types::MarginsType

A class that produces a Graphics::Types::MarginsBox. It takes one optional argument : a :default (:frame, :figure or :page), see Graphics::Types::Dimensions::from_text for more information.

Public Instance Methods

string_to_type_internal(str) click to toggle source
# File lib/ctioga2/metabuilder/types/coordinates.rb, line 47
def string_to_type_internal(str)
  default = @type[:default] || :frame
  specs = str.split(/\s*,\s*/)
  if specs.size == 1
    specs = specs * 4
  elsif specs.size == 2
    specs = [specs[0], specs[0], specs[1], specs[1]]
  end
  if specs.size != 4
    raise IncorrectInput, "You need either 1, 2 or 4 elements to make up a margin specification"
  end
  return Graphics::Types::MarginsBox.new(*specs.map {|x|
                                           Graphics::Types::Dimension::from_text(x, :x, default )})
end