vedeu 0.4.28 → 0.4.29

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: af28147191fb71a62c5dafcafdfc482ba5197f96
4
- data.tar.gz: ffba51b895e26f86fb0075b0880ee85dab52a31f
3
+ metadata.gz: 5054f0cadfac0fb38b0b9c4c800c3cd0f7aa08b7
4
+ data.tar.gz: a94e10fb79245068619c7cb78d4d6aaf5639e647
5
5
  SHA512:
6
- metadata.gz: b710ffa6a3f5b5cb01ba0bc88ec1b5b24d0e4261f14530d39588fc00595dda35cb9318b610636f16e2ac71775af986edc4bc2fa0b622e36551d6843e93b0e0ba
7
- data.tar.gz: cfa662925a0f62b56e942ff95ae0f8245cefb7384f27d00146378aa3eabd17c396cc7f565b637d88868c3f214ef96de403b2e37ecb4ed87d970ae66656a14cbc
6
+ metadata.gz: c8f6d315b3bcd9f768ff40508b00be0e2360e65c42c1402fbc133ba0e5dedb1f7ebe9a1201500cb25be4483b407d07a57b7b03fc45dd8d07f28949fa34885c7d
7
+ data.tar.gz: 467d9b7608d6ff0e057b33f3c86579c7204c905f61f237fd753d940e26f86fcb56ada657a1f1639c6a4cf5c8b0c76e843eff8f143293729faf59bfe3dca58fea
@@ -48,10 +48,6 @@ module Vedeu
48
48
  # @see Vedeu::Buffers.buffers
49
49
  def_delegators Vedeu::Buffers, :buffers
50
50
 
51
- # @!method canvas
52
- # @see Vedeu::Canvas.canvas
53
- def_delegators Vedeu::Canvas, :canvas
54
-
55
51
  # @!method configure
56
52
  # @see Vedeu::Configuration.configure
57
53
  # @!method configuration
@@ -21,13 +21,9 @@ module Vedeu
21
21
  end
22
22
  end
23
23
 
24
- Vedeu.bind(:_drb_retrieve_output_) do
25
- Vedeu.log(type: :drb, message: 'Retrieving output')
26
- Vedeu::VirtualBuffer.retrieve
27
- end
24
+ Vedeu.bind(:_drb_retrieve_output_) { Vedeu::VirtualBuffer.retrieve }
28
25
 
29
26
  Vedeu.bind(:_drb_store_output_) do |data|
30
- Vedeu.log(type: :drb, message: 'Storing output')
31
27
  Vedeu::VirtualBuffer.store(Vedeu::Terminal.virtual.output(data))
32
28
  end
33
29
 
@@ -174,19 +170,10 @@ module Vedeu
174
170
 
175
171
  # Clears the whole terminal space, or the named interface area to be cleared
176
172
  # if given.
177
- Vedeu.bind(:_clear_) do |name|
178
- Vedeu::Terminal.clear unless name
179
-
180
- Vedeu::Clear.clear(Vedeu.interfaces.by_name(name),
181
- clear_border: true, use_terminal_colours: true)
182
- end
173
+ Vedeu.bind(:_clear_) { |name| Vedeu::Clear.by_name(name) }
183
174
 
184
175
  # Clears the spaces occupied by the interfaces belonging to the named group.
185
- Vedeu.bind(:_clear_group_) do |group_name|
186
- Vedeu.groups.find(group_name).members.each do |interface_name|
187
- Vedeu.trigger(:_clear_, interface_name)
188
- end
189
- end
176
+ Vedeu.bind(:_clear_group_) { |name| Vedeu::Clear.by_group(name) }
190
177
 
191
178
  # Will cause all interfaces to refresh, or the named interface if given.
192
179
  #
@@ -1,5 +1,4 @@
1
1
  require_relative 'area'
2
- require_relative 'canvas'
3
2
  require_relative 'coordinate'
4
3
  require_relative 'dimension'
5
4
  require_relative 'geometry'
@@ -23,6 +23,37 @@ module Vedeu
23
23
  attr_reader :xn
24
24
  alias_method :right, :xn
25
25
 
26
+ # @param y [Fixnum]
27
+ # @param yn [Fixnum]
28
+ # @param y_yn [Fixnum]
29
+ # @param y_default [Fixnum]
30
+ # @param y_options [Hash<Symbol => Boolean>]
31
+ # @param x [Fixnum]
32
+ # @param xn [Fixnum]
33
+ # @param x_xn [Fixnum]
34
+ # @param x_default [Fixnum]
35
+ # @param x_options [Hash<Symbol => Boolean>]
36
+ # @return [Vedeu::Area]
37
+ def self.from_attributes(y:, yn:, y_yn:, y_default:,
38
+ x:, xn:, x_xn:, x_default:, options:)
39
+ y_yn = Vedeu::Dimension.pair({
40
+ d: y,
41
+ dn: yn,
42
+ d_dn: y_yn,
43
+ default: y_default,
44
+ options: options,
45
+ })
46
+ x_xn = Vedeu::Dimension.pair({
47
+ d: x,
48
+ dn: xn,
49
+ d_dn: x_xn,
50
+ default: x_default,
51
+ options: options,
52
+ })
53
+
54
+ from_dimensions(y_yn: y_yn, x_xn: x_xn)
55
+ end
56
+
26
57
  # @param y_yn [Array<Fixnum>]
27
58
  # @param x_xn [Array<Fixnum>]
28
59
  # @return [Vedeu::Area]
@@ -146,29 +146,17 @@ module Vedeu
146
146
 
147
147
  # @return [Vedeu::Area]
148
148
  def area
149
- @area = Vedeu::Area.from_dimensions(y_yn: y_yn, x_xn: x_xn)
150
- end
151
-
152
- # @return [Hash<Symbol => Fixnum, Hash]
153
- def height_attributes
154
- {
155
- d: _y,
156
- dn: _yn,
157
- d_dn: @height,
158
- default: Vedeu::Terminal.height,
159
- options: dimension_options,
160
- }
161
- end
162
-
163
- # @return [Hash<Symbol => Fixnum, Hash]
164
- def width_attributes
165
- {
166
- d: _x,
167
- dn: _xn,
168
- d_dn: @width,
169
- default: Vedeu::Terminal.width,
170
- options: dimension_options,
171
- }
149
+ @area = Vedeu::Area.from_attributes(
150
+ y: _y,
151
+ yn: _yn,
152
+ y_yn: @height,
153
+ y_default: Vedeu::Terminal.height,
154
+ x: _x,
155
+ xn: _xn,
156
+ x_xn: @width,
157
+ x_default: Vedeu::Terminal.width,
158
+ options: dimension_options,
159
+ )
172
160
  end
173
161
 
174
162
  # @return [Hash<Symbol => Boolean>]
@@ -179,16 +167,6 @@ module Vedeu
179
167
  }
180
168
  end
181
169
 
182
- # @return [Array<Fixnum>]
183
- def x_xn
184
- @x_xn = Vedeu::Dimension.pair(width_attributes)
185
- end
186
-
187
- # @return [Array<Fixnum>]
188
- def y_yn
189
- @y_yn = Vedeu::Dimension.pair(height_attributes)
190
- end
191
-
192
170
  # Returns the row/line start position for the interface.
193
171
  #
194
172
  # @return [Fixnum]
@@ -41,7 +41,7 @@ module Vedeu
41
41
  # @param child []
42
42
  # @return [void]
43
43
  def add(child)
44
- @streams = streams.add(child)
44
+ @_streams = @streams = collection.coerce(streams, self).add(child)
45
45
  end
46
46
 
47
47
  # Returns an array of all the characters with formatting for this line.
@@ -75,7 +75,7 @@ module Vedeu
75
75
 
76
76
  # @return [Vedeu::Streams]
77
77
  def streams
78
- collection.coerce(@streams, self)
78
+ @_streams ||= collection.coerce(@streams, self)
79
79
  end
80
80
 
81
81
  # Delegate to Vedeu::Interface#width if available.
@@ -21,6 +21,24 @@ module Vedeu
21
21
 
22
22
  class << self
23
23
 
24
+ # @param group [String]
25
+ # @return [void]
26
+ def by_group(group = nil)
27
+ return unless group
28
+
29
+ Vedeu.groups.find(group).members.each { |name| clear(name) }
30
+ end
31
+
32
+ # @param name [String]
33
+ # @return [void]
34
+ def by_name(name = nil)
35
+ return Vedeu::Terminal.clear unless name
36
+
37
+ clear(Vedeu.interfaces.by_name(name),
38
+ clear_border: true,
39
+ use_terminal_colours: true)
40
+ end
41
+
24
42
  # Clears the area defined by the interface.
25
43
  #
26
44
  # @return [Array|String]
@@ -11,15 +11,14 @@ module Vedeu
11
11
  colour.background
12
12
 
13
13
  else
14
- Vedeu::Background.new
15
- # @todo: Should this be: parent_background
14
+ parent_background
16
15
 
17
16
  end
18
17
  end
19
18
 
20
19
  # @return [Vedeu::Background]
21
20
  def background=(value)
22
- attributes[:background] = value
21
+ @attributes[:background] = value
23
22
  @background = colour.background = Vedeu::Background.coerce(value)
24
23
  end
25
24
 
@@ -30,7 +29,7 @@ module Vedeu
30
29
 
31
30
  # @return [Vedeu::Colour]
32
31
  def colour=(value)
33
- attributes[:colour] = value
32
+ @attributes[:colour] = value
34
33
  @colour = Vedeu::Colour.coerce(value)
35
34
  end
36
35
 
@@ -40,15 +39,14 @@ module Vedeu
40
39
  colour.foreground
41
40
 
42
41
  else
43
- Vedeu::Foreground.new
44
- # @todo: Should this be: parent_foreground
42
+ parent_foreground
45
43
 
46
44
  end
47
45
  end
48
46
 
49
47
  # @return [Vedeu::Foreground]
50
48
  def foreground=(value)
51
- attributes[:foreground] = value
49
+ @attributes[:foreground] = value
52
50
  @foreground = colour.foreground = Vedeu::Foreground.coerce(value)
53
51
  end
54
52
 
@@ -98,12 +96,6 @@ module Vedeu
98
96
  # model has previously set the colour and style, reverts back to that for
99
97
  # consistent formatting.
100
98
  #
101
- # @note
102
- # Aliasing #to_str to #to_s seems to reduce rendering time by around ~20ms
103
- # for normal sized (80x25) terminals.
104
- # @todo
105
- # Must investigate. (GL 2015-06-05)
106
- #
107
99
  # @return [String] An escape sequence with value interpolated.
108
100
  def to_s
109
101
  render_position { render_colour { render_style { value } } }
@@ -20,6 +20,8 @@ module Vedeu
20
20
  #
21
21
  # @return [Array<Array<Vedeu::Char>>|NilClass]
22
22
  def retrieve
23
+ Vedeu.log(type: :drb, message: 'Retrieving output')
24
+
23
25
  storage.pop
24
26
  end
25
27
 
@@ -27,6 +29,8 @@ module Vedeu
27
29
  #
28
30
  # @return [Array<Array<Vedeu::Char>>]
29
31
  def store(data)
32
+ Vedeu.log(type: :drb, message: 'Storing output')
33
+
30
34
  storage.unshift(data)
31
35
  end
32
36
 
@@ -110,8 +110,7 @@ module Vedeu
110
110
  #
111
111
  # @return [Array]
112
112
  def registered
113
- return [] if empty?
114
-
113
+ return [] if empty?
115
114
  return storage.keys if storage.is_a?(Hash)
116
115
  return storage.to_a if storage.is_a?(Set)
117
116
 
@@ -30,14 +30,6 @@ module Vedeu
30
30
  end
31
31
  end
32
32
 
33
- describe 'Vedeu::Canvas' do
34
- describe '.canvas' do
35
- subject { Vedeu.canvas }
36
-
37
- it { subject.must_be_instance_of(Vedeu::Canvas) }
38
- end
39
- end
40
-
41
33
  describe 'Vedeu::Configuration' do
42
34
  describe '.configure' do
43
35
  subject { Vedeu.configure }
@@ -16,9 +16,6 @@ module Vedeu
16
16
  let(:y) { 1 }
17
17
 
18
18
  before do
19
- Vedeu.borders.reset
20
- Vedeu.cursors.reset
21
- Vedeu.geometries.reset
22
19
  Vedeu::Cursor.new(name: 'move_with_border',
23
20
  ox: ox,
24
21
  oy: oy,
@@ -14,9 +14,6 @@ module Vedeu
14
14
  let(:boolean) { true }
15
15
 
16
16
  before do
17
- Vedeu.borders.reset
18
- Vedeu.buffers.reset
19
- Vedeu.interfaces.reset
20
17
  Vedeu.interface 'borders' do
21
18
  geometry do
22
19
  height 3
@@ -27,7 +24,11 @@ module Vedeu
27
24
  end
28
25
  end
29
26
  end
30
- after { Vedeu.interfaces.reset }
27
+ after do
28
+ Vedeu.borders.reset
29
+ Vedeu.buffers.reset
30
+ Vedeu.interfaces.reset
31
+ end
31
32
 
32
33
  describe 'alias methods' do
33
34
  it { instance.must_respond_to(:show_bottom) }
@@ -284,8 +284,6 @@ module Vedeu
284
284
  end
285
285
 
286
286
  describe '#show!' do
287
- after { Vedeu.interfaces.reset }
288
-
289
287
  subject {
290
288
  Vedeu.interface 'xenon' do
291
289
  show!
@@ -296,8 +294,6 @@ module Vedeu
296
294
  end
297
295
 
298
296
  describe '#hide!' do
299
- after { Vedeu.interfaces.reset }
300
-
301
297
  subject {
302
298
  Vedeu.interface 'xenon' do
303
299
  hide!
@@ -50,6 +50,7 @@ module Vedeu
50
50
  end
51
51
 
52
52
  context 'when the block is given' do
53
+ it { subject.must_equal([]) }
53
54
  end
54
55
  end
55
56
 
@@ -69,6 +70,7 @@ module Vedeu
69
70
  end
70
71
 
71
72
  context 'when the block is given' do
73
+ it { subject.must_equal([]) }
72
74
  end
73
75
  end
74
76
 
@@ -9,27 +9,25 @@ module Vedeu
9
9
  let(:_name) { 'position_validator' }
10
10
  let(:x) { 1 }
11
11
  let(:y) { 1 }
12
- let(:border) {
12
+ let(:enabled) { true }
13
+
14
+ before do
15
+ IO.console.stubs(:size).returns([15, 40])
13
16
  Vedeu::Border.new({
14
17
  name: _name,
15
18
  enabled: enabled,
16
- })
17
- }
18
- let(:enabled) { true }
19
- let(:geometry) {
19
+ }).store
20
20
  Vedeu::Geometry.new({
21
21
  name: _name,
22
22
  x: 5,
23
23
  xn: 35,
24
24
  y: 5,
25
25
  yn: 10
26
- })
27
- }
28
-
29
- before do
30
- IO.console.stubs(:size).returns([15, 40])
31
- Vedeu.borders.stubs(:by_name).returns(border)
32
- Vedeu.geometries.stubs(:by_name).returns(geometry)
26
+ }).store
27
+ end
28
+ after do
29
+ Vedeu.borders.reset
30
+ Vedeu.geometries.reset
33
31
  end
34
32
 
35
33
  describe '#initialize' do
@@ -10,9 +10,7 @@ module Vedeu
10
10
  let(:keymap) {}
11
11
  let(:repository) {}
12
12
 
13
- before do
14
- Vedeu.keymaps.reset
15
- end
13
+ before { Vedeu.keymaps.reset }
16
14
 
17
15
  describe '#initialize' do
18
16
  it { instance.must_be_instance_of(described) }
@@ -47,10 +45,7 @@ module Vedeu
47
45
  let(:key_test) { Key.new('a') { :do_something } }
48
46
  let(:keymap_test) { Keymap.new(name: 'test', keys: [key_test]) }
49
47
 
50
- before do
51
- Vedeu.keymaps.reset
52
- Vedeu.keymaps.store(keymap_test)
53
- end
48
+ before { Vedeu.keymaps.store(keymap_test) }
54
49
 
55
50
  it { subject.must_equal(true) }
56
51
  end
@@ -77,10 +72,7 @@ module Vedeu
77
72
  let(:key_test) { Key.new('a') { :do_something } }
78
73
  let(:keymap_test) { Keymap.new(name: 'test', keys: [key_test]) }
79
74
 
80
- before do
81
- Vedeu.keymaps.reset
82
- Vedeu.keymaps.store(keymap_test)
83
- end
75
+ before { Vedeu.keymaps.store(keymap_test) }
84
76
 
85
77
  it { subject.must_equal(false) }
86
78
  end
@@ -13,7 +13,10 @@ module Vedeu
13
13
  Vedeu.interface('lead') {}
14
14
  Vedeu.interface('bismuth') {}
15
15
  end
16
- after { Vedeu.interfaces.reset }
16
+ after do
17
+ Vedeu::Focus.reset
18
+ Vedeu.interfaces.reset
19
+ end
17
20
 
18
21
  describe '#add' do
19
22
  before do
@@ -13,8 +13,6 @@ module Vedeu
13
13
  }
14
14
 
15
15
  before do
16
- Vedeu.interfaces.reset
17
- Vedeu.borders.reset
18
16
  Vedeu.interface 'borders' do
19
17
  geometry do
20
18
  height 5
@@ -30,7 +28,10 @@ module Vedeu
30
28
  end
31
29
  end
32
30
  end
33
- after { Vedeu.interfaces.reset }
31
+ after do
32
+ Vedeu.interfaces.reset
33
+ Vedeu.borders.reset
34
+ end
34
35
 
35
36
  describe '.build' do
36
37
  subject {
@@ -100,9 +101,6 @@ module Vedeu
100
101
  let(:right) { false }
101
102
 
102
103
  before do
103
- Vedeu.interfaces.reset
104
- Vedeu.borders.reset
105
-
106
104
  Vedeu.interface('Border#bxbxnbybyn') do
107
105
  geometry do
108
106
  x 2
@@ -112,7 +110,6 @@ module Vedeu
112
110
  end
113
111
  end
114
112
  end
115
- after { Vedeu.interfaces.reset }
116
113
 
117
114
  describe '#bx' do
118
115
  subject { instance.bx }
@@ -413,9 +410,6 @@ module Vedeu
413
410
  let(:visibility) { true }
414
411
 
415
412
  before do
416
- Vedeu.interfaces.reset
417
- Vedeu.borders.reset
418
-
419
413
  Vedeu.interface('Border#render') do
420
414
  geometry do
421
415
  x 1
@@ -426,7 +420,6 @@ module Vedeu
426
420
  visible(visibility)
427
421
  end
428
422
  end
429
- after { Vedeu.interfaces.reset }
430
423
 
431
424
  subject { instance.render }
432
425
 
@@ -7,11 +7,7 @@ module Vedeu
7
7
  let(:described) { Vedeu::Clear }
8
8
  let(:instance) { described.new(interface, options) }
9
9
  let(:interface) { Vedeu::Interface.new(name: 'xenon', visible: visible) }
10
- let(:options) {
11
- {
12
-
13
- }
14
- }
10
+ let(:options) { {} }
15
11
  let(:visible) { true }
16
12
  let(:drb) { false }
17
13
 
@@ -21,6 +17,10 @@ module Vedeu
21
17
  Vedeu::Configuration.stubs(:drb?).returns(drb)
22
18
  Vedeu.renderers.stubs(:render)
23
19
  end
20
+ after do
21
+ Vedeu.borders.reset
22
+ Vedeu.geometries.reset
23
+ end
24
24
 
25
25
  describe '#initialize' do
26
26
  it { instance.must_be_instance_of(described) }
@@ -32,6 +32,18 @@ module Vedeu
32
32
  it { described.must_respond_to(:render) }
33
33
  end
34
34
 
35
+ # describe '.by_group' do
36
+ # subject { described.by_group(group) }
37
+
38
+ # it { skip }
39
+ # end
40
+
41
+ # describe '.by_name' do
42
+ # subject { described.by_name(_name) }
43
+
44
+ # it { skip }
45
+ # end
46
+
35
47
  describe '.clear' do
36
48
  subject { described.clear(interface, options) }
37
49
 
@@ -6,7 +6,10 @@ module Vedeu
6
6
 
7
7
  let(:described) { Vedeu::Viewport }
8
8
  let(:instance) { described.new(interface) }
9
- let(:interface) {
9
+ let(:interface) { Vedeu.interfaces.by_name('lithium') }
10
+ let(:visibility) { true }
11
+
12
+ before do
10
13
  Vedeu.interface 'lithium' do
11
14
  geometry do
12
15
  height 3
@@ -22,8 +25,8 @@ module Vedeu
22
25
  end
23
26
  visible(visibility)
24
27
  end
25
- }
26
- let(:visibility) { true }
28
+ end
29
+ after { Vedeu.interfaces.reset }
27
30
 
28
31
  describe '#initialize' do
29
32
  it { instance.must_be_instance_of(described) }
@@ -175,13 +175,10 @@ module Vedeu
175
175
 
176
176
  context 'when there are models stored in the repository' do
177
177
  before do
178
- Vedeu.interfaces.reset
179
178
  Vedeu.interface('hydrogen') {}
180
179
  Vedeu.interface('helium') {}
181
180
  end
182
- after do
183
- Vedeu.interfaces.reset
184
- end
181
+ after { Vedeu.interfaces.reset }
185
182
 
186
183
  subject { Vedeu.interfaces.inspect }
187
184
 
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'vedeu'
7
- spec.version = '0.4.28'
7
+ spec.version = '0.4.29'
8
8
  spec.authors = ['Gavin Laking']
9
9
  spec.email = ['gavinlaking@gmail.com']
10
10
  spec.summary = 'A terminal case of wonderland.'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vedeu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.28
4
+ version: 0.4.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Laking
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-16 00:00:00.000000000 Z
11
+ date: 2015-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -340,7 +340,6 @@ files:
340
340
  - lib/vedeu/events/trigger.rb
341
341
  - lib/vedeu/geometry/all.rb
342
342
  - lib/vedeu/geometry/area.rb
343
- - lib/vedeu/geometry/canvas.rb
344
343
  - lib/vedeu/geometry/coordinate.rb
345
344
  - lib/vedeu/geometry/dimension.rb
346
345
  - lib/vedeu/geometry/geometry.rb
@@ -472,7 +471,6 @@ files:
472
471
  - test/lib/vedeu/events/event_test.rb
473
472
  - test/lib/vedeu/events/trigger_test.rb
474
473
  - test/lib/vedeu/geometry/area_test.rb
475
- - test/lib/vedeu/geometry/canvas_test.rb
476
474
  - test/lib/vedeu/geometry/coordinate_test.rb
477
475
  - test/lib/vedeu/geometry/dimension_test.rb
478
476
  - test/lib/vedeu/geometry/geometry_test.rb
@@ -627,7 +625,6 @@ test_files:
627
625
  - test/lib/vedeu/events/event_test.rb
628
626
  - test/lib/vedeu/events/trigger_test.rb
629
627
  - test/lib/vedeu/geometry/area_test.rb
630
- - test/lib/vedeu/geometry/canvas_test.rb
631
628
  - test/lib/vedeu/geometry/coordinate_test.rb
632
629
  - test/lib/vedeu/geometry/dimension_test.rb
633
630
  - test/lib/vedeu/geometry/geometry_test.rb
@@ -1,84 +0,0 @@
1
- module Vedeu
2
-
3
- # The size of the terminal is a limitation. Defining a canvas means we have
4
- # more space to 'do stuff'.
5
- class Canvas
6
-
7
- include Singleton
8
-
9
- # @!attribute [r] yn
10
- # @return [Fixnum]
11
- attr_reader :yn
12
- alias_method :bottom, :yn
13
- alias_method :height, :yn
14
-
15
- # @!attribute [r] xn
16
- # @return [Fixnum]
17
- attr_reader :xn
18
- alias_method :right, :xn
19
- alias_method :width, :xn
20
-
21
- # @return [Vedeu::Canvas]
22
- def self.canvas
23
- instance
24
- end
25
-
26
- # @param yn [Fixnum]
27
- # @param xn [Fixnum]
28
- # @return [Vedeu::Canvas]
29
- def configure(yn, xn)
30
- @yn = yn
31
- @xn = xn
32
-
33
- self
34
- end
35
-
36
- # @return [Array]
37
- def c
38
- [cy, cx]
39
- end
40
- alias_method :centre, :c
41
-
42
- # @return [Fixnum]
43
- def cy
44
- (height / 2) + y
45
- end
46
- alias_method :centre_y, :cy
47
-
48
- # @return [Fixnum]
49
- def cx
50
- (width / 2) + x
51
- end
52
- alias_method :centre_x, :cx
53
-
54
- # @return [Fixnum]
55
- def o
56
- 1
57
- end
58
- alias_method :origin, :o
59
-
60
- # @return [Fixnum]
61
- def height
62
- (y..yn).size
63
- end
64
-
65
- # @return [Fixnum]
66
- def width
67
- (x..xn).size
68
- end
69
-
70
- # @return [Fixnum]
71
- def y
72
- 1
73
- end
74
- alias_method :top, :y
75
-
76
- # @return [Fixnum]
77
- def x
78
- 1
79
- end
80
- alias_method :left, :x
81
-
82
- end # Canvas
83
-
84
- end # Vedeu
@@ -1,74 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
-
5
- describe Canvas do
6
-
7
- let(:described) { Vedeu::Canvas }
8
- let(:instance) { described.canvas }
9
- let(:yn) { 25 }
10
- let(:xn) { 80 }
11
-
12
- before { instance.configure(yn, xn) }
13
-
14
- describe '.canvas' do
15
- it { instance.must_be_instance_of(described) }
16
- end
17
-
18
- describe '#configure' do
19
- it { instance.must_be_instance_of(described) }
20
- end
21
-
22
- describe '#c' do
23
- it { instance.c.must_equal([13, 41]) }
24
- it { instance.must_respond_to(:centre) }
25
- end
26
-
27
- describe '#cy' do
28
- it { instance.cy.must_equal(13) }
29
- it { instance.must_respond_to(:centre_y) }
30
- end
31
-
32
- describe '#cx' do
33
- it { instance.cx.must_equal(41) }
34
- it { instance.must_respond_to(:centre_x) }
35
- end
36
-
37
- describe '#o' do
38
- it { instance.o.must_equal(1) }
39
- it { instance.must_respond_to(:origin) }
40
- end
41
-
42
- describe '#height' do
43
- it { instance.height.must_equal(25) }
44
- end
45
-
46
- describe '#width' do
47
- it { instance.width.must_equal(80) }
48
- end
49
-
50
- describe '#y' do
51
- it { instance.y.must_equal(1) }
52
- it { instance.must_respond_to(:top) }
53
- end
54
-
55
- describe '#yn' do
56
- it { instance.yn.must_equal(25) }
57
- it { instance.must_respond_to(:bottom) }
58
- it { instance.must_respond_to(:height) }
59
- end
60
-
61
- describe '#x' do
62
- it { instance.x.must_equal(1) }
63
- it { instance.must_respond_to(:left) }
64
- end
65
-
66
- describe '#xn' do
67
- it { instance.xn.must_equal(80) }
68
- it { instance.must_respond_to(:right) }
69
- it { instance.must_respond_to(:width) }
70
- end
71
-
72
- end # Canvas
73
-
74
- end # Vedeu