Class: Korekto::Syntax

Inherits:
Object
  • Object
show all
Defined in:
lib/korekto/syntax.rb

Instance Method Summary collapse

Constructor Details

#initializeSyntax

Returns a new instance of Syntax.



3
# File 'lib/korekto/syntax.rb', line 3

def initialize = @a=[]

Instance Method Details

#eachObject



4
# File 'lib/korekto/syntax.rb', line 4

def each = @a.each{|s| yield s}

#push(s) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/korekto/syntax.rb', line 6

def push(s)
  # ensure it'll eval on string and returns boolean
  b = ''.instance_eval(s)
  raise Error, 'syntax rule must eval boolean' unless b==!!b
  @a.push(s)
rescue
  raise Error, "#{$!.class}: #{s}"
end