Class: Kamelopard::NumberList
- Inherits:
-
Object
- Object
- Kamelopard::NumberList
- Defined in:
- lib/kamelopard/pointlist.rb
Instance Method Summary collapse
- #<<(a) ⇒ Object
- #[](i) ⇒ Object
- #each(&blk) ⇒ Object
-
#initialize(init = []) ⇒ NumberList
constructor
Contains a list of numbers.
- #last ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(init = []) ⇒ NumberList
Contains a list of numbers
15 16 17 18 |
# File 'lib/kamelopard/pointlist.rb', line 15 def initialize(init = []) raise "Constructor argument needs to be an array" unless init.kind_of? Array @points = init end |
Instance Method Details
#<<(a) ⇒ Object
24 25 26 |
# File 'lib/kamelopard/pointlist.rb', line 24 def <<(a) @points << a end |
#[](i) ⇒ Object
32 33 34 |
# File 'lib/kamelopard/pointlist.rb', line 32 def [](i) @points[i] end |
#each(&blk) ⇒ Object
36 37 38 |
# File 'lib/kamelopard/pointlist.rb', line 36 def each(&blk) @points.each(&blk) end |
#last ⇒ Object
28 29 30 |
# File 'lib/kamelopard/pointlist.rb', line 28 def last @points.last end |
#size ⇒ Object
20 21 22 |
# File 'lib/kamelopard/pointlist.rb', line 20 def size return @points.size end |