Class: ObjectRepository::Repository

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/watir-or/repository.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, browser, options = nil) ⇒ Repository

Returns a new instance of Repository.



6
7
8
9
10
11
12
# File 'lib/watir-or/repository.rb', line 6

def initialize(file, browser, options = nil)
  @file = file
  @elements = []
  @browser = browser
  @type = File.extname(@file).delete('.')
  fill_elements(options)
end

Instance Attribute Details

#browserObject (readonly)

Returns the value of attribute browser.



4
5
6
# File 'lib/watir-or/repository.rb', line 4

def browser
  @browser
end

#elementsObject (readonly)

Returns the value of attribute elements.



4
5
6
# File 'lib/watir-or/repository.rb', line 4

def elements
  @elements
end

#fileObject (readonly)

Returns the value of attribute file.



4
5
6
# File 'lib/watir-or/repository.rb', line 4

def file
  @file
end

Instance Method Details

#each(&block) ⇒ Object



14
15
16
# File 'lib/watir-or/repository.rb', line 14

def each(&block)
  @elements.each { |el| yield el }
end

#get(name) ⇒ Object



18
19
20
21
22
# File 'lib/watir-or/repository.rb', line 18

def get(name)
  element = find { |el| el.name == name }
  raise "Couldn't find repository element with #{name.inspect}" if element.nil?
  return element
end

#inspectObject



24
25
26
# File 'lib/watir-or/repository.rb', line 24

def inspect
  @elements.inspect
end