Class: Textpow::SyntaxProxy

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

Instance Method Summary collapse

Constructor Details

#initialize(hash, syntax) ⇒ SyntaxProxy

Returns a new instance of SyntaxProxy.



6
7
8
9
# File 'lib/textpow/syntax.rb', line 6

def initialize hash, syntax
   @syntax = syntax
   @proxy = hash["include"]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/textpow/syntax.rb', line 11

def method_missing method, *args, &block
   if @proxy 
      @proxy_value = proxy unless @proxy_value
      if @proxy_value
         @proxy_value.send(method, *args, &block)
      else
         STDERR.puts "Failed proxying #{@proxy}.#{method}(#{args.join(', ')})"
      end
   end
end

Instance Method Details

#proxyObject



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

def proxy
   case @proxy 
   when /^#/
      if @syntax.repository && @syntax.repository[@proxy[1..-1]]
         #puts "Repository"
         #@table["syntax"].repository.each_key{|k| puts k}
         return @syntax.repository[@proxy[1..-1]]
      end
   when "$self"
      return @syntax
   when "$base"
      return @syntax
   else
      return @syntax.syntaxes[@proxy]
   end
end