Class: Lebowski::Foundation::Views::Support::SimpleItemArray
Constant Summary
SC_BRANCH_CLOSED, SC_BRANCH_OPEN, SC_BUTTON1_STATUS, SC_BUTTON2_STATUS, SC_BUTTON3_STATUS, SC_LEAF_NODE, SC_MIXED_STATE, SC_PICKER_FIXED, SC_PICKER_MENU, SC_PICKER_POINTER, SC_T_ARRAY, SC_T_BOOL, SC_T_CLASS, SC_T_ERROR, SC_T_FUNCTION, SC_T_HASH, SC_T_NULL, SC_T_NUMBER, SC_T_OBJECT, SC_T_STRING, SC_T_UNDEFINED
Instance Method Summary
collapse
Constructor Details
#initialize(parent, item_selector, value_rel_path = nil, items_rel_path = nil, item_title_key = nil, item_value_key = nil) ⇒ SimpleItemArray
Returns a new instance of SimpleItemArray.
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/lebowski/foundation/views/support/simple_item_array.rb', line 43
def initialize(parent, item_selector, value_rel_path=nil, items_rel_path=nil, item_title_key=nil, item_value_key=nil)
if not parent.kind_of? View
raise ArgumentInvalidTypeError.new "parent", parent, View
end
if not item_selector.kind_of? String
raise ArgumentInvalidTypeError.new "item_selector", item_selector, String
end
@parent = parent
@driver = parent.driver
@item_selector = item_selector
@value_rel_path = value_rel_path.nil? ? 'value' : value_rel_path
@items_rel_path = items_rel_path.nil? ? 'items' : items_rel_path
@item_title_key = item_title_key.nil? ? parent['itemTitleKey'] : parent[item_title_key]
@item_value_key = item_value_key.nil? ? parent['itemValueKey'] : parent[item_value_key]
end
|
Instance Method Details
#[](index) ⇒ Object
92
93
94
95
96
97
98
99
|
# File 'lib/lebowski/foundation/views/support/simple_item_array.rb', line 92
def [](index)
if index < 0 or index > count
raise ArgumentError "index must be between 0 and #{count}"
end
items = @parent[@items_rel_path]
return __create_simple_item(items[index])
end
|
#all?(&block) ⇒ Boolean
120
121
122
123
|
# File 'lib/lebowski/foundation/views/support/simple_item_array.rb', line 120
def all?(&block)
raise ArgumentError "require block" if (not block_given?)
return (count(&block) == count)
end
|
#all_selected? ⇒ Boolean
80
81
82
|
# File 'lib/lebowski/foundation/views/support/simple_item_array.rb', line 80
def all_selected?()
return (selected_count == count)
end
|
#any?(&block) ⇒ Boolean
Also known as:
some?
125
126
127
128
|
# File 'lib/lebowski/foundation/views/support/simple_item_array.rb', line 125
def any?(&block)
raise ArgumentError "require block" if (not block_given?)
return (count(&block) > 0)
end
|
#any_selected? ⇒ Boolean
Also known as:
some_selected?
74
75
76
|
# File 'lib/lebowski/foundation/views/support/simple_item_array.rb', line 74
def any_selected?()
return (selected_count > 0)
end
|
#click(value) ⇒ Object
163
164
165
166
167
168
169
170
171
|
# File 'lib/lebowski/foundation/views/support/simple_item_array.rb', line 163
def click(value)
if value.kind_of? Integer
click_with_index(value)
elsif value.kind_of? String
click_with_title(value)
else
raise ArgumentInvalidTypeError.new "value", value, Integer, String
end
end
|
#click_with_index(value) ⇒ Object
173
174
175
176
177
178
179
180
181
182
|
# File 'lib/lebowski/foundation/views/support/simple_item_array.rb', line 173
def click_with_index(value)
cq = @parent.core_query(@item_selector)
cq[value].mouse_down
cq[value].basic_click cq.done
cq = @parent.core_query(@item_selector)
cq[value].mouse_up
cq.done
end
|
#click_with_title(value) ⇒ Object
184
185
186
187
188
|
# File 'lib/lebowski/foundation/views/support/simple_item_array.rb', line 184
def click_with_title(value)
index = find_index_with_title value
return if (index == :no_index)
click_with_index index
end
|
#count(&block) ⇒ Object
110
111
112
113
114
115
116
117
118
|
# File 'lib/lebowski/foundation/views/support/simple_item_array.rb', line 110
def count(&block)
return @parent["#{@items_rel_path}.length"] if (not block_given?)
counter = 0
each do |item, index|
result = yield item, index
counter = counter.next if (result == true)
end
return counter
end
|
#each(&block) ⇒ Object
101
102
103
104
105
106
107
108
|
# File 'lib/lebowski/foundation/views/support/simple_item_array.rb', line 101
def each(&block)
items = @parent[@items_rel_path]
items.each_with_index do |item, index|
item = __create_simple_item(item)
yield item, index
end
end
|
#find_index_with_title(value) ⇒ Object
212
213
214
215
216
217
218
219
220
|
# File 'lib/lebowski/foundation/views/support/simple_item_array.rb', line 212
def find_index_with_title(value)
items = @parent[@items_rel_path]
items.each_with_index do |item, index|
title = get_item_title(item)
return index if (title =~ /^#{value}/i)
end
return :no_index
end
|
#none?(&block) ⇒ Boolean
137
138
139
140
|
# File 'lib/lebowski/foundation/views/support/simple_item_array.rb', line 137
def none?(&block)
raise ArgumentError "require block" if (not block_given?)
return (count(&block) == 0)
end
|
#none_selected? ⇒ Boolean
88
89
90
|
# File 'lib/lebowski/foundation/views/support/simple_item_array.rb', line 88
def none_selected?()
return (selected_count == 0)
end
|
#one?(&block) ⇒ Boolean
132
133
134
135
|
# File 'lib/lebowski/foundation/views/support/simple_item_array.rb', line 132
def one?(&block)
raise ArgumentError "require block" if (not block_given?)
return (count(&block) == 1)
end
|
#one_selected? ⇒ Boolean
84
85
86
|
# File 'lib/lebowski/foundation/views/support/simple_item_array.rb', line 84
def one_selected?()
return (selected_count == 1)
end
|
#select(value) ⇒ Object
190
191
192
193
194
195
196
197
198
|
# File 'lib/lebowski/foundation/views/support/simple_item_array.rb', line 190
def select(value)
if value.kind_of? Integer
select_with_index(value)
elsif value.kind_of? String
select_with_title(value)
else
raise ArgumentInvalidTypeError.new "value", value, Integer, String
end
end
|
#select_with_index(index) ⇒ Object
200
201
202
203
|
# File 'lib/lebowski/foundation/views/support/simple_item_array.rb', line 200
def select_with_index(index)
item = self[index]
item.select
end
|
#select_with_title(value) ⇒ Object
205
206
207
208
209
210
|
# File 'lib/lebowski/foundation/views/support/simple_item_array.rb', line 205
def select_with_title(value)
index = find_index_with_title(value)
return if (index == :no_index)
item = self[index]
item.select
end
|
#selected?(value) ⇒ Boolean
61
62
63
64
65
|
# File 'lib/lebowski/foundation/views/support/simple_item_array.rb', line 61
def selected?(value)
return selected_with_index?(value) if (value.kind_of? Integer)
return selected_with_title?(value) if (value.kind_of? String)
raise ArgumentInvalidTypeError.new "value", value, Integer, String
end
|
#selected_count ⇒ Object
67
68
69
70
71
72
|
# File 'lib/lebowski/foundation/views/support/simple_item_array.rb', line 67
def selected_count()
value = @parent[@value_rel_path]
return 0 if value.nil?
return value.length if value.kind_of?(Array)
return 1
end
|
#selected_with_index?(index) ⇒ Boolean
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
# File 'lib/lebowski/foundation/views/support/simple_item_array.rb', line 142
def selected_with_index?(index)
value = @parent[@value_rel_path]
items = @parent[@items_rel_path]
items.each_with_index do |item, idx|
item_value = get_item_value(item)
if index == idx
return (value == item_value) if (not value.kind_of? Array)
return (value.member? item_value) if value.kind_of?(Array)
end
end
return false
end
|
#selected_with_title?(value) ⇒ Boolean
157
158
159
160
161
|
# File 'lib/lebowski/foundation/views/support/simple_item_array.rb', line 157
def selected_with_title?(value)
index = find_index_with_title value
return false if (index == :no_index)
return selected_with_index?(index)
end
|