Class: Osaka::Location

Inherits:
Object
  • Object
show all
Defined in:
lib/osaka/numbers.rb,
lib/osaka/location.rb

Instance Method Summary collapse

Constructor Details

#initialize(location_name) ⇒ Location

Returns a new instance of Location.



5
6
7
8
# File 'lib/osaka/location.rb', line 5

def initialize(location_name)
  @location_name = location_name.to_s
  validate
end

Instance Method Details

#+(other_location) ⇒ Object



14
15
16
17
18
# File 'lib/osaka/location.rb', line 14

def+(other_location)
  return Location.new(self) if other_location.to_s.empty?
  return Location.new(other_location) if to_s.empty?
  Location.new(to_s + " of " + other_location.to_s)
end

#==(obj) ⇒ Object



146
147
148
# File 'lib/osaka/location.rb', line 146

def ==(obj)
  @location_name == obj.to_s
end

#as_prefixed_locationObject



28
29
30
31
# File 'lib/osaka/location.rb', line 28

def as_prefixed_location
  return "" if to_s.empty?
  " of " + to_s
end

#button(name) ⇒ Object



37
38
39
# File 'lib/osaka/location.rb', line 37

def button(name)
  create_location_with_added_name("button", name)
end

#cell(name) ⇒ Object



5
6
7
# File 'lib/osaka/numbers.rb', line 5

def cell(name)
  create_location_with_added_name("cell", name)
end

#checkbox(name) ⇒ Object



89
90
91
# File 'lib/osaka/location.rb', line 89

def checkbox(name)
  create_location_with_added_name("checkbox", name)
end

#create_location_with_added_name(element, name) ⇒ Object



138
139
140
# File 'lib/osaka/location.rb', line 138

def create_location_with_added_name(element, name)
  self + Location.new(element + " " + to_location_string(name))
end

#dialog(name) ⇒ Object



85
86
87
# File 'lib/osaka/location.rb', line 85

def dialog(name)
  create_location_with_added_name("dialog", name)
end

#group(name) ⇒ Object



41
42
43
# File 'lib/osaka/location.rb', line 41

def group(name)
  create_location_with_added_name("group", name)
end

#has_element?(name) ⇒ Boolean

Returns:

  • (Boolean)


142
143
144
# File 'lib/osaka/location.rb', line 142

def has_element?(name)
  as_prefixed_location.scan(" of #{name}").length >= 1
end

#has_menu_bar?Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/osaka/location.rb', line 77

def has_menu_bar?
  has_element?("menu bar")
end

#has_top_level_element?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/osaka/location.rb', line 33

def has_top_level_element?
  has_window? || has_menu_bar?
end

#has_window?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/osaka/location.rb', line 53

def has_window?
  has_element?("window")
end


65
66
67
# File 'lib/osaka/location.rb', line 65

def menu(name)
  create_location_with_added_name("menu", name)
end


73
74
75
# File 'lib/osaka/location.rb', line 73

def menu_bar(name)
  create_location_with_added_name("menu bar", name)
end


81
82
83
# File 'lib/osaka/location.rb', line 81

def menu_bar_item(name)
  create_location_with_added_name("menu bar item", name)
end


61
62
63
# File 'lib/osaka/location.rb', line 61

def menu_button(name)
  create_location_with_added_name("menu button", name)
end


69
70
71
# File 'lib/osaka/location.rb', line 69

def menu_item(name)
  create_location_with_added_name("menu item", name)
end

#outline(name) ⇒ Object



113
114
115
# File 'lib/osaka/location.rb', line 113

def outline(name)
  create_location_with_added_name("outline", name)
end

#pop_up_button(name) ⇒ Object



101
102
103
# File 'lib/osaka/location.rb', line 101

def pop_up_button(name)
  create_location_with_added_name("pop up button", name)
end

#radio_button(name) ⇒ Object



129
130
131
# File 'lib/osaka/location.rb', line 129

def radio_button(name)
  create_location_with_added_name("radio button", name)
end

#radio_group(name) ⇒ Object



125
126
127
# File 'lib/osaka/location.rb', line 125

def radio_group(name)
  create_location_with_added_name("radio group", name)
end

#row(name) ⇒ Object



121
122
123
# File 'lib/osaka/location.rb', line 121

def row(name)
    create_location_with_added_name("row", name)
end

#scroll_area(name) ⇒ Object



109
110
111
# File 'lib/osaka/location.rb', line 109

def scroll_area(name)
  create_location_with_added_name("scroll area", name)
end

#sheet(name) ⇒ Object



93
94
95
# File 'lib/osaka/location.rb', line 93

def sheet(name)
  create_location_with_added_name("sheet", name)
end

#splitter_group(name) ⇒ Object



105
106
107
# File 'lib/osaka/location.rb', line 105

def splitter_group(name)
  create_location_with_added_name("splitter group", name)
end

#static_text(name) ⇒ Object



57
58
59
# File 'lib/osaka/location.rb', line 57

def static_text(name)
  create_location_with_added_name("static text", name)
end

#tab_group(name) ⇒ Object



45
46
47
# File 'lib/osaka/location.rb', line 45

def tab_group(name)
  create_location_with_added_name("tab group", name)
end

#table(name) ⇒ Object



9
10
11
# File 'lib/osaka/numbers.rb', line 9

def table(name)
  create_location_with_added_name("table", name)
end

#text_field(name) ⇒ Object



97
98
99
# File 'lib/osaka/location.rb', line 97

def text_field(name)
  create_location_with_added_name("text field", name)
end

#to_location_string(name) ⇒ Object



133
134
135
136
# File 'lib/osaka/location.rb', line 133

def to_location_string(name)
  return name.to_s if name.kind_of? Integer
  '"' + name.to_s + '"'
end

#to_sObject



24
25
26
# File 'lib/osaka/location.rb', line 24

def to_s
  @location_name
end

#top_level_elementObject



20
21
22
# File 'lib/osaka/location.rb', line 20

def top_level_element
  Location.new(@location_name[/window (.*)$/])
end

#ui_element(name) ⇒ Object



117
118
119
# File 'lib/osaka/location.rb', line 117

def ui_element(name)
    create_location_with_added_name("UI element", name)
end

#validateObject



10
11
12
# File 'lib/osaka/location.rb', line 10

def validate
  raise(Osaka::InvalidLocation, "Invalid location: #{to_s}") if as_prefixed_location.scan(" of window").length > 1
end

#window(name) ⇒ Object



49
50
51
# File 'lib/osaka/location.rb', line 49

def window(name)
  create_location_with_added_name("window", name)
end