module Seahorse::Model::Shapes

Public Class Methods

register(type, shape_class) click to toggle source

Registers a shape by type.

Shapes.register('structure', Shapes::StructureShape)

Shapes.type('structure')
#=> #<Shapes::StructureShape>

@param [String] type @param [Class<Shape>] ::shape_class @return [void] @raise [ArgumentError] Raises an error if the given type or

shape class have already been registered.
# File lib/seahorse/model/shapes.rb, line 23
def register(type, shape_class)
  shape_class.type = type
  @types[type] = shape_class
end
shape_class(type) click to toggle source

Given a type, this method returned the registered shape class. @param [String] type @return [Class<Shape>] @raise [ArgumentError] Raises an ArgumentError if there is no

shape class registered with the given %xtype`.
# File lib/seahorse/model/shapes.rb, line 33
def shape_class(type)
  if @types.key?(type)
    @types[type]
  else
    raise ArgumentError, "unregisterd type `#{type}'"
  end
end
types() click to toggle source

Returns an enumerator that yields registered type names and shape classes.

Seahorse::Model::Shapes.types.each do |type, shape_class|
  puts "%s => %s" % [type, shape_class.name]
end

@return [Enumerator] Returns an enumerable object that yields

registered type names and shape classes.
# File lib/seahorse/model/shapes.rb, line 50
def types
  Enumerator.new do |y|
    @types.each do |name, shape_class|
      y.yield(name, shape_class)
    end
  end
end