Class: Cheep

Inherits:
BlankSlate
  • Object
show all
Defined in:
lib/cheep.rb

Defined Under Namespace

Classes: Connector, Object

Constant Summary collapse

@@objects =
[]

Class Method Summary collapse

Class Method Details

.[](name, *args) ⇒ Object



12
13
14
15
16
17
# File 'lib/cheep.rb', line 12

def self.[](name, *args)
  name = name.to_sym
  object = Cheep::Object.new name, @@objects.size, *args
  @@objects << object
  object
end

.method_missing(name, *args) ⇒ Object



8
9
10
# File 'lib/cheep.rb', line 8

def self.method_missing(name, *args)
  self[name, *args]
end

.to_patchObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/cheep.rb', line 23

def self.to_patch
  patch = ['#N canvas 400 400 400 400 10;']

  # Objects
  # i.e. #X obj 97 131 print;
  objects.each do |obj|
    patch << obj.to_patch.values.first
  end

  # Connections
  # i.e. #X connect 1 0 1 0;
  patch << Connector.new(objects).resolve_connections

  patch.flatten.join "\n"
end