Class: Radventure::Meta
- Inherits:
-
Object
- Object
- Radventure::Meta
- Defined in:
- lib/radventure/meta.rb
Overview
Defines game metadata
Instance Attribute Summary collapse
-
#author ⇒ String
readonly
The author name of the game.
-
#description ⇒ String
readonly
The short description of the game.
-
#license ⇒ String
readonly
The license name of the game.
-
#prelude ⇒ String?
readonly
A text block containg the game’s prelude, or ‘nil` if none is set.
-
#title ⇒ String
readonly
The name/title of the game.
-
#version ⇒ String
readonly
The version of the game.
-
#year ⇒ String
readonly
The year/years of development/release of the game.
Instance Method Summary collapse
-
#initialize(title, description, version, author, license, year, prelude: '') ⇒ Meta
constructor
Constructor method.
Constructor Details
#initialize(title, description, version, author, license, year, prelude: '') ⇒ Meta
Constructor method
36 37 38 39 40 41 42 43 44 |
# File 'lib/radventure/meta.rb', line 36 def initialize(title, description, version, , license, year, prelude: '') @title = title.strip @description = description.strip @version = version.strip @author = .strip @license = license.strip @year = year.to_s.strip @prelude = prelude.strip || '' end |
Instance Attribute Details
#author ⇒ String (readonly)
Returns The author name of the game.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/radventure/meta.rb', line 23 class Meta attr_reader :title, :description, :version, :author, :license, :year, :prelude # Constructor method # # @param title [String] The title of the game # @param description [String] The description of the game # @param version [String] The version of the game, in accordance with SemVer # @param author [String] The author of the game # @param license [String] The license of the game # @param year [String, Integer] The year(s) of the game # @param prelude [String] The prelude text of the game # @return [Meta] Game metadata object def initialize(title, description, version, , license, year, prelude: '') @title = title.strip @description = description.strip @version = version.strip @author = .strip @license = license.strip @year = year.to_s.strip @prelude = prelude.strip || '' end private # Retrieves the metadata from the game's YAML file # # @param yaml_file [String] The path to the game's metadata YAML file # @return [Hash] A hash containing the game metadata def fetch(yaml_file) if File.exist? yaml_file YAML.load_file yaml_file else { 'title' => 'No Title', 'description' => 'No description so far.', 'version' => 'x.y.z', 'author' => 'No One', 'license' => 'CC0', 'year' => '1917' } end end end |
#description ⇒ String (readonly)
Returns The short description of the game.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/radventure/meta.rb', line 23 class Meta attr_reader :title, :description, :version, :author, :license, :year, :prelude # Constructor method # # @param title [String] The title of the game # @param description [String] The description of the game # @param version [String] The version of the game, in accordance with SemVer # @param author [String] The author of the game # @param license [String] The license of the game # @param year [String, Integer] The year(s) of the game # @param prelude [String] The prelude text of the game # @return [Meta] Game metadata object def initialize(title, description, version, , license, year, prelude: '') @title = title.strip @description = description.strip @version = version.strip @author = .strip @license = license.strip @year = year.to_s.strip @prelude = prelude.strip || '' end private # Retrieves the metadata from the game's YAML file # # @param yaml_file [String] The path to the game's metadata YAML file # @return [Hash] A hash containing the game metadata def fetch(yaml_file) if File.exist? yaml_file YAML.load_file yaml_file else { 'title' => 'No Title', 'description' => 'No description so far.', 'version' => 'x.y.z', 'author' => 'No One', 'license' => 'CC0', 'year' => '1917' } end end end |
#license ⇒ String (readonly)
Returns The license name of the game.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/radventure/meta.rb', line 23 class Meta attr_reader :title, :description, :version, :author, :license, :year, :prelude # Constructor method # # @param title [String] The title of the game # @param description [String] The description of the game # @param version [String] The version of the game, in accordance with SemVer # @param author [String] The author of the game # @param license [String] The license of the game # @param year [String, Integer] The year(s) of the game # @param prelude [String] The prelude text of the game # @return [Meta] Game metadata object def initialize(title, description, version, , license, year, prelude: '') @title = title.strip @description = description.strip @version = version.strip @author = .strip @license = license.strip @year = year.to_s.strip @prelude = prelude.strip || '' end private # Retrieves the metadata from the game's YAML file # # @param yaml_file [String] The path to the game's metadata YAML file # @return [Hash] A hash containing the game metadata def fetch(yaml_file) if File.exist? yaml_file YAML.load_file yaml_file else { 'title' => 'No Title', 'description' => 'No description so far.', 'version' => 'x.y.z', 'author' => 'No One', 'license' => 'CC0', 'year' => '1917' } end end end |
#prelude ⇒ String? (readonly)
Returns A text block containg the game’s prelude, or ‘nil` if none is set.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/radventure/meta.rb', line 23 class Meta attr_reader :title, :description, :version, :author, :license, :year, :prelude # Constructor method # # @param title [String] The title of the game # @param description [String] The description of the game # @param version [String] The version of the game, in accordance with SemVer # @param author [String] The author of the game # @param license [String] The license of the game # @param year [String, Integer] The year(s) of the game # @param prelude [String] The prelude text of the game # @return [Meta] Game metadata object def initialize(title, description, version, , license, year, prelude: '') @title = title.strip @description = description.strip @version = version.strip @author = .strip @license = license.strip @year = year.to_s.strip @prelude = prelude.strip || '' end private # Retrieves the metadata from the game's YAML file # # @param yaml_file [String] The path to the game's metadata YAML file # @return [Hash] A hash containing the game metadata def fetch(yaml_file) if File.exist? yaml_file YAML.load_file yaml_file else { 'title' => 'No Title', 'description' => 'No description so far.', 'version' => 'x.y.z', 'author' => 'No One', 'license' => 'CC0', 'year' => '1917' } end end end |
#title ⇒ String (readonly)
Returns The name/title of the game.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/radventure/meta.rb', line 23 class Meta attr_reader :title, :description, :version, :author, :license, :year, :prelude # Constructor method # # @param title [String] The title of the game # @param description [String] The description of the game # @param version [String] The version of the game, in accordance with SemVer # @param author [String] The author of the game # @param license [String] The license of the game # @param year [String, Integer] The year(s) of the game # @param prelude [String] The prelude text of the game # @return [Meta] Game metadata object def initialize(title, description, version, , license, year, prelude: '') @title = title.strip @description = description.strip @version = version.strip @author = .strip @license = license.strip @year = year.to_s.strip @prelude = prelude.strip || '' end private # Retrieves the metadata from the game's YAML file # # @param yaml_file [String] The path to the game's metadata YAML file # @return [Hash] A hash containing the game metadata def fetch(yaml_file) if File.exist? yaml_file YAML.load_file yaml_file else { 'title' => 'No Title', 'description' => 'No description so far.', 'version' => 'x.y.z', 'author' => 'No One', 'license' => 'CC0', 'year' => '1917' } end end end |
#version ⇒ String (readonly)
Returns The version of the game.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/radventure/meta.rb', line 23 class Meta attr_reader :title, :description, :version, :author, :license, :year, :prelude # Constructor method # # @param title [String] The title of the game # @param description [String] The description of the game # @param version [String] The version of the game, in accordance with SemVer # @param author [String] The author of the game # @param license [String] The license of the game # @param year [String, Integer] The year(s) of the game # @param prelude [String] The prelude text of the game # @return [Meta] Game metadata object def initialize(title, description, version, , license, year, prelude: '') @title = title.strip @description = description.strip @version = version.strip @author = .strip @license = license.strip @year = year.to_s.strip @prelude = prelude.strip || '' end private # Retrieves the metadata from the game's YAML file # # @param yaml_file [String] The path to the game's metadata YAML file # @return [Hash] A hash containing the game metadata def fetch(yaml_file) if File.exist? yaml_file YAML.load_file yaml_file else { 'title' => 'No Title', 'description' => 'No description so far.', 'version' => 'x.y.z', 'author' => 'No One', 'license' => 'CC0', 'year' => '1917' } end end end |
#year ⇒ String (readonly)
Returns The year/years of development/release of the game.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/radventure/meta.rb', line 23 class Meta attr_reader :title, :description, :version, :author, :license, :year, :prelude # Constructor method # # @param title [String] The title of the game # @param description [String] The description of the game # @param version [String] The version of the game, in accordance with SemVer # @param author [String] The author of the game # @param license [String] The license of the game # @param year [String, Integer] The year(s) of the game # @param prelude [String] The prelude text of the game # @return [Meta] Game metadata object def initialize(title, description, version, , license, year, prelude: '') @title = title.strip @description = description.strip @version = version.strip @author = .strip @license = license.strip @year = year.to_s.strip @prelude = prelude.strip || '' end private # Retrieves the metadata from the game's YAML file # # @param yaml_file [String] The path to the game's metadata YAML file # @return [Hash] A hash containing the game metadata def fetch(yaml_file) if File.exist? yaml_file YAML.load_file yaml_file else { 'title' => 'No Title', 'description' => 'No description so far.', 'version' => 'x.y.z', 'author' => 'No One', 'license' => 'CC0', 'year' => '1917' } end end end |