Class: PageObject
- Inherits:
-
Object
- Object
- PageObject
- Includes:
- Capybara::DSL
- Defined in:
- lib/pageify/capybara.rb,
lib/pageify/page_object.rb,
lib/pageify/capybara_experimental.rb
Instance Attribute Summary collapse
-
#intend ⇒ Object
Returns the value of attribute intend.
-
#name ⇒ Object
Returns the value of attribute name.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#self_selector ⇒ Object
Returns the value of attribute self_selector.
Class Method Summary collapse
Instance Method Summary collapse
- #createChild(raw_row) ⇒ Object
- #f ⇒ Object
- #find ⇒ Object
- #find_all ⇒ Object
-
#initialize(name, self_selector, intend) ⇒ PageObject
constructor
A new instance of PageObject.
- #selector ⇒ Object
Constructor Details
#initialize(name, self_selector, intend) ⇒ PageObject
Returns a new instance of PageObject.
34 35 36 37 38 |
# File 'lib/pageify/page_object.rb', line 34 def initialize (name,self_selector,intend) @name = name @self_selector = self_selector @intend = intend end |
Instance Attribute Details
#intend ⇒ Object
Returns the value of attribute intend.
2 3 4 |
# File 'lib/pageify/page_object.rb', line 2 def intend @intend end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/pageify/page_object.rb', line 2 def name @name end |
#parent ⇒ Object
Returns the value of attribute parent.
2 3 4 |
# File 'lib/pageify/page_object.rb', line 2 def parent @parent end |
#self_selector ⇒ Object
Returns the value of attribute self_selector.
2 3 4 |
# File 'lib/pageify/page_object.rb', line 2 def self_selector @self_selector end |
Class Method Details
.create(raw_row) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/pageify/page_object.rb', line 23 def self.create (raw_row) name = raw_row.lstrip.split(":").first self_selector = raw_row.slice(raw_row.index(':')+1..-1) intend = raw_row.lspace PageObject.new(name,self_selector,intend) end |
Instance Method Details
#createChild(raw_row) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/pageify/page_object.rb', line 4 def createChild (raw_row) child = PageObject.create(raw_row) child.parent = self define_singleton_method(child.name) do |*arguments| unless arguments.eql? [] child_selector = (child.self_selector % arguments).strip_quotes.strip else child_selector = (child.self_selector % '').strip_quotes.strip end if child_selector.start_with? "&" $global_selector += child_selector.gsub(/^&/, "") else $global_selector += " " + child_selector end child end return child end |
#f ⇒ Object
8 9 10 |
# File 'lib/pageify/capybara.rb', line 8 def f() self.find end |
#find ⇒ Object
4 5 6 |
# File 'lib/pageify/capybara.rb', line 4 def find() page.find(self.selector) end |
#find_all ⇒ Object
12 13 14 |
# File 'lib/pageify/capybara.rb', line 12 def find_all() page.all(self.selector) end |
#selector ⇒ Object
30 31 32 |
# File 'lib/pageify/page_object.rb', line 30 def selector $global_selector.strip end |