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