Class: Xpath::Specs::PagePart

Inherits:
Object
  • Object
show all
Defined in:
lib/xpath/specs/page_part.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(description, xpath, parent = nil) ⇒ PagePart

Returns a new instance of PagePart.



7
8
9
10
11
# File 'lib/xpath/specs/page_part.rb', line 7

def initialize(description, xpath, parent = nil)
  @xpath = xpath
  @description = description
  @parent = parent
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



13
14
15
# File 'lib/xpath/specs/page_part.rb', line 13

def description
  @description
end

#parentObject (readonly)

Returns the value of attribute parent.



13
14
15
# File 'lib/xpath/specs/page_part.rb', line 13

def parent
  @parent
end

#xpathObject (readonly)

Returns the value of attribute xpath.



13
14
15
# File 'lib/xpath/specs/page_part.rb', line 13

def xpath
  @xpath
end

Instance Method Details

#has_parentObject



15
16
17
# File 'lib/xpath/specs/page_part.rb', line 15

def has_parent
  !parent.nil?
end

#long_descriptionObject



19
20
21
# File 'lib/xpath/specs/page_part.rb', line 19

def long_description
  "#{description} (#{xpath})"
end

#that(description, xpath) ⇒ Object



29
30
31
# File 'lib/xpath/specs/page_part.rb', line 29

def that(description, xpath)
  PagePart.new("#{self.description} that #{description}", self.xpath+xpath, self)
end

#with(description, xpath) ⇒ Object



23
24
25
# File 'lib/xpath/specs/page_part.rb', line 23

def with(description, xpath)
  PagePart.new(description, self.xpath+xpath, self)
end

#within_a(outer_page_part) ⇒ Object



26
27
28
# File 'lib/xpath/specs/page_part.rb', line 26

def within_a(outer_page_part)
  outer_page_part.with(self.description, self.xpath)
end