vedeu 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +40 -0
  3. data/README.md +1 -0
  4. data/docs/dsl.md +24 -24
  5. data/lib/vedeu/all.rb +21 -44
  6. data/lib/vedeu/api.rb +13 -13
  7. data/lib/vedeu/application/application_controller.rb +2 -0
  8. data/lib/vedeu/bindings/movement.rb +53 -18
  9. data/lib/vedeu/bindings/refresh.rb +1 -1
  10. data/lib/vedeu/bindings/system.rb +2 -2
  11. data/lib/vedeu/bindings/visibility.rb +3 -3
  12. data/lib/vedeu/borders/all.rb +13 -0
  13. data/lib/vedeu/borders/border.rb +209 -202
  14. data/lib/vedeu/{dsl/border.rb → borders/dsl.rb} +15 -15
  15. data/lib/vedeu/{null/border.rb → borders/null.rb} +9 -9
  16. data/lib/vedeu/borders/render.rb +347 -0
  17. data/lib/vedeu/borders/repository.rb +19 -0
  18. data/lib/vedeu/buffers/all.rb +13 -0
  19. data/lib/vedeu/buffers/buffer.rb +182 -176
  20. data/lib/vedeu/{null/buffer.rb → buffers/null.rb} +8 -8
  21. data/lib/vedeu/buffers/repository.rb +24 -0
  22. data/lib/vedeu/buffers/virtual_buffer.rb +2 -2
  23. data/lib/vedeu/cursors/all.rb +11 -0
  24. data/lib/vedeu/cursors/cursor.rb +276 -0
  25. data/lib/vedeu/cursors/refresh.rb +84 -0
  26. data/lib/vedeu/cursors/repository.rb +34 -0
  27. data/lib/vedeu/dsl/interface.rb +9 -9
  28. data/lib/vedeu/dsl/shared.rb +11 -11
  29. data/lib/vedeu/{exceptions.rb → error.rb} +2 -2
  30. data/lib/vedeu/esc/esc.rb +1 -1
  31. data/lib/vedeu/geometry/all.rb +18 -0
  32. data/lib/vedeu/geometry/area.rb +170 -160
  33. data/lib/vedeu/geometry/coordinate.rb +61 -39
  34. data/lib/vedeu/geometry/dimension.rb +139 -132
  35. data/lib/vedeu/{dsl/geometry.rb → geometry/dsl.rb} +11 -11
  36. data/lib/vedeu/geometry/generic_coordinate.rb +159 -153
  37. data/lib/vedeu/geometry/geometry.rb +310 -212
  38. data/lib/vedeu/geometry/grid.rb +73 -69
  39. data/lib/vedeu/{null/geometry.rb → geometry/null.rb} +10 -10
  40. data/lib/vedeu/geometry/position.rb +124 -120
  41. data/lib/vedeu/geometry/repository.rb +19 -0
  42. data/lib/vedeu/input/editor/document.rb +2 -2
  43. data/lib/vedeu/internal_api.rb +8 -8
  44. data/lib/vedeu/models/escape.rb +2 -2
  45. data/lib/vedeu/models/interface.rb +1 -1
  46. data/lib/vedeu/models/page.rb +89 -0
  47. data/lib/vedeu/models/row.rb +66 -0
  48. data/lib/vedeu/models/toggleable.rb +1 -1
  49. data/lib/vedeu/models/views/char.rb +7 -6
  50. data/lib/vedeu/models/views/line.rb +1 -1
  51. data/lib/vedeu/models/views/view.rb +2 -2
  52. data/lib/vedeu/options.rb +19 -0
  53. data/lib/vedeu/output/clear/named_interface.rb +1 -1
  54. data/lib/vedeu/output/direct.rb +1 -1
  55. data/lib/vedeu/output/presentation.rb +2 -1
  56. data/lib/vedeu/output/viewport.rb +3 -3
  57. data/lib/vedeu/repositories/model.rb +9 -1
  58. data/lib/vedeu/repositories/repository.rb +5 -0
  59. data/lib/vedeu/terminal/terminal.rb +3 -3
  60. data/lib/vedeu/version.rb +1 -1
  61. data/test/lib/vedeu/borders/border_test.rb +299 -291
  62. data/test/lib/vedeu/{dsl/border_test.rb → borders/dsl_test.rb} +6 -6
  63. data/test/lib/vedeu/{null/border_test.rb → borders/null_test.rb} +6 -6
  64. data/test/lib/vedeu/borders/render_test.rb +125 -0
  65. data/test/lib/vedeu/borders/repository_test.rb +17 -0
  66. data/test/lib/vedeu/buffers/buffer_test.rb +116 -112
  67. data/test/lib/vedeu/{null/buffer_test.rb → buffers/null_test.rb} +5 -5
  68. data/test/lib/vedeu/buffers/repository_test.rb +18 -0
  69. data/test/lib/vedeu/cursors/cursor_test.rb +370 -0
  70. data/test/lib/vedeu/cursors/refresh_test.rb +69 -0
  71. data/test/lib/vedeu/cursors/repository_test.rb +41 -0
  72. data/test/lib/vedeu/dsl/interface_test.rb +5 -5
  73. data/test/lib/vedeu/{exceptions_test.rb → error_test.rb} +0 -0
  74. data/test/lib/vedeu/geometry/area_test.rb +141 -137
  75. data/test/lib/vedeu/geometry/coordinate_test.rb +93 -89
  76. data/test/lib/vedeu/geometry/dimension_test.rb +137 -133
  77. data/test/lib/vedeu/{dsl/geometry_test.rb → geometry/dsl_test.rb} +17 -17
  78. data/test/lib/vedeu/geometry/generic_coordinate_test.rb +32 -28
  79. data/test/lib/vedeu/geometry/geometry_test.rb +282 -157
  80. data/test/lib/vedeu/geometry/grid_test.rb +35 -31
  81. data/test/lib/vedeu/{null/geometry_test.rb → geometry/null_test.rb} +5 -5
  82. data/test/lib/vedeu/geometry/position_test.rb +146 -142
  83. data/test/lib/vedeu/geometry/repository_test.rb +19 -0
  84. data/test/lib/vedeu/input/editor/document_test.rb +1 -1
  85. data/test/lib/vedeu/models/escape_test.rb +1 -1
  86. data/test/lib/vedeu/models/interface_test.rb +2 -2
  87. data/test/lib/vedeu/models/page_test.rb +235 -0
  88. data/test/lib/vedeu/models/row_test.rb +111 -0
  89. data/test/lib/vedeu/models/views/char_test.rb +3 -3
  90. data/test/lib/vedeu/options_test.rb +57 -0
  91. data/test/lib/vedeu/output/clear/named_interface_test.rb +1 -1
  92. data/test/lib/vedeu/output/renderers/json_test.rb +1 -1
  93. data/test/lib/vedeu/output/viewport_test.rb +15 -9
  94. data/test/lib/vedeu/refresh/refresh_buffer_test.rb +12 -12
  95. data/test/lib/vedeu/repositories/repositories_test.rb +1 -1
  96. data/test/lib/vedeu/repositories/repository_test.rb +7 -0
  97. data/test/lib/vedeu/terminal/terminal_test.rb +1 -1
  98. data/test/test_helper.rb +1 -1
  99. data/vedeu.gemspec +2 -2
  100. metadata +57 -63
  101. data/lib/vedeu/borders/borders.rb +0 -15
  102. data/lib/vedeu/borders/render_border.rb +0 -331
  103. data/lib/vedeu/buffers/buffers.rb +0 -20
  104. data/lib/vedeu/cursor/cursor.rb +0 -174
  105. data/lib/vedeu/cursor/cursors.rb +0 -30
  106. data/lib/vedeu/cursor/move.rb +0 -239
  107. data/lib/vedeu/cursor/reposition.rb +0 -78
  108. data/lib/vedeu/geometry/geometries.rb +0 -15
  109. data/lib/vedeu/refresh/refresh_cursor.rb +0 -92
  110. data/test/lib/vedeu/borders/borders_test.rb +0 -13
  111. data/test/lib/vedeu/borders/render_border_test.rb +0 -121
  112. data/test/lib/vedeu/buffers/buffers_test.rb +0 -14
  113. data/test/lib/vedeu/cursor/cursor_test.rb +0 -246
  114. data/test/lib/vedeu/cursor/cursors_test.rb +0 -37
  115. data/test/lib/vedeu/cursor/move_test.rb +0 -301
  116. data/test/lib/vedeu/cursor/reposition_test.rb +0 -63
  117. data/test/lib/vedeu/geometry/geometries_test.rb +0 -15
  118. data/test/lib/vedeu/refresh/refresh_cursor_test.rb +0 -65
@@ -53,17 +53,17 @@ module Vedeu
53
53
  # registered, and also adds interface's name to list of focussable
54
54
  # interfaces.
55
55
  #
56
- # @see Vedeu::Buffer
57
- # @return [void]
56
+ # @see Vedeu::Buffers::Buffer
57
+ # @return [Vedeu::Buffers::Buffer]
58
58
  def add_buffers!(name)
59
- Vedeu::Buffer.new(name: name).store
59
+ Vedeu::Buffers::Buffer.new(name: name).store
60
60
  end
61
61
 
62
62
  # Registers a new cursor for the interface unless already registered.
63
63
  #
64
- # @return [void]
64
+ # @return [Vedeu::Cursors::Cursor]
65
65
  def add_cursor!(name)
66
- Vedeu::Cursor.new(name: name).store
66
+ Vedeu::Cursors::Cursor.new(name: name).store
67
67
  end
68
68
 
69
69
  # Registers interface name in focus list unless already registered.
@@ -120,16 +120,16 @@ module Vedeu
120
120
  # # ... # is rendered.
121
121
  # end
122
122
  #
123
- # @return [Vedeu::Cursor]
123
+ # @return [Vedeu::Cursors::Cursor]
124
124
  def cursor(value = true)
125
125
  boolean = value ? true : false
126
126
 
127
- Vedeu::Cursor.new(name: model.name, visible: boolean).store
127
+ Vedeu::Cursors::Cursor.new(name: model.name, visible: boolean).store
128
128
  end
129
129
 
130
130
  # Set the cursor to visible for the interface.
131
131
  #
132
- # @return [Vedeu::Cursor]
132
+ # @return [Vedeu::Cursors::Cursor]
133
133
  def cursor!
134
134
  cursor(true)
135
135
  end
@@ -214,7 +214,7 @@ module Vedeu
214
214
 
215
215
  # Set the cursor to invisible for the interface.
216
216
  #
217
- # @return [Vedeu::Cursor]
217
+ # @return [Vedeu::Cursors::Cursor]
218
218
  def no_cursor!
219
219
  cursor(false)
220
220
  end
@@ -12,17 +12,17 @@ module Vedeu
12
12
  # @example
13
13
  # Vedeu.interface 'my_interface' do
14
14
  # border do
15
- # # ... see Vedeu::DSL::Border for DSL methods for borders.
15
+ # # ... see Vedeu::Borders::DSL for DSL methods for borders.
16
16
  # end
17
17
  # end
18
18
  #
19
19
  # @param name [String] The name of the interface; this is already provided
20
20
  # when we define the interface or view, setting it here is just
21
- # mirroring functionality of {Vedeu::DSL::Border.border}.
21
+ # mirroring functionality of {Vedeu::Borders::DSL.border}.
22
22
  # @param block [Proc]
23
23
  # @raise [Vedeu::Error::InvalidSyntax] The required block was not given.
24
- # @return [Vedeu::Border]
25
- # @see Vedeu::DSL::Border
24
+ # @return [Vedeu::Borders::Border]
25
+ # @see Vedeu::Borders::DSL
26
26
  def border(name = nil, &block)
27
27
  fail Vedeu::Error::InvalidSyntax, 'block not given' unless block_given?
28
28
 
@@ -31,7 +31,7 @@ module Vedeu
31
31
  border_attrs = attributes.merge!(enabled: true,
32
32
  name: model_name)
33
33
 
34
- Vedeu::Border.build(border_attrs, &block).store
34
+ Vedeu::Borders::Border.build(border_attrs, &block).store
35
35
  end
36
36
 
37
37
  # Applies the default border to the interface.
@@ -43,7 +43,7 @@ module Vedeu
43
43
  # # ... some code
44
44
  # end
45
45
  #
46
- # @return [Vedeu::Border]
46
+ # @return [Vedeu::Borders::Border]
47
47
  def border!
48
48
  border do
49
49
  # adds default border
@@ -55,23 +55,23 @@ module Vedeu
55
55
  # @example
56
56
  # Vedeu.interface 'my_interface' do
57
57
  # geometry do
58
- # # ... see Vedeu::DSL::Geometry for DSL methods for geometries.
58
+ # # ... see Vedeu::Geometry::DSL for DSL methods for geometries.
59
59
  # end
60
60
  # end
61
61
  #
62
62
  # @param name [String] The name of the interface; this is already provided
63
63
  # when we define the interface or view, setting it here is just
64
- # mirroring functionality of {Vedeu::DSL::Geometry.geometry}.
64
+ # mirroring functionality of {Vedeu::Geometry::DSL.geometry}.
65
65
  # @param block [Proc]
66
66
  # @raise [Vedeu::Error::InvalidSyntax] The required block was not given.
67
- # @return [Vedeu::Geometry]
68
- # @see Vedeu::DSL::Geometry
67
+ # @return [Vedeu::Geometry::Geometry]
68
+ # @see Vedeu::Geometry::DSL
69
69
  def geometry(name = nil, &block)
70
70
  fail Vedeu::Error::InvalidSyntax, 'block not given' unless block_given?
71
71
 
72
72
  model_name = name ? name : model.name
73
73
 
74
- Vedeu::Geometry.build(name: model_name, &block).store
74
+ Vedeu::Geometry::Geometry.build(name: model_name, &block).store
75
75
  end
76
76
 
77
77
  end # Shared
@@ -1,6 +1,6 @@
1
1
  module Vedeu
2
2
 
3
- # Custom exceptions which Vedeu will raise in certain circumstances.
3
+ # Custom exceptions/errors which Vedeu will raise in certain circumstances.
4
4
  #
5
5
  module Error
6
6
 
@@ -73,7 +73,7 @@ module Vedeu
73
73
  # Raised when trying to access an interface column less than 1 or greater
74
74
  # than 12. Vedeu is hard-wired to a 12-column layout for the time being.
75
75
  #
76
- # @see Vedeu::Grid
76
+ # @see Vedeu::Geometry::Grid
77
77
  #
78
78
  class OutOfRange < StandardError
79
79
 
data/lib/vedeu/esc/esc.rb CHANGED
@@ -85,7 +85,7 @@ module Vedeu
85
85
 
86
86
  # @return [String]
87
87
  def last_character_position
88
- Vedeu::Position[Vedeu.height, Vedeu.width].to_s
88
+ Vedeu::Geometry::Position[Vedeu.height, Vedeu.width].to_s
89
89
  end
90
90
 
91
91
  end # Esc
@@ -0,0 +1,18 @@
1
+ module Vedeu
2
+
3
+ module Geometry
4
+
5
+ end # Geometry
6
+
7
+ end # Vedeu
8
+
9
+ require 'vedeu/geometry/area'
10
+ require 'vedeu/geometry/coordinate'
11
+ require 'vedeu/geometry/dimension'
12
+ require 'vedeu/geometry/dsl'
13
+ require 'vedeu/geometry/generic_coordinate'
14
+ require 'vedeu/geometry/geometry'
15
+ require 'vedeu/geometry/grid'
16
+ require 'vedeu/geometry/null'
17
+ require 'vedeu/geometry/position'
18
+ require 'vedeu/geometry/repository'
@@ -1,166 +1,176 @@
1
1
  module Vedeu
2
2
 
3
- # Define an area from dimensions or points.
4
- #
5
- class Area
6
-
7
- # @!attribute [r] y
8
- # @return [Fixnum] Returns the top coordinate of the interface.
9
- attr_reader :y
10
- alias_method :top, :y
11
-
12
- # @!attribute [r] yn
13
- # @return [Fixnum] Returns the bottom coordinate of the interface.
14
- attr_reader :yn
15
- alias_method :bottom, :yn
16
-
17
- # @!attribute [r] x
18
- # @return [Fixnum] Returns the left coordinate of the interface.
19
- attr_reader :x
20
- alias_method :left, :x
21
-
22
- # @!attribute [r] xn
23
- # @return [Fixnum] Returns the right coordinate of the interface.
24
- attr_reader :xn
25
- alias_method :right, :xn
26
-
27
- # @param attributes [Hash]
28
- # @option attributes y [Fixnum]
29
- # @option attributes yn [Fixnum]
30
- # @option attributes y_yn [Fixnum]
31
- # @option attributes y_default [Fixnum]
32
- # @option attributes x [Fixnum]
33
- # @option attributes xn [Fixnum]
34
- # @option attributes x_xn [Fixnum]
35
- # @option attributes x_default [Fixnum]
36
- # @option attributes options [Hash<Symbol => Boolean>]
37
- # @return [Vedeu::Area]
38
- def self.from_attributes(attributes = {})
39
- y_yn = Vedeu::Dimension.pair(d: attributes[:y],
40
- dn: attributes[:yn],
41
- d_dn: attributes[:y_yn],
42
- default: attributes[:y_default],
43
- maximised: attributes[:maximised],
44
- centred: attributes[:centred])
45
- x_xn = Vedeu::Dimension.pair(d: attributes[:x],
46
- dn: attributes[:xn],
47
- d_dn: attributes[:x_xn],
48
- default: attributes[:x_default],
49
- maximised: attributes[:maximised],
50
- centred: attributes[:centred])
51
-
52
- new(y: y_yn[0], yn: y_yn[-1], x: x_xn[0], xn: x_xn[-1])
53
- end
54
-
55
- # Returns a new instance of Vedeu::Area.
56
- #
57
- # @param y [Fixnum] The starting row/line position.
58
- # @param yn [Fixnum] The ending row/line position.
59
- # @param x [Fixnum] The starting column/character position.
60
- # @param xn [Fixnum] The ending column/character position.
61
- # @return [Vedeu::Area]
62
- def initialize(y:, yn:, x:, xn:)
63
- @y = y
64
- @yn = yn
65
- @x = x
66
- @xn = xn
67
- end
68
-
69
- # An object is equal when its values are the same.
70
- #
71
- # @param other [Vedeu::Area]
72
- # @return [Boolean]
73
- def eql?(other)
74
- self.class == other.class && y == other.y && yn == other.yn &&
75
- x == other.x && xn == other.xn
76
- end
77
- alias_method :==, :eql?
78
-
79
- # @return [Array<Fixnum>]
80
- def centre
81
- [centre_y, centre_x]
82
- end
83
-
84
- # @return [Fixnum]
85
- def centre_y
86
- (height / 2) + y
87
- end
88
-
89
- # @return [Fixnum]
90
- def centre_x
91
- (width / 2) + x
92
- end
93
-
94
- # @return [Fixnum]
95
- def height
96
- (y..yn).size
97
- end
98
-
99
- # @return [Fixnum]
100
- def width
101
- (x..xn).size
102
- end
103
-
104
- # Returns the row above the top by default.
105
- #
106
- # @example
107
- # `top` or `y` is 4.
108
- #
109
- # north # => 3
110
- # north(2) # => 2 (positive goes north)
111
- # north(-4) # => 8 (negative goes south)
112
- #
113
- # @param offset [Fixnum]
114
- # @return [Fixnum]
115
- def north(offset = 1)
116
- y - offset
117
- end
118
-
119
- # Returns the column after right by default.
120
- #
121
- # @example
122
- # `right` or `xn` is 19.
123
- #
124
- # east # => 20
125
- # east(2) # => 21 (positive goes east)
126
- # east(-4) # => 15 (negative goes west)
127
- #
128
- # @param offset [Fixnum]
129
- # @return [Fixnum]
130
- def east(offset = 1)
131
- xn + offset
132
- end
133
-
134
- # Returns the row below the bottom by default.
135
- #
136
- # @example
137
- # `bottom` or `yn` is 12.
138
- #
139
- # south # => 13
140
- # south(2) # => 14 (positive goes south)
141
- # south(-4) # => 8 (negative goes north)
142
- #
143
- # @param offset [Fixnum]
144
- # @return [Fixnum]
145
- def south(offset = 1)
146
- yn + offset
147
- end
3
+ module Geometry
148
4
 
149
- # Returns the column before left by default.
150
- #
151
- # @example
152
- # `left` or `x` is 8.
5
+ # Define an area from dimensions or points.
153
6
  #
154
- # west # => 7
155
- # west(2) # => 6 (positive goes west)
156
- # west(-4) # => 12 (negative goes east)
157
- #
158
- # @param offset [Fixnum]
159
- # @return [Fixnum]
160
- def west(offset = 1)
161
- x - offset
162
- end
163
-
164
- end # Area
7
+ class Area
8
+
9
+ # @!attribute [r] y
10
+ # @return [Fixnum] Returns the top coordinate of the interface.
11
+ attr_reader :y
12
+ alias_method :top, :y
13
+
14
+ # @!attribute [r] yn
15
+ # @return [Fixnum] Returns the bottom coordinate of the interface.
16
+ attr_reader :yn
17
+ alias_method :bottom, :yn
18
+
19
+ # @!attribute [r] x
20
+ # @return [Fixnum] Returns the left coordinate of the interface.
21
+ attr_reader :x
22
+ alias_method :left, :x
23
+
24
+ # @!attribute [r] xn
25
+ # @return [Fixnum] Returns the right coordinate of the interface.
26
+ attr_reader :xn
27
+ alias_method :right, :xn
28
+
29
+ # @param attributes [Hash]
30
+ # @option attributes y [Fixnum]
31
+ # @option attributes yn [Fixnum]
32
+ # @option attributes y_yn [Fixnum]
33
+ # @option attributes y_default [Fixnum]
34
+ # @option attributes x [Fixnum]
35
+ # @option attributes xn [Fixnum]
36
+ # @option attributes x_xn [Fixnum]
37
+ # @option attributes x_default [Fixnum]
38
+ # @option attributes options [Hash<Symbol => Boolean>]
39
+ # @return [Vedeu::Geometry::Area]
40
+ def self.from_attributes(attributes = {})
41
+ y_attributes = {
42
+ d: attributes[:y],
43
+ dn: attributes[:yn],
44
+ d_dn: attributes[:y_yn],
45
+ default: attributes[:y_default],
46
+ maximised: attributes[:maximised],
47
+ centred: attributes[:centred],
48
+ }
49
+ x_attributes = {
50
+ d: attributes[:x],
51
+ dn: attributes[:xn],
52
+ d_dn: attributes[:x_xn],
53
+ default: attributes[:x_default],
54
+ maximised: attributes[:maximised],
55
+ centred: attributes[:centred],
56
+ }
57
+ y_yn = Vedeu::Geometry::Dimension.pair(y_attributes)
58
+ x_xn = Vedeu::Geometry::Dimension.pair(x_attributes)
59
+
60
+ new(y: y_yn[0], yn: y_yn[-1], x: x_xn[0], xn: x_xn[-1])
61
+ end
62
+
63
+ # Returns a new instance of Vedeu::Area.
64
+ #
65
+ # @param y [Fixnum] The starting row/line position.
66
+ # @param yn [Fixnum] The ending row/line position.
67
+ # @param x [Fixnum] The starting column/character position.
68
+ # @param xn [Fixnum] The ending column/character position.
69
+ # @return [Vedeu::Geometry::Area]
70
+ def initialize(y:, yn:, x:, xn:)
71
+ @y = y
72
+ @yn = yn
73
+ @x = x
74
+ @xn = xn
75
+ end
76
+
77
+ # An object is equal when its values are the same.
78
+ #
79
+ # @param other [Vedeu::Geometry::Area]
80
+ # @return [Boolean]
81
+ def eql?(other)
82
+ self.class == other.class && y == other.y && yn == other.yn &&
83
+ x == other.x && xn == other.xn
84
+ end
85
+ alias_method :==, :eql?
86
+
87
+ # @return [Array<Fixnum>]
88
+ def centre
89
+ [centre_y, centre_x]
90
+ end
91
+
92
+ # @return [Fixnum]
93
+ def centre_y
94
+ (height / 2) + y
95
+ end
96
+
97
+ # @return [Fixnum]
98
+ def centre_x
99
+ (width / 2) + x
100
+ end
101
+
102
+ # @return [Fixnum]
103
+ def height
104
+ (y..yn).size
105
+ end
106
+
107
+ # @return [Fixnum]
108
+ def width
109
+ (x..xn).size
110
+ end
111
+
112
+ # Returns the row above the top by default.
113
+ #
114
+ # @example
115
+ # `top` or `y` is 4.
116
+ #
117
+ # north # => 3
118
+ # north(2) # => 2 (positive goes north)
119
+ # north(-4) # => 8 (negative goes south)
120
+ #
121
+ # @param offset [Fixnum]
122
+ # @return [Fixnum]
123
+ def north(offset = 1)
124
+ y - offset
125
+ end
126
+
127
+ # Returns the column after right by default.
128
+ #
129
+ # @example
130
+ # `right` or `xn` is 19.
131
+ #
132
+ # east # => 20
133
+ # east(2) # => 21 (positive goes east)
134
+ # east(-4) # => 15 (negative goes west)
135
+ #
136
+ # @param offset [Fixnum]
137
+ # @return [Fixnum]
138
+ def east(offset = 1)
139
+ xn + offset
140
+ end
141
+
142
+ # Returns the row below the bottom by default.
143
+ #
144
+ # @example
145
+ # `bottom` or `yn` is 12.
146
+ #
147
+ # south # => 13
148
+ # south(2) # => 14 (positive goes south)
149
+ # south(-4) # => 8 (negative goes north)
150
+ #
151
+ # @param offset [Fixnum]
152
+ # @return [Fixnum]
153
+ def south(offset = 1)
154
+ yn + offset
155
+ end
156
+
157
+ # Returns the column before left by default.
158
+ #
159
+ # @example
160
+ # `left` or `x` is 8.
161
+ #
162
+ # west # => 7
163
+ # west(2) # => 6 (positive goes west)
164
+ # west(-4) # => 12 (negative goes east)
165
+ #
166
+ # @param offset [Fixnum]
167
+ # @return [Fixnum]
168
+ def west(offset = 1)
169
+ x - offset
170
+ end
171
+
172
+ end # Area
173
+
174
+ end # Geometry
165
175
 
166
176
  end # Vedeu