Class: Insite::ComponentCollection
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#a, #abbr, #abbrs, #address, #addresses, #area, #areas, #article, #articles, #as, #aside, #asides, #audio, #audios, #b, #base, #bases, #bdi, #bdis, #bdo, #bdos, #blockquote, #blockquotes, #body, #bodys, #br, #brs, #bs, #button, #buttons, #canvas, #canvases, #caption, #captions, #cell, #cells, #checkbox, #checkboxes, #circle, #circles, #cite, #cites, #code, #codes, #col, #colgroup, #colgroups, #cols, #cursor, #cursors, #data, #datalist, #datalists, #datas, #date_field, #date_fields, #date_time_field, #date_time_fields, #dd, #dds, #defs, #defss, #del, #dels, #desc, #descs, #details, #detailses, #dfn, #dfns, #div, #divs, #dl, #dls, #dt, #dts, #element, #elements, #ellipse, #ellipses, #em, #embed, #embeds, #ems, #field_set, #field_sets, #fieldset, #fieldsets, #figcaption, #figcaptions, #figure, #figures, #file_field, #file_fields, #font, #fonts, #footer, #footers, #foreign_object, #foreign_objects, #form, #forms, #frame, #frames, #frameset, #framesets, #g, #gs, #h1, #h1s, #h2, #h2s, #h3, #h3s, #h4, #h4s, #h5, #h5s, #h6, #h6s, #hatchpath, #hatchpaths, #head, #header, #headers, #heads, #hidden, #hiddens, #hr, #hrs, #htmls, #i, #iframe, #iframes, #image, #images, #img, #imgs, #input, #inputs, #ins, #inses, #is, #kbd, #kbds, #keygen, #keygens, #label, #labels, #legend, #legends, #li, #line, #linear_gradient, #linear_gradients, #lines, #link, #links, #lis, #main, #mains, #map, #maps, #mark, #marker, #markers, #marks, #menu, #menuitem, #menuitems, #menus, #mesh, #meshes, #meshgradient, #meshgradients, #meshpatch, #meshpatches, #meshrow, #meshrows, #meta, #metadata, #metadatas, #metas, #meter, #meters, #nav, #navs, #noscript, #noscripts, #object, #objects, #ol, #ols, #optgroup, #optgroups, #option, #options, #output, #outputs, #p, #param, #params, #path, #paths, #pattern, #patterns, #picture, #pictures, #polygon, #polygons, #polyline, #polylines, #pre, #pres, #progress, #progresses, #ps, #q, #qs, #radial_gradient, #radial_gradients, #radio, #radios, #rb, #rbs, #rect, #rects, #row, #rows, #rp, #rps, #rt, #rtc, #rtcs, #rts, #rubies, #ruby, #s, #samp, #samps, #script, #scripts, #section, #sections, #select, #select_list, #select_lists, #selects, #small, #smalls, #solidcolor, #solidcolors, #source, #sources, #span, #spans, #ss, #stop, #stops, #strong, #strongs, #style, #styles, #sub, #subs, #summaries, #summary, #sup, #sups, #svg, #svgs, #switch, #switches, #symbol, #symbols, #table, #tables, #tbody, #tbodys, #td, #tds, #template, #templates, #text_field, #text_fields, #text_path, #text_paths, #textarea, #textareas, #tfoot, #tfoots, #th, #thead, #theads, #ths, #time, #times, #titles, #tr, #track, #tracks, #trs, #tspan, #tspans, #u, #ul, #uls, #us, #use, #uses, #var, #vars, #video, #videos, #view, #views, #wbr, #wbrs
#document, #update_object
Constructor Details
Returns a new instance of ComponentCollection.
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/insite/component/component_collection.rb', line 45
def initialize(parent, *args)
@site = parent.class.ancestors.include?(Insite) ? parent : parent.site
@browser = @site.browser
@collection_member_type = self.class.instance_variable_get(:@collection_member_type)
@selector = @collection_member_type.selector
if args[0].is_a?(Insite::Element) || args[0].is_a?(Watir::Element)
@dom_type = nil
@args = nil
@target = args[0].target
elsif args[0].is_a?(Insite::ElementCollection) || args[0].is_a?(Watir::ElementCollection)
@dom_type = nil
@args = nil
@target = args[0]
else
@args = parse_args(args)
@selector = @args
@non_relative = @args.delete(:non_relative) || false
if @non_relative
@parent = parent.site
else
parent.respond_to?(:target) ? obj = parent : obj = parent.site
@parent = obj
end
if watir_class = Insite::CLASS_MAP.key(self.class)
@target = watir_class.new(@parent.target, @args)
else
@target = Watir::HTMLElementCollection.new(@parent.target, @args)
end
end
end
|
Instance Attribute Details
Returns the value of attribute args.
3
4
5
|
# File 'lib/insite/component/component_collection.rb', line 3
def args
@args
end
|
Returns the value of attribute browser.
3
4
5
|
# File 'lib/insite/component/component_collection.rb', line 3
def browser
@browser
end
|
#collection_member_type ⇒ Object
Returns the value of attribute collection_member_type.
3
4
5
|
# File 'lib/insite/component/component_collection.rb', line 3
def collection_member_type
@collection_member_type
end
|
#indentifiers ⇒ Object
Returns the value of attribute indentifiers.
3
4
5
|
# File 'lib/insite/component/component_collection.rb', line 3
def indentifiers
@indentifiers
end
|
Returns the value of attribute parent.
3
4
5
|
# File 'lib/insite/component/component_collection.rb', line 3
def parent
@parent
end
|
Returns the value of attribute site.
3
4
5
|
# File 'lib/insite/component/component_collection.rb', line 3
def site
@site
end
|
Returns the value of attribute target.
3
4
5
|
# File 'lib/insite/component/component_collection.rb', line 3
def target
@target
end
|
Class Method Details
.collection? ⇒ true, false
Returns true if the class represents a collection, false if not.
16
17
18
|
# File 'lib/insite/component/component_collection.rb', line 16
def self.collection?
true
end
|
Instance Method Details
#==(other) ⇒ Object
Also known as:
eql?
20
21
22
|
# File 'lib/insite/component/component_collection.rb', line 20
def ==(other)
to_a == other.to_a
end
|
25
26
27
|
# File 'lib/insite/component/component_collection.rb', line 25
def[](idx)
to_a[idx]
end
|
#collection? ⇒ Boolean
29
30
31
|
# File 'lib/insite/component/component_collection.rb', line 29
def collection?
true
end
|
#each(&block) ⇒ Object
37
38
39
|
# File 'lib/insite/component/component_collection.rb', line 37
def each(&block)
to_a.each(&block)
end
|
#empty? ⇒ Boolean
41
42
43
|
# File 'lib/insite/component/component_collection.rb', line 41
def empty?
length == 0
end
|
33
34
35
|
# File 'lib/insite/component/component_collection.rb', line 33
def first
to_a[0]
end
|
80
81
82
83
|
# File 'lib/insite/component/component_collection.rb', line 80
def inspect
@selector.empty? ? s = '{element: (selenium element)}' : s = @selector.to_s
"#<#{self.class}: @parent: #{@parent}; @selector=#{s}>"
end
|
85
86
87
|
# File 'lib/insite/component/component_collection.rb', line 85
def last
to_a[-1]
end
|
#length ⇒ Object
Also known as:
count, size
89
90
91
|
# File 'lib/insite/component/component_collection.rb', line 89
def length
to_a.length
end
|
95
96
97
|
# File 'lib/insite/component/component_collection.rb', line 95
def text
to_a.map(&:text)
end
|
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/insite/component/component_collection.rb', line 99
def to_a
out = []
@target.to_a.each_with_index do |elem, idx|
out << @collection_member_type.new(
@parent,
@args.merge!(index: idx)
)
end
out
end
|