Class: Dommy::TouchList
- Inherits:
-
Object
- Object
- Dommy::TouchList
- Includes:
- Enumerable
- Defined in:
- lib/dommy/event.rb
Overview
‘TouchList` — immutable, indexed collection of Touch points.
Instance Method Summary collapse
- #[](index) ⇒ Object
- #__js_call__(method, args) ⇒ Object
- #__js_get__(key) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(touches = []) ⇒ TouchList
constructor
A new instance of TouchList.
- #item(index) ⇒ Object
- #length ⇒ Object
Constructor Details
#initialize(touches = []) ⇒ TouchList
Returns a new instance of TouchList.
613 614 615 |
# File 'lib/dommy/event.rb', line 613 def initialize(touches = []) @touches = touches.to_a.freeze end |
Instance Method Details
#[](index) ⇒ Object
625 626 627 |
# File 'lib/dommy/event.rb', line 625 def [](index) item(index) end |
#__js_call__(method, args) ⇒ Object
643 644 645 646 647 648 |
# File 'lib/dommy/event.rb', line 643 def __js_call__(method, args) case method when "item" item(args[0]) end end |
#__js_get__(key) ⇒ Object
634 635 636 637 638 639 640 641 |
# File 'lib/dommy/event.rb', line 634 def __js_get__(key) case key when "length" length else item(key.to_i) if key.is_a?(Integer) || key.to_s.match?(/\A-?\d+\z/) end end |
#each(&block) ⇒ Object
629 630 631 632 |
# File 'lib/dommy/event.rb', line 629 def each(&block) @touches.each(&block) self end |
#item(index) ⇒ Object
621 622 623 |
# File 'lib/dommy/event.rb', line 621 def item(index) @touches[index.to_i] end |
#length ⇒ Object
617 618 619 |
# File 'lib/dommy/event.rb', line 617 def length @touches.length end |