Class: Sexp

Inherits:
Array show all
Defined in:
lib/wrong/chunk.rb

Overview

todo: move to separate monkey patch file

Instance Method Summary collapse

Instance Method Details

#assertionObject



127
128
129
130
131
132
133
134
135
136
# File 'lib/wrong/chunk.rb', line 127

def assertion
  sexp = self
  assertion = if sexp.assertion?
                sexp
              else
                # todo: extract into sexp
                nested_assertions.first
              end
  assertion
end

#assertion?Boolean

Returns:

  • (Boolean)


119
120
121
122
123
124
125
# File 'lib/wrong/chunk.rb', line 119

def assertion?
  self.is_a? Sexp and
    self[0] == :iter and
    self[1].is_a? Sexp and
    self[1][0] == :call and
    [:assert, :deny].include? self[1][2] # todo: allow aliases for assert (e.g. "is")
end

#doopObject



109
110
111
# File 'lib/wrong/chunk.rb', line 109

def doop
  Marshal.load(Marshal.dump(self))
end

#to_rubyObject



113
114
115
116
117
# File 'lib/wrong/chunk.rb', line 113

def to_ruby
  d = self.doop
  x = Ruby2Ruby.new.process(d)
  x
end