jarib-celerity 0.0.6.9 → 0.0.6.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -48,19 +48,20 @@ module Celerity
48
48
 
49
49
  #
50
50
  # Get the element at the given index.
51
- # This is 1-indexed to keep compatibility with Watir - subject to change.
51
+ # By default, this is 1-indexed to keep compatibility with Watir.
52
+ #
52
53
  # Also note that because of Watir's lazy loading, this will return an Element
53
54
  # instance even if the index is out of bounds.
54
55
  #
55
- # @param [Fixnum] n Index of wanted element, 1-indexed.
56
+ # @param [Fixnum] n Index of wanted element, 1-indexed unless Celerity.index_offset is changed.
56
57
  # @return [Celerity::Element] Returns a subclass of Celerity::Element
57
58
  #
58
59
 
59
60
  def [](n)
60
- if @elements && @elements[n - INDEX_OFFSET]
61
- element_class.new(@container, :object, @elements[n - INDEX_OFFSET])
61
+ if @elements && @elements[n - Celerity.index_offset]
62
+ element_class.new(@container, :object, @elements[n - Celerity.index_offset])
62
63
  else
63
- iterator_object(n - INDEX_OFFSET)
64
+ iterator_object(n - Celerity.index_offset)
64
65
  end
65
66
  end
66
67
 
@@ -71,7 +72,7 @@ module Celerity
71
72
  #
72
73
 
73
74
  def first
74
- self[INDEX_OFFSET]
75
+ self[Celerity.index_offset]
75
76
  end
76
77
 
77
78
  #
@@ -81,7 +82,7 @@ module Celerity
81
82
  #
82
83
 
83
84
  def last
84
- self[INDEX_OFFSET - 1]
85
+ self[Celerity.index_offset - 1]
85
86
  end
86
87
 
87
88
  #
@@ -52,7 +52,7 @@ module Celerity
52
52
  elsif @attributes.include?(how = how.to_sym)
53
53
  attributes[how] << what
54
54
  elsif how == :index
55
- index = what.to_i - INDEX_OFFSET
55
+ index = what.to_i - Celerity.index_offset
56
56
  elsif how == :text
57
57
  text = what
58
58
  else
@@ -67,11 +67,11 @@ module Celerity
67
67
  def child_row(index)
68
68
  assert_exists
69
69
 
70
- if (index - INDEX_OFFSET) >= @rows.length
70
+ if (index - Celerity.index_offset) >= @rows.length
71
71
  raise UnknownRowException, "Unable to locate a row at index #{index}"
72
72
  end
73
73
 
74
- TableRow.new(self, :object, @rows[index - INDEX_OFFSET])
74
+ TableRow.new(self, :object, @rows[index - Celerity.index_offset])
75
75
  end
76
76
  alias_method :[], :child_row
77
77
 
@@ -88,11 +88,11 @@ module Celerity
88
88
  def child_cell(index)
89
89
  assert_exists
90
90
 
91
- if (index - INDEX_OFFSET) >= @cells.length
91
+ if (index - Celerity.index_offset) >= @cells.length
92
92
  raise UnknownCellException, "Unable to locate a cell at index #{index}"
93
93
  end
94
94
 
95
- TableCell.new(self, :object, @cells[index - INDEX_OFFSET])
95
+ TableCell.new(self, :object, @cells[index - Celerity.index_offset])
96
96
  end
97
97
 
98
98
  #
@@ -112,9 +112,9 @@ module Celerity
112
112
  # @return [Fixnum]
113
113
  #
114
114
 
115
- def column_count(index = INDEX_OFFSET)
115
+ def column_count(index = Celerity.index_offset)
116
116
  assert_exists
117
- @object.getRow(index - INDEX_OFFSET).getCells.length
117
+ @object.getRow(index - Celerity.index_offset).getCells.length
118
118
  end
119
119
 
120
120
  #
@@ -13,7 +13,7 @@ module Celerity
13
13
 
14
14
  def [](index)
15
15
  assert_exists
16
- TableRow.new(self, :object, @rows[index - INDEX_OFFSET])
16
+ TableRow.new(self, :object, @rows[index - Celerity.index_offset])
17
17
  end
18
18
 
19
19
  def length
@@ -27,11 +27,11 @@ module Celerity
27
27
  def child_cell(index)
28
28
  assert_exists
29
29
 
30
- if (index - INDEX_OFFSET) >= @cells.length
30
+ if (index - Celerity.index_offset) >= @cells.length
31
31
  raise UnknownCellException, "Unable to locate a cell at index #{index}"
32
32
  end
33
33
 
34
- TableCell.new(self, :object, @cells[index - INDEX_OFFSET])
34
+ TableCell.new(self, :object, @cells[index - Celerity.index_offset])
35
35
  end
36
36
  alias_method :[], :child_cell
37
37
 
@@ -3,7 +3,7 @@ module Celerity #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
5
  TINY = 6
6
- PATCH = 9 # Set to nil for official release
6
+ PATCH = 10 # Set to nil for official release
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PATCH].compact.join('.')
9
9
  end
data/lib/celerity.rb CHANGED
@@ -16,7 +16,11 @@ module Celerity
16
16
  Log = Logger.new($DEBUG ? $stderr : nil)
17
17
  Log.level = Logger::DEBUG
18
18
 
19
- INDEX_OFFSET = 1
19
+ @index_offset = 1
20
+ class << self
21
+ attr_accessor :index_offset
22
+ end
23
+
20
24
  DIR = File.expand_path(File.dirname(__FILE__) + "/celerity")
21
25
  end
22
26
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jarib-celerity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6.9
4
+ version: 0.0.6.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jari Bakken