UML model and code examples of design patterns for Crystal. The model is created with Astah.
Model and code examples of GoF Design Patterns for Crystal.
This project is available for the following objectives:
UML model example:
Crystal code example:
# ˅
require "./file_system_element"
# ˄
# Since class name of "File" can not be used duplicately, the class name is "File_".
class File_ < FileSystemElement
# ˅
# ˄
@name : String
@size : Int32
def initialize(name : String, size : Int32)
# ˅
@name = name
@size = size
# ˄
end
def name : String
# ˅
return @name
# ˄
end
def size : Int32
# ˅
return @size
# ˄
end
# Print this element with the "upperPath".
def print(upper_path : String)
# ˅
puts "#{upper_path}/#{self.to_s}"
# ˄
end
# ˅
# ˄
end
# ˅
# ˄
This has been confirmed on Ubuntu 22.04 / 20.04.2 / 18.04.5, not confirmed on macOS and Windows.
UML Modeling Tool
Crystal Development Environment
sudo apt-get install libgirepository1.0-dev libgtk-3-dev libcairo-gobject2 gir1.2-freedesktop
Ubuntu 22.04
sudo apt-get install libgirepository1.0-dev libgtk-3-dev libcairo-gobject2 gir1.2-freedesktop
sudo apt-get install gcc pkg-config git tzdata libpcre3-dev libevent-dev libyaml-dev libgmp-dev libssl-dev libxml2-dev
shards install
Note: The following error (File::AlreadyExistsError) occurs when running the shards command, but the installation seems to succeed.
Unhandled exception: Error creating symlink: '..' -> '/path_to_app/lib/cairo-gobject/lib': File exists (File::AlreadyExistsError)
This has been confirmed on Ubuntu 22.04 / 20.04.2 / 18.04.5, not confirmed on macOS and Windows.
Code Generation from UML
Build and Run (in Debug Mode)
main.cr
for the pattern you want to run, and click Run > Start Debugging (or press F5).This project is licensed under the Creative Commons Zero (CC0) license. The model and code are completely free to use.
C++, C#, Go, Java, JavaScript, Kotlin, Python, Ruby, Scala, Swift, TypeScript