Class: IndexPath
Overview
This class is used in switch statements. Easy pattern matching, so instead
of if index_path.row...index_path.section, you can use
when IndexPath[row, section]
Class Method Summary collapse
Instance Method Summary collapse
- #===(other) ⇒ Object
-
#initialize(values) ⇒ IndexPath
constructor
A new instance of IndexPath.
Constructor Details
#initialize(values) ⇒ IndexPath
Returns a new instance of IndexPath.
29 30 31 |
# File 'lib/sugarcube/nsindexpath.rb', line 29 def initialize values @values = values end |
Class Method Details
.[](*values) ⇒ Object
25 26 27 |
# File 'lib/sugarcube/nsindexpath.rb', line 25 def self.[] *values IndexPath.new values end |
Instance Method Details
#===(other) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/sugarcube/nsindexpath.rb', line 33 def === other return true if super if other.is_a? NSIndexPath other = other.to_a end if other.is_a? Enumerable ret = true other_i = 0 @values.each do |val| next_val = other[other_i] other_i += 1 unless val == true || val === next_val ret = false break end end return ret end return false end |