Class: LEAP::Motion::Utils::History
- Inherits:
-
Array
- Object
- Array
- LEAP::Motion::Utils::History
- Defined in:
- lib/leap/motion/utils/history.rb
Instance Attribute Summary collapse
-
#max_size ⇒ Object
readonly
Returns the value of attribute max_size.
Instance Method Summary collapse
- #<<(el) ⇒ Object (also: #push)
-
#initialize(max_size, enum = nil) ⇒ History
constructor
A new instance of History.
Constructor Details
#initialize(max_size, enum = nil) ⇒ History
Returns a new instance of History.
7 8 9 10 |
# File 'lib/leap/motion/utils/history.rb', line 7 def initialize(max_size, enum = nil) @max_size = max_size enum.each { |e| self << e } if enum end |
Instance Attribute Details
#max_size ⇒ Object (readonly)
Returns the value of attribute max_size.
5 6 7 |
# File 'lib/leap/motion/utils/history.rb', line 5 def max_size @max_size end |
Instance Method Details
#<<(el) ⇒ Object Also known as: push
12 13 14 15 16 17 18 19 |
# File 'lib/leap/motion/utils/history.rb', line 12 def <<(el) if self.size < @max_size || @max_size.nil? super else self.shift self.push(el) end end |