File: blackmagic.rb

package info (click to toggle)
ruby-facets 2.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 9,824 kB
  • sloc: ruby: 25,483; xml: 90; makefile: 20
file content (103 lines) | stat: -rw-r--r-- 1,241 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# BALCK MAJIC


__END__


class Class

  # query langauge for the ruby object model

  def defn(name, &procedure)
    define_method(name, &procedure
  end

end

def Class(name, &initialize)
  const_set(name.capitalize, Class.new(&initialize))
end

 Class(HelloWorld) do%{
     attr(:msg).default("")
     defn(:sayit) {
       puts("Hello World")
     }
   }end




# WE PROGRAM BACKWARDS

1. class(name).method(name)




class ObjectX
  def initialize(a, h, &b)
    attributes = h
    elements = a
    body = b
  end

  def

  def +(x)
    case type, x.type
    when [:integer, :integer]
      ObjectX.new(:integer, elements[0] + x.elements[0])
    when [:string, :string]
      x.attributes
    when
  end

  def <<()

end

class NilClass

  def object(*a, &b)
    h = a.last.is_a?(Hash) ? a.pop : {}
    ObjectX.new(a, h, &b)
  end

  def array(*a)
    a
  end

  def hash(hash_or_array)
    case hash_or_array
    when Array
      Hash[*hash_or_array]
    when Hash
      hash_or_array.dup
    else

    end
  end

  def string(*a, &b)
    String.new(*a, &b)
  end



  def array1(*a, &b)
    Array.new(*a, &b)
  end

  def hash1(*a, &b)
    Hash.new(*a, &b)
  end

  def string1(*a, &b)
    String.new(*a, &b)
  end

end


array(1,2,3)