Module: Trxl::FormalParameterList2
- Defined in:
- lib/trxl/trxl_grammar.rb
Instance Method Summary collapse
- #bind(args, env = Environment.new) ⇒ Object
- #length ⇒ Object
- #to_s(env = Environment.new) ⇒ Object
- #variables ⇒ Object
Instance Method Details
#bind(args, env = Environment.new) ⇒ Object
1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 |
# File 'lib/trxl/trxl_grammar.rb', line 1695 def bind(args, env = Environment.new) if (a = args.length) < (f = variables.length) raise WrongNumberOfArgumentsException, "#{a} instead of #{f}" end env.merge!(variables.zip(args).inject({}) do |bindings, param| bindings.merge(param.first.name => param.last) end) # store arguments array in scope, javascript like env.merge!(:arguments => args) end |
#length ⇒ Object
1710 1711 1712 |
# File 'lib/trxl/trxl_grammar.rb', line 1710 def length variables.length end |
#to_s(env = Environment.new) ⇒ Object
1714 1715 1716 |
# File 'lib/trxl/trxl_grammar.rb', line 1714 def to_s(env = Environment.new) "(#{variables.map { |var| var.text_value }.join(',')})" end |
#variables ⇒ Object
1706 1707 1708 |
# File 'lib/trxl/trxl_grammar.rb', line 1706 def variables [variable] + more_variables.elements.map { |e| e.variable } end |