Class: Tb::Func::LastN
- Inherits:
-
Object
- Object
- Tb::Func::LastN
- Defined in:
- lib/tb/func.rb
Instance Method Summary collapse
- #aggregate(ary) ⇒ Object
- #call(a1, a2) ⇒ Object
-
#initialize(n) ⇒ LastN
constructor
A new instance of LastN.
- #start(value) ⇒ Object
Constructor Details
#initialize(n) ⇒ LastN
Returns a new instance of LastN.
127 |
# File 'lib/tb/func.rb', line 127 def initialize(n) @n = n end |
Instance Method Details
#aggregate(ary) ⇒ Object
130 |
# File 'lib/tb/func.rb', line 130 def aggregate(ary) ary end |
#call(a1, a2) ⇒ Object
129 |
# File 'lib/tb/func.rb', line 129 def call(a1, a2) a2.length == @n ? a2 : (a1+a2).last(@n) end |
#start(value) ⇒ Object
128 |
# File 'lib/tb/func.rb', line 128 def start(value) [value] end |