Class: Bio::Graphics::Primitive

Inherits:
Object
  • Object
show all
Defined in:
lib/bio/graphics/primitive.rb

Overview

The Bio::Graphics::Primitive class is used to describe simple shapes. It is basically a simple data container that has lots of dynamically set instance variables including a name. The Bio::Graphics::Primitive object is later translated to an SVG string by the Bio::Graphics::SVGEE class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(primitive, args) ⇒ Primitive

Creates a new Primitive and initialises instance variables dynamically from the args hash

args+

  • :primitive = the Primitive type

  • args = a hash of parameters needed to describe the attributes of the primitive type



15
16
17
18
19
20
# File 'lib/bio/graphics/primitive.rb', line 15

def initialize(primitive,args)
  @primitive = primitive
  args.each_key do |k|
    self.instance_variable_set("@#{k}", args[k])
  end 
end

Instance Attribute Details

#primitiveObject (readonly)

Returns the value of attribute primitive.



8
9
10
# File 'lib/bio/graphics/primitive.rb', line 8

def primitive
  @primitive
end

Instance Method Details

#update(args) ⇒ Object

Updates a Primitive and sets the provided values as instance variables

args

  • args = a hash of new parameters for the given primitive type



26
27
28
29
30
# File 'lib/bio/graphics/primitive.rb', line 26

def update(args)
  args.each_key do |k|
    self.instance_variable_set("@#{k}", args[k])
  end
end