Class: Radventure::Meta

Inherits:
Object
  • Object
show all
Defined in:
lib/radventure/meta.rb

Overview

Defines game metadata

Examples:

Initialize metadata

meta = Meta.new 'game.yml'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, description, version, author, license, year, prelude: '') ⇒ Meta

Constructor method

Parameters:

  • title (String)

    The title of the game

  • description (String)

    The description of the game

  • version (String)

    The version of the game, in accordance with SemVer

  • author (String)

    The author of the game

  • license (String)

    The license of the game

  • year (String, Integer)

    The year(s) of the game

  • prelude (String) (defaults to: '')

    The prelude text of the game



36
37
38
39
40
41
42
43
44
# File 'lib/radventure/meta.rb', line 36

def initialize(title, description, version, author, license, year, prelude: '')
  @title = title.strip
  @description = description.strip
  @version = version.strip
  @author = author.strip
  @license = license.strip
  @year = year.to_s.strip
  @prelude = prelude.strip || ''
end

Instance Attribute Details

#authorString (readonly)

Returns The author name of the game.

Returns:

  • (String)

    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, author, license, year, prelude: '')
    @title = title.strip
    @description = description.strip
    @version = version.strip
    @author = 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

#descriptionString (readonly)

Returns The short description of the game.

Returns:

  • (String)

    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, author, license, year, prelude: '')
    @title = title.strip
    @description = description.strip
    @version = version.strip
    @author = 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

#licenseString (readonly)

Returns The license name of the game.

Returns:

  • (String)

    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, author, license, year, prelude: '')
    @title = title.strip
    @description = description.strip
    @version = version.strip
    @author = 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

#preludeString? (readonly)

Returns A text block containg the game’s prelude, or ‘nil` if none is set.

Returns:

  • (String, nil)

    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, author, license, year, prelude: '')
    @title = title.strip
    @description = description.strip
    @version = version.strip
    @author = 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

#titleString (readonly)

Returns The name/title of the game.

Returns:

  • (String)

    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, author, license, year, prelude: '')
    @title = title.strip
    @description = description.strip
    @version = version.strip
    @author = 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

#versionString (readonly)

Returns The version of the game.

Returns:

  • (String)

    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, author, license, year, prelude: '')
    @title = title.strip
    @description = description.strip
    @version = version.strip
    @author = 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

#yearString (readonly)

Returns The year/years of development/release of the game.

Returns:

  • (String)

    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, author, license, year, prelude: '')
    @title = title.strip
    @description = description.strip
    @version = version.strip
    @author = 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