Class: Golden_Sections

Inherits:
Object
  • Object
show all
Defined in:
lib/project/handler.rb,
lib/project/constants.rb,
lib/project/goldensections.rb

Overview

Golden_Sections handler for common methods

Constant Summary collapse

CGPoint_proc =

CGPoint initializer

lambda {|options| CGPoint.new(options[:x], options[:y])}
CGSize_proc =

CGSize initializer

lambda {|options| CGSize.new(options[:width], options[:height])}
CGRect_proc =

CGRect initializer

lambda {|options| CGRect.new([options[:x], options[:y]], [options[:width], options[:height]])}
Version =

The version of golden-sections

'0.0.2'
Golden_Mean =

The all-important golden mean

1.6180339
CGPoint_relations =

Relations of CGPoint attributes

{:x => :y}
CGSize_relations =

Relations of CGSize attributes

{:width => :height}
CGRect_relations =

Relations of CGRect attributes

{:x => :y, :width => :height}

Class Method Summary collapse

Class Method Details

.handler(relations, options, &init) ⇒ Object

A common handler for golden_section methods

Parameters:

  • relations (Hash)

    the set of relations to use

  • options (Hash)

    the options passed by the user

  • init (Proc)

    the initialization method to call



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/project/handler.rb', line 9

def self.handler(relations, options, &init)
options[:exponent]||=1
  relations.each do |relation1, relation2|
if options[relation1]&&!options[relation2]
options[relation2]=options[relation1].golden_section(options[:exponent])
elsif options[relation2]&&!options[relation1]
options[relation1]=options[relation2].golden_section(options[:exponent])
end
end
init.call(options)
end