diff options
| author | Amir Rajan <[email protected]> | 2020-02-27 20:14:39 -0600 |
|---|---|---|
| committer | Amir Rajan <[email protected]> | 2020-02-27 20:14:39 -0600 |
| commit | 5d0c0305854633122b3e800dd9058e93c2950eb6 (patch) | |
| tree | 0283825a7055cebd59ad1b3aff1b3dec1f2ac03c /dragon/docs.rb | |
| parent | 07468bf3f309c21ea3f7fcf47195ca275177dc7f (diff) | |
| download | dragonruby-game-toolkit-contrib-5d0c0305854633122b3e800dd9058e93c2950eb6.tar.gz dragonruby-game-toolkit-contrib-5d0c0305854633122b3e800dd9058e93c2950eb6.zip | |
open sourced parts of game toolkit.
Diffstat (limited to 'dragon/docs.rb')
| -rw-r--r-- | dragon/docs.rb | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/dragon/docs.rb b/dragon/docs.rb new file mode 100644 index 0000000..b9d3dbf --- /dev/null +++ b/dragon/docs.rb @@ -0,0 +1,47 @@ +# coding: utf-8 +# Copyright 2019 DragonRuby LLC +# MIT License +# docs.rb has been released under MIT (*only this file*). + +module GTK + class Docs + def map_with_ys + puts <<-S +* Numeric#map_with_ys +Numeric#map_with_ys is a helper method that is useful for working with coordinates +or rows with columns. Here is an example usage. + +Assume you have a grid with 10 rows (xs) and 5 columns (ys). You can generate +an array of hashes with the following form: + +#+begin_src +[ + { x: 0, y: 0, some_data: "A" }, + { x: 0, y: 1, some_data: "A" }, + { x: 0, y: 2, some_data: "A" }, +... + { x: 9, y: 4, some_data: "A" }, +] +#+end_src + +Using the following code: + +#+begin_src ruby +array_of_hashes = 10.map_with_ys 5 do |x, y| + { x: x, y: y, some_data: "A" } +end + +Take a look at the "hexagon grid" sample app for a real world usage of +this method. +#+end_src +S + end + + def method_missing m, *args + puts <<-S +* DOCUMENTATION MISSING: +It looks like docs are missing for :#{m}. Let the @dragonborne know about it in the Discord channel: http://discord.dragonruby.org. +S + end + end +end |
