Class: Ranicoma::Creator
- Inherits:
-
Object
- Object
- Ranicoma::Creator
- Includes:
- Util
- Defined in:
- lib/ranicoma/creator.rb
Instance Attribute Summary collapse
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
-
#rng ⇒ Object
readonly
Returns the value of attribute rng.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
- #create ⇒ Object
-
#initialize(seed, size) ⇒ Creator
constructor
A new instance of Creator.
Methods included from Util
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
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
17 18 19 |
# File 'lib/ranicoma/creator.rb', line 17 def doc @doc end |
#rng ⇒ Object (readonly)
Returns the value of attribute rng.
15 16 17 |
# File 'lib/ranicoma/creator.rb', line 15 def rng @rng end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
16 17 18 |
# File 'lib/ranicoma/creator.rb', line 16 def size @size end |
Instance Method Details
#create ⇒ Object
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 |