Class: Textpow::SyntaxProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/ultra_pow_list/vendor/ruby1.8/textpow/textpow/syntax.rb,
lib/ultra_pow_list/vendor/ruby1.9/textpow/textpow/syntax.rb

Instance Method Summary collapse

Constructor Details

#initialize(hash, syntax) ⇒ SyntaxProxy

Returns a new instance of SyntaxProxy.



4
5
6
7
# File 'lib/ultra_pow_list/vendor/ruby1.8/textpow/textpow/syntax.rb', line 4

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



9
10
11
12
13
14
15
16
17
18
# File 'lib/ultra_pow_list/vendor/ruby1.8/textpow/textpow/syntax.rb', line 9

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



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ultra_pow_list/vendor/ruby1.8/textpow/textpow/syntax.rb', line 20

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