Class: Aio::Base::Toolkit::Chain
- Inherits:
-
Object
- Object
- Aio::Base::Toolkit::Chain
- Defined in:
- lib/aio/base/toolkit/hash.rb
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#get_line ⇒ Object
获取一条链路.
-
#initialize ⇒ Chain
constructor
A new instance of Chain.
-
#split(key, num) ⇒ Object
分裂出多条key值数组.
Constructor Details
#initialize ⇒ Chain
Returns a new instance of Chain.
5 6 7 |
# File 'lib/aio/base/toolkit/hash.rb', line 5 def initialize @chain = [] end |
Instance Method Details
#empty? ⇒ Boolean
28 29 30 |
# File 'lib/aio/base/toolkit/hash.rb', line 28 def empty? @chain.empty? end |
#get_line ⇒ Object
获取一条链路
24 25 26 |
# File 'lib/aio/base/toolkit/hash.rb', line 24 def get_line @chain.pop end |
#split(key, num) ⇒ Object
分裂出多条key值数组
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/aio/base/toolkit/hash.rb', line 10 def split(key, num) if @chain.empty? num.times { @chain.push [key.to_s] } else last = @chain.pop tmp = ::Array.new(num) { last.clone << key } @chain.concat tmp @chain end end |