glimmer-dsl-swt 4.20.13.6 → 4.20.13.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +17 -0
  3. data/README.md +5 -5
  4. data/VERSION +1 -1
  5. data/docs/reference/GLIMMER_SAMPLES.md +13 -0
  6. data/docs/reference/GLIMMER_STYLE_GUIDE.md +2 -1
  7. data/glimmer-dsl-swt.gemspec +0 -0
  8. data/lib/glimmer/rake_task/scaffold.rb +14 -14
  9. data/lib/glimmer/swt/custom/code_text.rb +4 -4
  10. data/lib/glimmer/swt/custom/shape.rb +1 -1
  11. data/lib/glimmer/swt/image_proxy.rb +1 -1
  12. data/samples/elaborate/calculator.rb +2 -2
  13. data/samples/elaborate/contact_manager.rb +2 -2
  14. data/samples/elaborate/klondike_solitaire.rb +93 -0
  15. data/samples/elaborate/klondike_solitaire/model/column_pile.rb +60 -0
  16. data/samples/elaborate/klondike_solitaire/model/dealing_pile.rb +33 -0
  17. data/samples/elaborate/klondike_solitaire/model/dealt_pile.rb +25 -0
  18. data/samples/elaborate/klondike_solitaire/model/foundation_pile.rb +40 -0
  19. data/samples/elaborate/klondike_solitaire/model/game.rb +37 -0
  20. data/samples/elaborate/klondike_solitaire/model/playing_card.rb +86 -0
  21. data/samples/elaborate/klondike_solitaire/view/action_panel.rb +30 -0
  22. data/samples/elaborate/klondike_solitaire/view/column_pile.rb +66 -0
  23. data/samples/elaborate/klondike_solitaire/view/dealing_pile.rb +36 -0
  24. data/samples/elaborate/klondike_solitaire/view/dealt_pile.rb +38 -0
  25. data/samples/elaborate/klondike_solitaire/view/empty_playing_card.rb +33 -0
  26. data/samples/elaborate/klondike_solitaire/view/foundation_pile.rb +59 -0
  27. data/samples/elaborate/klondike_solitaire/view/hidden_playing_card.rb +26 -0
  28. data/samples/elaborate/klondike_solitaire/view/playing_card.rb +35 -0
  29. data/samples/elaborate/klondike_solitaire/view/tableau.rb +41 -0
  30. data/samples/elaborate/login.rb +2 -2
  31. data/samples/elaborate/mandelbrot_fractal.rb +12 -12
  32. data/samples/elaborate/meta_sample.rb +2 -2
  33. data/samples/elaborate/metronome.rb +2 -2
  34. data/samples/elaborate/stock_ticker.rb +8 -8
  35. data/samples/elaborate/tetris.rb +4 -4
  36. data/samples/elaborate/tetris/view/bevel.rb +2 -2
  37. data/samples/elaborate/tetris/view/score_lane.rb +2 -2
  38. data/samples/elaborate/tic_tac_toe.rb +6 -6
  39. data/samples/elaborate/timer.rb +4 -4
  40. data/samples/elaborate/weather.rb +4 -4
  41. data/samples/hello/hello_button.rb +2 -2
  42. data/samples/hello/hello_c_combo.rb +2 -2
  43. data/samples/hello/hello_canvas.rb +4 -4
  44. data/samples/hello/hello_canvas_animation.rb +2 -2
  45. data/samples/hello/hello_canvas_data_binding.rb +2 -2
  46. data/samples/hello/hello_checkbox.rb +2 -2
  47. data/samples/hello/hello_checkbox_group.rb +2 -2
  48. data/samples/hello/hello_code_text.rb +2 -2
  49. data/samples/hello/hello_color_dialog.rb +2 -2
  50. data/samples/hello/hello_combo.rb +2 -2
  51. data/samples/hello/hello_computed.rb +14 -22
  52. data/samples/hello/hello_cool_bar.rb +2 -2
  53. data/samples/hello/hello_cursor.rb +2 -2
  54. data/samples/hello/hello_custom_shape.rb +2 -2
  55. data/samples/hello/hello_custom_shell.rb +2 -2
  56. data/samples/hello/hello_custom_widget.rb +4 -4
  57. data/samples/hello/hello_date_time.rb +2 -2
  58. data/samples/hello/hello_directory_dialog.rb +2 -2
  59. data/samples/hello/hello_file_dialog.rb +2 -2
  60. data/samples/hello/hello_font_dialog.rb +2 -2
  61. data/samples/hello/hello_group.rb +2 -2
  62. data/samples/hello/hello_list_multi_selection.rb +2 -2
  63. data/samples/hello/hello_list_single_selection.rb +2 -2
  64. data/samples/hello/hello_progress_bar.rb +2 -2
  65. data/samples/hello/hello_radio.rb +2 -2
  66. data/samples/hello/hello_radio_group.rb +2 -2
  67. data/samples/hello/hello_scale.rb +2 -2
  68. data/samples/hello/hello_spinner.rb +2 -2
  69. data/samples/hello/hello_table.rb +2 -2
  70. data/samples/hello/hello_text.rb +2 -2
  71. data/samples/hello/hello_tool_bar.rb +2 -2
  72. data/samples/hello/hello_tray_item.rb +2 -2
  73. data/samples/hello/hello_tree.rb +4 -4
  74. metadata +18 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9d49b7c8377c625821d745fe902daa4f2120a2f913aac28cc180a541b4d5e7b2
4
- data.tar.gz: fa0600350138e85e73ddd25487890357080f0a7c5bf3d329b374239690ac9cec
3
+ metadata.gz: 982e9293313f88fc19f63d148e0b59b1dcda227e25bc47d9eb07377359b90084
4
+ data.tar.gz: c90ad4be0b5ebf2aaa28b5b0376934e518f7fbe878a3ecb4a37982fa5feac554
5
5
  SHA512:
6
- metadata.gz: d29652357d6e5cbcb667b69584f6bc50551d5a04733e799522945ec38a36456c6d2dadbe48c44f0646b46edeebc95f43f5b37e56701b6067fa18cf17adf65c64
7
- data.tar.gz: 383f1cbae1582175c8047f25e6a03889f46099cda58d9c885d6a5a820bfc2fc3675e19cc3bda4f6760f8dd905814a69dafa54d230b62f7f9a2a7937e88a2b2b1
6
+ metadata.gz: 6946dfd8d245a2ef28df3df0c7eb3b74213f4c912c69a6de5ce0bd4f42d7b69f87671df845a816c532d6b580bd0f9da535639368aba6ed0abd76d689c66ded07
7
+ data.tar.gz: c630515458b13ab4b08c6c662c27759c9a0adb8903e5f0a5e20aba958792d3949f48ae47d9849ffddbe52d4a7b33887955979d76ffe6223871cc51e8f844c443
data/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Change Log
2
2
 
3
+ ### 4.20.13.10
4
+
5
+ - Update Glimmer Style Guide, scaffolding, and samples to have `before_body` and `after_body` in custom widgets/shells/shapes always take a `do; end` block since they contain logic not visuals
6
+
7
+ ### 4.20.13.9
8
+
9
+ - Update Klondike Solitaire to have playing card suit symbols and avoid clipping of cards on the boundaries
10
+
11
+ ### 4.20.13.8
12
+
13
+ - Glimmer Klondike Solitaire elaborate sample
14
+
15
+ ### 4.20.13.7
16
+
17
+ - Support accepting ImageProxy objects in Canvas Shape DSL (not just image paths)
18
+ - Fix issue in ImageProxy not flattening args before selecting file path
19
+
3
20
  ### 4.20.13.6
4
21
 
5
22
  - Ensure a dragged shape can be dropped back into a parent it originally belonged to without it counting as a drop into itself.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for SWT 4.20.13.6
1
+ # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for SWT 4.20.13.10
2
2
  ## JRuby Desktop Development GUI Framework
3
3
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-swt.svg)](http://badge.fury.io/rb/glimmer-dsl-swt)
4
4
  [![Travis CI](https://travis-ci.com/AndyObtiva/glimmer-dsl-swt.svg?branch=master)](https://travis-ci.com/github/AndyObtiva/glimmer-dsl-swt)
@@ -15,7 +15,7 @@
15
15
  [<img src="https://covers.oreillystatic.com/images/9780596519650/lrg.jpg" width=105 /><br />
16
16
  Featured in JRuby Cookbook](http://shop.oreilly.com/product/9780596519650.do) and [Chalmers/Gothenburg University Software Engineering Master's Lecture Material](http://www.cse.chalmers.se/~bergert/slides/guest_lecture_DSLs.pdf)
17
17
 
18
- [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.20.13.6 includes [SWT 4.20](https://download.eclipse.org/eclipse/downloads/drops4/R-4.20-202106111600/), which was released on June 11, 2021. Gem version numbers are in sync with the SWT library versions. The first two digits represent the SWT version number. The last two digits represent the minor and patch versions of Glimmer DSL for SWT. Note that SWT now supports AARCH64 on Mac and Linux, but it is not fully tested in Glimmer DSL for SWT yet, so deem its support experimental for the time being without guarantees for functionality until declared otherwise (report any issues you may encounter).
18
+ [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.20.13.10 includes [SWT 4.20](https://download.eclipse.org/eclipse/downloads/drops4/R-4.20-202106111600/), which was released on June 11, 2021. Gem version numbers are in sync with the SWT library versions. The first two digits represent the SWT version number. The last two digits represent the minor and patch versions of Glimmer DSL for SWT. Note that SWT now supports AARCH64 on Mac and Linux, but it is not fully tested in Glimmer DSL for SWT yet, so deem its support experimental for the time being without guarantees for functionality until declared otherwise (report any issues you may encounter).
19
19
 
20
20
  **Starting in version 4.20.0.0, [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) comes with the new [***Shine***](/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#shine) syntax** for highly intuitive and visually expressive View/Model Attribute Mapping, relying on `<=>` for bidirectional (two-way) data-binding and `<=` for unidirectional (one-way) data-binding, providing an alternative to the `bind` keyword (keep in mind that it is still a beta, so default back to `bind` whenever needed).
21
21
 
@@ -326,7 +326,7 @@ jgem install glimmer-dsl-swt
326
326
 
327
327
  Or this command if you want a specific version:
328
328
  ```
329
- jgem install glimmer-dsl-swt -v 4.20.13.6
329
+ jgem install glimmer-dsl-swt -v 4.20.13.10
330
330
  ```
331
331
 
332
332
  `jgem` is JRuby's version of `gem` command.
@@ -354,7 +354,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
354
354
 
355
355
  Add the following to `Gemfile`:
356
356
  ```
357
- gem 'glimmer-dsl-swt', '~> 4.20.13.6'
357
+ gem 'glimmer-dsl-swt', '~> 4.20.13.10'
358
358
  ```
359
359
 
360
360
  And, then run:
@@ -375,7 +375,7 @@ glimmer
375
375
  ```
376
376
 
377
377
  ```
378
- Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.20.13.6
378
+ Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.20.13.10
379
379
 
380
380
  Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
381
381
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.20.13.6
1
+ 4.20.13.10
@@ -62,6 +62,7 @@
62
62
  - [Tic Tac Toe](#tic-tac-toe)
63
63
  - [Contact Manager](#contact-manager)
64
64
  - [Glimmer Tetris](#glimmer-tetris)
65
+ - [Klondike Solitaire](#klondike-solitaire)
65
66
  - [Mandelbrot Fractal](#mandelbrot-fractal)
66
67
  - [Stock Ticker](#stock-ticker)
67
68
  - [Metronome](#metronome)
@@ -1098,6 +1099,18 @@ Code:
1098
1099
 
1099
1100
  ![Tetris Help Menu](/images/glimmer-tetris-help-menu.png)
1100
1101
 
1102
+ #### Klondike Solitaire
1103
+
1104
+ This sample demonstrates how to build an interactive card game with MVC architecture, custom-shell/custom-widgets, data-binding, observers, and drag & drop.
1105
+
1106
+ Code:
1107
+
1108
+ [samples/elaborate/klondike_solitaire.rb](/samples/elaborate/klondike_solitaire.rb)
1109
+
1110
+ ![Tetris](/images/glimmer-klondike-solitaire.png)
1111
+
1112
+ ![Tetris](/images/glimmer-klondike-solitaire-played.png)
1113
+
1101
1114
  #### Mandelbrot Fractal
1102
1115
 
1103
1116
  This sample demonstrates how to render canvas graphics with multi-threaded processing taking advantage of all CPU cores and doing background processing of images.
@@ -10,6 +10,7 @@
10
10
  - Widget listeners are always declared starting with `on_` prefix and affixing listener event method name afterwards in underscored lowercase form. Their multi-line blocks rely on the `do; end` style.
11
11
  - Widget listeners are always followed by a block using curly braces (Only when declared in DSL. When invoked on widget object directly outside of GUI declarations, standard Ruby conventions apply)
12
12
  - Data-binding is done via `bind` keyword, which always takes arguments wrapped in parentheses
13
- - Custom widget `body`, `before_body`, and `after_body` blocks open their blocks and close them with curly braces.
13
+ - Custom widget/shell/shape `body` blocks open and close with curly braces.
14
+ - Custom widget/shell/shape `before_body` and `after_body` blocks are declared as `do; end` blocks.
14
15
  - Custom widgets receive additional keyword arguments called options, which come after the SWT styles.
15
16
  - Pure logic multi-line blocks that do not constitute GUI DSL view elements (such as `Thread.new`, `loop`, `each` and `observe` blocks) rely on the `do; end` style to clearly separate logic code from view code.
Binary file
@@ -607,7 +607,7 @@ module Glimmer
607
607
 
608
608
  if %i[gem app desktopify].include?(shell_type)
609
609
  custom_shell_file_content += <<-MULTI_LINE_STRING
610
- before_body {
610
+ before_body do
611
611
  Display.app_name = '#{shell_type == :gem ? human_name(custom_shell_name) : human_name(namespace)}'
612
612
  Display.app_version = VERSION
613
613
  @display = display {
@@ -618,13 +618,13 @@ module Glimmer
618
618
  #{shell_type == :desktopify ? 'display_about_dialog' : 'display_preferences_dialog'}
619
619
  }
620
620
  }
621
- }
621
+ end
622
622
  MULTI_LINE_STRING
623
623
  else
624
624
  custom_shell_file_content += <<-MULTI_LINE_STRING
625
- # before_body {
625
+ # before_body do
626
626
  #
627
- # }
627
+ # end
628
628
  MULTI_LINE_STRING
629
629
  end
630
630
 
@@ -632,9 +632,9 @@ module Glimmer
632
632
 
633
633
  ## Use after_body block to setup observers for widgets in body
634
634
  #
635
- # after_body {
635
+ # after_body do
636
636
  #
637
- # }
637
+ # end
638
638
 
639
639
  ## Add widget content inside custom shell body
640
640
  ## Top-most widget must be a shell or another custom shell
@@ -767,15 +767,15 @@ end
767
767
  ## Use before_body block to pre-initialize variables to use in body
768
768
  #
769
769
  #
770
- # before_body {
770
+ # before_body do
771
771
  #
772
- # }
772
+ # end
773
773
 
774
774
  ## Use after_body block to setup observers for widgets in body
775
775
  #
776
- # after_body {
776
+ # after_body do
777
777
  #
778
- # }
778
+ # end
779
779
 
780
780
  ## Add widget content under custom widget body
781
781
  ##
@@ -817,15 +817,15 @@ end
817
817
  ## Use before_body block to pre-initialize variables to use in body
818
818
  #
819
819
  #
820
- # before_body {
820
+ # before_body do
821
821
  #
822
- # }
822
+ # end
823
823
 
824
824
  ## Use after_body block to setup observers for shapes in body
825
825
  #
826
- # after_body {
826
+ # after_body do
827
827
  #
828
- # }
828
+ # end
829
829
 
830
830
  ## Add shape content under custom shape body
831
831
  #
@@ -121,7 +121,7 @@ module Glimmer
121
121
  @line_numbers_styled_text_proxy.content(&block)
122
122
  end
123
123
 
124
- before_body {
124
+ before_body do
125
125
  require 'rouge'
126
126
  require 'ext/rouge/themes/glimmer'
127
127
  @swt_style = swt_style == 0 ? [:border, :multi, :v_scroll, :h_scroll] : swt_style
@@ -132,11 +132,11 @@ module Glimmer
132
132
  @lines_width = lines[:width]
133
133
  end
134
134
  @dsl_mode = true
135
- }
135
+ end
136
136
 
137
- after_body {
137
+ after_body do
138
138
  @dsl_mode = nil
139
- }
139
+ end
140
140
 
141
141
  body {
142
142
  if lines
@@ -405,7 +405,7 @@ module Glimmer
405
405
  end
406
406
  if @name == 'image'
407
407
  if @args.first.is_a?(::String)
408
- @args[0] = ImageProxy.new(@args[0])
408
+ @args[0] = ImageProxy.create(@args[0])
409
409
  end
410
410
  if @args.first.is_a?(ImageProxy)
411
411
  @image = @args[0] = @args[0].swt_image
@@ -74,8 +74,8 @@ module Glimmer
74
74
  end
75
75
  options = @args.last.is_a?(Hash) ? @args.delete_at(-1) : {}
76
76
  options[:swt_image] = @args.first if @args.size == 1 && @args.first.is_a?(Image)
77
- @file_path = @args.first if @args.first.is_a?(String)
78
77
  @args = @args.first if @args.size == 1 && @args.first.is_a?(Array)
78
+ @file_path = @args.first if @args.first.is_a?(String)
79
79
  if options&.keys&.include?(:swt_image)
80
80
  @swt_image = options[:swt_image]
81
81
  @original_image_data = @image_data = @swt_image.image_data
@@ -15,7 +15,7 @@ class Calculator
15
15
 
16
16
  attr_reader :presenter
17
17
 
18
- before_body {
18
+ before_body do
19
19
  @presenter = Model::Presenter.new
20
20
 
21
21
  Display.setAppName('Glimmer Calculator')
@@ -30,7 +30,7 @@ class Calculator
30
30
  display_about_dialog
31
31
  }
32
32
  }
33
- }
33
+ end
34
34
 
35
35
  body {
36
36
  shell {
@@ -26,10 +26,10 @@ require_relative "contact_manager/contact_manager_presenter"
26
26
  class ContactManager
27
27
  include Glimmer::UI::CustomShell
28
28
 
29
- before_body {
29
+ before_body do
30
30
  @contact_manager_presenter = ContactManagerPresenter.new
31
31
  @contact_manager_presenter.list
32
- }
32
+ end
33
33
 
34
34
  body {
35
35
  shell {
@@ -0,0 +1,93 @@
1
+ require 'glimmer-dsl-swt'
2
+
3
+ require_relative 'klondike_solitaire/model/game'
4
+
5
+ require_relative 'klondike_solitaire/view/action_panel'
6
+ require_relative 'klondike_solitaire/view/tableau'
7
+
8
+ class KlondikeSolitaire
9
+ include Glimmer::UI::CustomShell
10
+
11
+ PLAYING_CARD_WIDTH = 50
12
+ PLAYING_CARD_HEIGHT = 80
13
+ PLAYING_CARD_SPACING = 5
14
+ MARGIN = 15
15
+ TABLEAU_WIDTH = 2*MARGIN + 7*(PLAYING_CARD_WIDTH + PLAYING_CARD_SPACING)
16
+ TABLEAU_HEIGHT = 400
17
+
18
+ before_body do
19
+ @game = Model::Game.new
20
+ Display.app_name = 'Glimmer Klondike Solitaire'
21
+ @display = display {
22
+ on_about {
23
+ display_about_dialog
24
+ }
25
+ on_preferences {
26
+ display_about_dialog
27
+ }
28
+ }
29
+ end
30
+
31
+ body {
32
+ shell(:no_resize) {
33
+ row_layout(:vertical) {
34
+ fill true
35
+ center true
36
+ margin_width 0
37
+ margin_height 0
38
+ margin_top 15
39
+ }
40
+ minimum_size TABLEAU_WIDTH, TABLEAU_HEIGHT
41
+ text "Glimmer Klondike Solitaire"
42
+ background :dark_green
43
+
44
+ action_panel(game: @game)
45
+ tableau(game: @game) {
46
+ layout_data {
47
+ width TABLEAU_WIDTH
48
+ height TABLEAU_HEIGHT
49
+ }
50
+ }
51
+
52
+ menu_bar {
53
+ menu {
54
+ text '&Game'
55
+ menu_item {
56
+ text '&Restart'
57
+ accelerator (OS.mac? ? :command : :ctrl), :r
58
+
59
+ on_widget_selected {
60
+ @game.restart!
61
+ }
62
+ }
63
+ menu_item {
64
+ text 'E&xit'
65
+ accelerator :alt, :f4
66
+
67
+ on_widget_selected {
68
+ body_root.close
69
+ }
70
+ }
71
+ }
72
+ menu {
73
+ text '&Help'
74
+ menu_item {
75
+ text '&About...'
76
+ on_widget_selected {
77
+ display_about_dialog
78
+ }
79
+ }
80
+ }
81
+ }
82
+ }
83
+ }
84
+
85
+ def display_about_dialog
86
+ message_box(body_root) {
87
+ text 'About'
88
+ message "Glimmer Klondike Solitaire\nGlimmer DSL for SWT Elaborate Sample"
89
+ }.open
90
+ end
91
+ end
92
+
93
+ KlondikeSolitaire.launch
@@ -0,0 +1,60 @@
1
+ class KlondikeSolitaire
2
+ module Model
3
+ class ColumnPile
4
+ include Glimmer::DataBinding::ObservableModel
5
+ attr_reader :count
6
+
7
+ def initialize(game, count)
8
+ @game = game
9
+ @count = count
10
+ reset!
11
+ end
12
+
13
+ def reset!
14
+ playing_cards.clear
15
+ populate!(count.times.map { @game.deck.pop })
16
+ notify_observers(:playing_cards)
17
+ end
18
+
19
+ # this method does not validate
20
+ def populate!(new_playing_cards)
21
+ new_playing_cards.each_with_index do |playing_card, index|
22
+ playing_card.hidden = true if index < (new_playing_cards.size - 1)
23
+ playing_cards.push(playing_card)
24
+ end
25
+ end
26
+
27
+ # this method validates that playing card fits at the bottom of the column (opposite color and one number smaller)
28
+ # throws an error if it does not fit
29
+ def add!(new_playing_card)
30
+ bottom_card = playing_cards.last
31
+ if (playing_cards.empty? && new_playing_card.rank == 13) ||
32
+ (new_playing_card.color != bottom_card.color && new_playing_card.rank == (bottom_card.rank - 1))
33
+ playing_cards.push(new_playing_card)
34
+ else
35
+ raise "Cannot add #{new_playing_card} to #{self}"
36
+ end
37
+ end
38
+
39
+ def remove!(card)
40
+ remove_cards_starting_at(playing_cards.index(card)).tap do |result|
41
+ playing_cards.last&.hidden = false
42
+ end
43
+ end
44
+
45
+ def remove_cards_starting_at(index)
46
+ removed_cards = playing_cards[index...playing_cards.size]
47
+ playing_cards[index...playing_cards.size] = []
48
+ removed_cards
49
+ end
50
+
51
+ def playing_cards
52
+ @playing_cards ||= []
53
+ end
54
+
55
+ def to_s
56
+ "Column Pile #{count} (#{playing_cards.map {|card| "#{card.rank}#{card.suit.to_s[0].upcase}"}.join(" | ")})"
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,33 @@
1
+ class KlondikeSolitaire
2
+ module Model
3
+ class DealingPile
4
+ DEALING_INITIAL_COUNT = 24
5
+
6
+ def initialize(game)
7
+ @game = game
8
+ reset!
9
+ end
10
+
11
+ def reset!
12
+ playing_cards.clear
13
+ DEALING_INITIAL_COUNT.times { playing_cards << @game.deck.pop }
14
+ end
15
+
16
+ def deal!
17
+ playing_card = playing_cards.shift
18
+ if playing_card.nil?
19
+ @game.dealt_pile.playing_cards.each do |a_playing_card|
20
+ playing_cards << a_playing_card
21
+ end
22
+ @game.dealt_pile.playing_cards.clear
23
+ else
24
+ @game.dealt_pile.push!(playing_card)
25
+ end
26
+ end
27
+
28
+ def playing_cards
29
+ @playing_cards ||= []
30
+ end
31
+ end
32
+ end
33
+ end