sugarcube 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +16 -0
- data/lib/sugarcube/array.rb +0 -8
- data/lib/sugarcube/nsindexpath.rb +23 -4
- data/lib/sugarcube/to_s/uiview.rb +1 -1
- data/lib/sugarcube/version.rb +1 -1
- metadata +16 -6
data/README.md
CHANGED
@@ -122,6 +122,22 @@ end
|
|
122
122
|
|
123
123
|
# NSURL
|
124
124
|
"https://github.com".nsurl # => NSURL.URLWithString("https://github.com")
|
125
|
+
```
|
126
|
+
|
127
|
+
NSIndexPath
|
128
|
+
-------------
|
129
|
+
|
130
|
+
Use the `IndexPath` class to match `NSIndexPath` objects, for instance in a
|
131
|
+
`UITableViewDelegate`.
|
132
|
+
|
133
|
+
```ruby
|
134
|
+
index_path = [0, 2].nsindexpath
|
135
|
+
case index_path
|
136
|
+
when IndexPath[0]
|
137
|
+
when IndexPath[1, 0..5]
|
138
|
+
when IndexPath[1, 5..objects.length]
|
139
|
+
end
|
140
|
+
[0, 2].nsindexpath.to_a == [0, 2] # => true
|
125
141
|
```
|
126
142
|
|
127
143
|
Symbol
|
data/lib/sugarcube/array.rb
CHANGED
@@ -1,13 +1,5 @@
|
|
1
1
|
class Array
|
2
2
|
|
3
|
-
def === other
|
4
|
-
return other === self if other.is_a? NSIndexPath
|
5
|
-
ret = super
|
6
|
-
puts("=============== array.rb at line 6 ===============
|
7
|
-
returning super: #{ret.inspect}")
|
8
|
-
ret
|
9
|
-
end
|
10
|
-
|
11
3
|
def to_pointer(type)
|
12
4
|
ret = Pointer.new(type, self.length)
|
13
5
|
self.each_index do |i|
|
@@ -8,15 +8,33 @@ class NSIndexPath
|
|
8
8
|
end
|
9
9
|
a
|
10
10
|
end
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
class IndexPath
|
15
|
+
|
16
|
+
def self.[] *values
|
17
|
+
IndexPath.new values
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize values
|
21
|
+
@values = values
|
22
|
+
end
|
11
23
|
|
12
24
|
def === other
|
13
25
|
return true if super
|
14
26
|
|
27
|
+
if other.is_a? NSIndexPath
|
28
|
+
other = other.to_a
|
29
|
+
end
|
30
|
+
|
15
31
|
if other.is_a? Enumerable
|
16
32
|
ret = true
|
17
|
-
|
18
|
-
|
19
|
-
|
33
|
+
other_i = 0
|
34
|
+
@values.each do |val|
|
35
|
+
next_val = other[other_i]
|
36
|
+
other_i += 1
|
37
|
+
unless val === next_val
|
20
38
|
ret = false
|
21
39
|
break
|
22
40
|
end
|
@@ -26,4 +44,5 @@ class NSIndexPath
|
|
26
44
|
end
|
27
45
|
return false
|
28
46
|
end
|
29
|
-
|
47
|
+
|
48
|
+
end
|
@@ -2,7 +2,7 @@ class UIView
|
|
2
2
|
|
3
3
|
def to_s
|
4
4
|
"#{self.class.name}(##{self.object_id.to_s(16)}, #{self.frame}, " +
|
5
|
-
self.superview ? " child of #{self.superview.class.name}(##{self.superview.object_id.to_s(16)})" : ''
|
5
|
+
(self.superview ? " child of #{self.superview.class.name}(##{self.superview.object_id.to_s(16)})" : '')
|
6
6
|
end
|
7
7
|
|
8
8
|
end
|
data/lib/sugarcube/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sugarcube
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -14,7 +14,7 @@ date: 2012-08-30 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
17
|
-
requirement:
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,15 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements:
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0'
|
26
31
|
- !ruby/object:Gem::Dependency
|
27
32
|
name: rspec
|
28
|
-
requirement:
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
29
34
|
none: false
|
30
35
|
requirements:
|
31
36
|
- - ! '>='
|
@@ -33,7 +38,12 @@ dependencies:
|
|
33
38
|
version: '0'
|
34
39
|
type: :development
|
35
40
|
prerelease: false
|
36
|
-
version_requirements:
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
37
47
|
description: ! '== Description
|
38
48
|
|
39
49
|
|
@@ -119,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
129
|
version: '0'
|
120
130
|
requirements: []
|
121
131
|
rubyforge_project:
|
122
|
-
rubygems_version: 1.8.
|
132
|
+
rubygems_version: 1.8.19
|
123
133
|
signing_key:
|
124
134
|
specification_version: 3
|
125
135
|
summary: Extensions for Ruby to make Rubymotion development more enjoyable, and hopefully
|