Class: Watirmark::ProcessPage

Inherits:
Object
  • Object
show all
Defined in:
lib/watirmark/page/process_page.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = '', parent = nil, active_page = nil, navigate_page = nil, submit_page = nil) ⇒ ProcessPage

Returns a new instance of ProcessPage.



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/watirmark/page/process_page.rb', line 38

def initialize(name='', parent=nil, active_page=nil, navigate_page=nil, submit_page=nil)
  @name = name
  @parent = parent
  @keywords = []
  @root = false
  @always_activate_parent = false
  @alias = []
  @active_page_method = active_page if active_page
  @navigate_method = navigate_page if navigate_page
  @submit_method = submit_page if submit_page
end

Instance Attribute Details

#active_page_methodObject

Returns the value of attribute active_page_method.



6
7
8
# File 'lib/watirmark/page/process_page.rb', line 6

def active_page_method
  @active_page_method
end

#aliasObject

Returns the value of attribute alias.



5
6
7
# File 'lib/watirmark/page/process_page.rb', line 5

def alias
  @alias
end

#always_activate_parentObject

Returns the value of attribute always_activate_parent.



5
6
7
# File 'lib/watirmark/page/process_page.rb', line 5

def always_activate_parent
  @always_activate_parent
end

#keywordsObject (readonly)

Returns the value of attribute keywords.



4
5
6
# File 'lib/watirmark/page/process_page.rb', line 4

def keywords
  @keywords
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/watirmark/page/process_page.rb', line 5

def name
  @name
end

Returns the value of attribute navigate_method.



6
7
8
# File 'lib/watirmark/page/process_page.rb', line 6

def navigate_method
  @navigate_method
end

#parentObject (readonly)

Returns the value of attribute parent.



4
5
6
# File 'lib/watirmark/page/process_page.rb', line 4

def parent
  @parent
end

#rootObject

Returns the value of attribute root.



5
6
7
# File 'lib/watirmark/page/process_page.rb', line 5

def root
  @root
end

#submit_methodObject

Returns the value of attribute submit_method.



6
7
8
# File 'lib/watirmark/page/process_page.rb', line 6

def submit_method
  @submit_method
end

Class Method Details

.active_page_method_defaultObject



33
34
35
# File 'lib/watirmark/page/process_page.rb', line 33

def active_page_method_default
  @@active_page_method_default
end

.active_page_method_default=(proc) ⇒ Object



21
22
23
# File 'lib/watirmark/page/process_page.rb', line 21

def active_page_method_default=(proc)
  @@active_page_method_default = proc
end


25
26
27
# File 'lib/watirmark/page/process_page.rb', line 25

def navigate_method_default
  @@navigate_method_default
end


13
14
15
# File 'lib/watirmark/page/process_page.rb', line 13

def navigate_method_default=(proc)
  @@navigate_method_default = proc
end

.submit_method_defaultObject



29
30
31
# File 'lib/watirmark/page/process_page.rb', line 29

def submit_method_default
  @@submit_method_default
end

.submit_method_default=(proc) ⇒ Object



17
18
19
# File 'lib/watirmark/page/process_page.rb', line 17

def submit_method_default=(proc)
  @@submit_method_default = proc
end

Instance Method Details

#<<(x) ⇒ Object



68
69
70
# File 'lib/watirmark/page/process_page.rb', line 68

def <<(x)
  @keywords << x.to_sym
end

#activateObject



58
59
60
61
62
63
64
65
66
# File 'lib/watirmark/page/process_page.rb', line 58

def activate
  return if (@root || active?)
  if @always_activate_parent
    @parent.goto_process_page
  else
    @parent.activate if @parent
  end
  goto_process_page
end

#active?Boolean

Returns:

  • (Boolean)


100
101
102
103
104
105
# File 'lib/watirmark/page/process_page.rb', line 100

def active?
  page = active_page
  return true if in_submenu(page, underscored_name)
  aliases.each { |a| return true if in_submenu(page, underscored_name(a)) } unless aliases.empty?
  false
end

#active_pageObject



92
93
94
# File 'lib/watirmark/page/process_page.rb', line 92

def active_page
  instance_eval &(@active_page_method || @@active_page_method_default)
end

#aliasesObject



96
97
98
# File 'lib/watirmark/page/process_page.rb', line 96

def aliases
  @alias ||= []
end

#goto_process_pageObject



72
73
74
75
76
77
78
79
80
81
82
# File 'lib/watirmark/page/process_page.rb', line 72

def goto_process_page
  unless navigate
    aliases.each do |alias_name|
      alias_process_page = self.dup
      alias_process_page.alias = []
      alias_process_page.name = alias_name
      alias_process_page.alias = nil
      alias_process_page.goto_process_page
    end
  end
end

#in_submenu(active_page, requested_page) ⇒ Object



107
108
109
# File 'lib/watirmark/page/process_page.rb', line 107

def in_submenu(active_page, requested_page)
  !!(active_page.to_s.downcase.delete('>').gsub(/\s+/, '_') =~ /^#{requested_page}/)
end


84
85
86
# File 'lib/watirmark/page/process_page.rb', line 84

def navigate
  instance_eval &(@navigate_method || @@navigate_method_default)
end

#submitObject



88
89
90
# File 'lib/watirmark/page/process_page.rb', line 88

def submit
  instance_eval &(@submit_method || @@submit_method_default)
end

#underscored_name(name = @name) ⇒ Object

Give the full name of this process page, including the parent process pages. The argument allows us to easily get the full path for alias names.



53
54
55
56
# File 'lib/watirmark/page/process_page.rb', line 53

def underscored_name(name=@name)
  u_name = (@parent && !@parent.root) ? "#{@parent.underscored_name}_#{name}" : name
  u_name.downcase.gsub(/\s+|\//, '_') if u_name
end