Class: Ranicoma::Creator

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/ranicoma/creator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util

#element

Constructor Details

#initialize(seed, size) ⇒ Creator

Returns a new instance of Creator.



9
10
11
12
13
14
# File 'lib/ranicoma/creator.rb', line 9

def initialize( seed, size )
  @rng=Random.new(seed)
  @size=size
  @doc = REXML::Document.new
  @doc << REXML::XMLDecl.new('1.0', 'UTF-8')
end

Instance Attribute Details

#docObject (readonly)

Returns the value of attribute doc.



17
18
19
# File 'lib/ranicoma/creator.rb', line 17

def doc
  @doc
end

#rngObject (readonly)

Returns the value of attribute rng.



15
16
17
# File 'lib/ranicoma/creator.rb', line 15

def rng
  @rng
end

#sizeObject (readonly)

Returns the value of attribute size.



16
17
18
# File 'lib/ranicoma/creator.rb', line 16

def size
  @size
end

Instance Method Details

#createObject



19
20
21
22
23
24
25
26
# File 'lib/ranicoma/creator.rb', line 19

def create
  design = Design::Base.subclasses.sample( random:rng ).new(rng)
  doc << (
    element("svg", xmlns:"http://www.w3.org/2000/svg", height:"#{size}px", width:"#{size}px", viewBox:"0 0 1 1" ){
      design.create
    }
  )
end