Class: Braingasm::PrefixStack
- Inherits:
-
Object
- Object
- Braingasm::PrefixStack
- Extended by:
- Forwardable
- Defined in:
- lib/braingasm/prefixes.rb
Instance Attribute Summary collapse
-
#stack ⇒ Object
Returns the value of attribute stack.
Instance Method Summary collapse
- #fix_params(function, default_param = 1) ⇒ Object
-
#initialize ⇒ PrefixStack
constructor
A new instance of PrefixStack.
Constructor Details
#initialize ⇒ PrefixStack
Returns a new instance of PrefixStack.
10 11 12 |
# File 'lib/braingasm/prefixes.rb', line 10 def initialize @stack = [] end |
Instance Attribute Details
#stack ⇒ Object
Returns the value of attribute stack.
7 8 9 |
# File 'lib/braingasm/prefixes.rb', line 7 def stack @stack end |
Instance Method Details
#fix_params(function, default_param = 1) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/braingasm/prefixes.rb', line 14 def fix_params(function, default_param=1) prefix = @stack.pop || default_param case prefix when Integer, String function.curry.call(prefix) when Proc proc do |m| n = prefix.call(m) function.call(n, m) end end end |