Class: Radventure::Item
- Inherits:
-
Object
- Object
- Radventure::Item
- Defined in:
- lib/radventure/item.rb
Overview
Represents an ingame item
Instance Attribute Summary collapse
-
#desc ⇒ String
readonly
The long description of the item.
-
#is_known ⇒ Boolean
readonly
Whether the item is known (as in the ‘Identify` spell) or not.
-
#is_magic ⇒ Boolean
readonly
Whether the item is magic or not.
-
#name ⇒ String
readonly
The name of the item.
-
#short_desc ⇒ String
readonly
The short description of the item.
-
#true_desc ⇒ String?
readonly
The true long description of the item.
-
#true_name ⇒ String?
readonly
The true name of the item.
-
#true_type ⇒ String?
readonly
The true type (and possibly subtype) of the item.
-
#type ⇒ String
readonly
The type (and subtype, where applicable) of the item.
-
#value ⇒ Float
readonly
The value (in gold pieces) of the item.
-
#weight ⇒ Float
readonly
The weight (in kilograms) of the item.
Instance Method Summary collapse
-
#initialize(name, type, short_desc, desc, value, weight, is_magic: false, is_known: true, true_name: nil, true_type: nil, true_desc: nil) ⇒ Item
constructor
Item constructor.
Constructor Details
#initialize(name, type, short_desc, desc, value, weight, is_magic: false, is_known: true, true_name: nil, true_type: nil, true_desc: nil) ⇒ Item
Item constructor
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/radventure/item.rb', line 66 def initialize(name, type, short_desc, desc, value, weight, is_magic: false, is_known: true, true_name: nil, true_type: nil, true_desc: nil) @name = name.strip @type = type.strip @short_desc = short_desc.strip @desc = desc.strip @value = value.to_f @weight = weight.to_f @is_magic = is_magic ? true : false @is_known = is_known ? true : false @true_name = true_name.strip @true_type = true_type.strip @true_desc = true_desc.strip end |
Instance Attribute Details
#desc ⇒ String (readonly)
Returns The long description of the item.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/radventure/item.rb', line 48 class Item attr_reader :name, :type, :short_desc, :desc, :value, :weight, :is_magic, :is_known, :true_name, :true_type, :true_desc # Item constructor # # @param name [String] The name of the item # @param type [String] The type (and subtype, where applicable) of the item # @param short_desc [String] The short description of the item # @param desc [String] The long description of the item # @param value [Float] The value (in gold pieces) of the item # @param weight [Float] The weight (in kilograms) of the item # @param is_magic [Boolean] Whether the item is magic or not # @param is_known [Boolean] Whether the item is known (as in the `Identify` spell) or not # @param true_name [String, nil] The true name of the item # @param true_type [String, nil] The true type (and possibly subtype) of the item # @param true_desc [String, nil] The true long description of the item # @return [Item] The Item object def initialize(name, type, short_desc, desc, value, weight, is_magic: false, is_known: true, true_name: nil, true_type: nil, true_desc: nil) @name = name.strip @type = type.strip @short_desc = short_desc.strip @desc = desc.strip @value = value.to_f @weight = weight.to_f @is_magic = is_magic ? true : false @is_known = is_known ? true : false @true_name = true_name.strip @true_type = true_type.strip @true_desc = true_desc.strip end end |
#is_known ⇒ Boolean (readonly)
Returns Whether the item is known (as in the ‘Identify` spell) or not.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/radventure/item.rb', line 48 class Item attr_reader :name, :type, :short_desc, :desc, :value, :weight, :is_magic, :is_known, :true_name, :true_type, :true_desc # Item constructor # # @param name [String] The name of the item # @param type [String] The type (and subtype, where applicable) of the item # @param short_desc [String] The short description of the item # @param desc [String] The long description of the item # @param value [Float] The value (in gold pieces) of the item # @param weight [Float] The weight (in kilograms) of the item # @param is_magic [Boolean] Whether the item is magic or not # @param is_known [Boolean] Whether the item is known (as in the `Identify` spell) or not # @param true_name [String, nil] The true name of the item # @param true_type [String, nil] The true type (and possibly subtype) of the item # @param true_desc [String, nil] The true long description of the item # @return [Item] The Item object def initialize(name, type, short_desc, desc, value, weight, is_magic: false, is_known: true, true_name: nil, true_type: nil, true_desc: nil) @name = name.strip @type = type.strip @short_desc = short_desc.strip @desc = desc.strip @value = value.to_f @weight = weight.to_f @is_magic = is_magic ? true : false @is_known = is_known ? true : false @true_name = true_name.strip @true_type = true_type.strip @true_desc = true_desc.strip end end |
#is_magic ⇒ Boolean (readonly)
Returns Whether the item is magic or not.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/radventure/item.rb', line 48 class Item attr_reader :name, :type, :short_desc, :desc, :value, :weight, :is_magic, :is_known, :true_name, :true_type, :true_desc # Item constructor # # @param name [String] The name of the item # @param type [String] The type (and subtype, where applicable) of the item # @param short_desc [String] The short description of the item # @param desc [String] The long description of the item # @param value [Float] The value (in gold pieces) of the item # @param weight [Float] The weight (in kilograms) of the item # @param is_magic [Boolean] Whether the item is magic or not # @param is_known [Boolean] Whether the item is known (as in the `Identify` spell) or not # @param true_name [String, nil] The true name of the item # @param true_type [String, nil] The true type (and possibly subtype) of the item # @param true_desc [String, nil] The true long description of the item # @return [Item] The Item object def initialize(name, type, short_desc, desc, value, weight, is_magic: false, is_known: true, true_name: nil, true_type: nil, true_desc: nil) @name = name.strip @type = type.strip @short_desc = short_desc.strip @desc = desc.strip @value = value.to_f @weight = weight.to_f @is_magic = is_magic ? true : false @is_known = is_known ? true : false @true_name = true_name.strip @true_type = true_type.strip @true_desc = true_desc.strip end end |
#name ⇒ String (readonly)
Returns The name of the item.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/radventure/item.rb', line 48 class Item attr_reader :name, :type, :short_desc, :desc, :value, :weight, :is_magic, :is_known, :true_name, :true_type, :true_desc # Item constructor # # @param name [String] The name of the item # @param type [String] The type (and subtype, where applicable) of the item # @param short_desc [String] The short description of the item # @param desc [String] The long description of the item # @param value [Float] The value (in gold pieces) of the item # @param weight [Float] The weight (in kilograms) of the item # @param is_magic [Boolean] Whether the item is magic or not # @param is_known [Boolean] Whether the item is known (as in the `Identify` spell) or not # @param true_name [String, nil] The true name of the item # @param true_type [String, nil] The true type (and possibly subtype) of the item # @param true_desc [String, nil] The true long description of the item # @return [Item] The Item object def initialize(name, type, short_desc, desc, value, weight, is_magic: false, is_known: true, true_name: nil, true_type: nil, true_desc: nil) @name = name.strip @type = type.strip @short_desc = short_desc.strip @desc = desc.strip @value = value.to_f @weight = weight.to_f @is_magic = is_magic ? true : false @is_known = is_known ? true : false @true_name = true_name.strip @true_type = true_type.strip @true_desc = true_desc.strip end end |
#short_desc ⇒ String (readonly)
Returns The short description of the item.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/radventure/item.rb', line 48 class Item attr_reader :name, :type, :short_desc, :desc, :value, :weight, :is_magic, :is_known, :true_name, :true_type, :true_desc # Item constructor # # @param name [String] The name of the item # @param type [String] The type (and subtype, where applicable) of the item # @param short_desc [String] The short description of the item # @param desc [String] The long description of the item # @param value [Float] The value (in gold pieces) of the item # @param weight [Float] The weight (in kilograms) of the item # @param is_magic [Boolean] Whether the item is magic or not # @param is_known [Boolean] Whether the item is known (as in the `Identify` spell) or not # @param true_name [String, nil] The true name of the item # @param true_type [String, nil] The true type (and possibly subtype) of the item # @param true_desc [String, nil] The true long description of the item # @return [Item] The Item object def initialize(name, type, short_desc, desc, value, weight, is_magic: false, is_known: true, true_name: nil, true_type: nil, true_desc: nil) @name = name.strip @type = type.strip @short_desc = short_desc.strip @desc = desc.strip @value = value.to_f @weight = weight.to_f @is_magic = is_magic ? true : false @is_known = is_known ? true : false @true_name = true_name.strip @true_type = true_type.strip @true_desc = true_desc.strip end end |
#true_desc ⇒ String? (readonly)
Returns The true long description of the item.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/radventure/item.rb', line 48 class Item attr_reader :name, :type, :short_desc, :desc, :value, :weight, :is_magic, :is_known, :true_name, :true_type, :true_desc # Item constructor # # @param name [String] The name of the item # @param type [String] The type (and subtype, where applicable) of the item # @param short_desc [String] The short description of the item # @param desc [String] The long description of the item # @param value [Float] The value (in gold pieces) of the item # @param weight [Float] The weight (in kilograms) of the item # @param is_magic [Boolean] Whether the item is magic or not # @param is_known [Boolean] Whether the item is known (as in the `Identify` spell) or not # @param true_name [String, nil] The true name of the item # @param true_type [String, nil] The true type (and possibly subtype) of the item # @param true_desc [String, nil] The true long description of the item # @return [Item] The Item object def initialize(name, type, short_desc, desc, value, weight, is_magic: false, is_known: true, true_name: nil, true_type: nil, true_desc: nil) @name = name.strip @type = type.strip @short_desc = short_desc.strip @desc = desc.strip @value = value.to_f @weight = weight.to_f @is_magic = is_magic ? true : false @is_known = is_known ? true : false @true_name = true_name.strip @true_type = true_type.strip @true_desc = true_desc.strip end end |
#true_name ⇒ String? (readonly)
Returns The true name of the item.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/radventure/item.rb', line 48 class Item attr_reader :name, :type, :short_desc, :desc, :value, :weight, :is_magic, :is_known, :true_name, :true_type, :true_desc # Item constructor # # @param name [String] The name of the item # @param type [String] The type (and subtype, where applicable) of the item # @param short_desc [String] The short description of the item # @param desc [String] The long description of the item # @param value [Float] The value (in gold pieces) of the item # @param weight [Float] The weight (in kilograms) of the item # @param is_magic [Boolean] Whether the item is magic or not # @param is_known [Boolean] Whether the item is known (as in the `Identify` spell) or not # @param true_name [String, nil] The true name of the item # @param true_type [String, nil] The true type (and possibly subtype) of the item # @param true_desc [String, nil] The true long description of the item # @return [Item] The Item object def initialize(name, type, short_desc, desc, value, weight, is_magic: false, is_known: true, true_name: nil, true_type: nil, true_desc: nil) @name = name.strip @type = type.strip @short_desc = short_desc.strip @desc = desc.strip @value = value.to_f @weight = weight.to_f @is_magic = is_magic ? true : false @is_known = is_known ? true : false @true_name = true_name.strip @true_type = true_type.strip @true_desc = true_desc.strip end end |
#true_type ⇒ String? (readonly)
Returns The true type (and possibly subtype) of the item.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/radventure/item.rb', line 48 class Item attr_reader :name, :type, :short_desc, :desc, :value, :weight, :is_magic, :is_known, :true_name, :true_type, :true_desc # Item constructor # # @param name [String] The name of the item # @param type [String] The type (and subtype, where applicable) of the item # @param short_desc [String] The short description of the item # @param desc [String] The long description of the item # @param value [Float] The value (in gold pieces) of the item # @param weight [Float] The weight (in kilograms) of the item # @param is_magic [Boolean] Whether the item is magic or not # @param is_known [Boolean] Whether the item is known (as in the `Identify` spell) or not # @param true_name [String, nil] The true name of the item # @param true_type [String, nil] The true type (and possibly subtype) of the item # @param true_desc [String, nil] The true long description of the item # @return [Item] The Item object def initialize(name, type, short_desc, desc, value, weight, is_magic: false, is_known: true, true_name: nil, true_type: nil, true_desc: nil) @name = name.strip @type = type.strip @short_desc = short_desc.strip @desc = desc.strip @value = value.to_f @weight = weight.to_f @is_magic = is_magic ? true : false @is_known = is_known ? true : false @true_name = true_name.strip @true_type = true_type.strip @true_desc = true_desc.strip end end |
#type ⇒ String (readonly)
Returns The type (and subtype, where applicable) of the item.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/radventure/item.rb', line 48 class Item attr_reader :name, :type, :short_desc, :desc, :value, :weight, :is_magic, :is_known, :true_name, :true_type, :true_desc # Item constructor # # @param name [String] The name of the item # @param type [String] The type (and subtype, where applicable) of the item # @param short_desc [String] The short description of the item # @param desc [String] The long description of the item # @param value [Float] The value (in gold pieces) of the item # @param weight [Float] The weight (in kilograms) of the item # @param is_magic [Boolean] Whether the item is magic or not # @param is_known [Boolean] Whether the item is known (as in the `Identify` spell) or not # @param true_name [String, nil] The true name of the item # @param true_type [String, nil] The true type (and possibly subtype) of the item # @param true_desc [String, nil] The true long description of the item # @return [Item] The Item object def initialize(name, type, short_desc, desc, value, weight, is_magic: false, is_known: true, true_name: nil, true_type: nil, true_desc: nil) @name = name.strip @type = type.strip @short_desc = short_desc.strip @desc = desc.strip @value = value.to_f @weight = weight.to_f @is_magic = is_magic ? true : false @is_known = is_known ? true : false @true_name = true_name.strip @true_type = true_type.strip @true_desc = true_desc.strip end end |
#value ⇒ Float (readonly)
Returns The value (in gold pieces) of the item.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/radventure/item.rb', line 48 class Item attr_reader :name, :type, :short_desc, :desc, :value, :weight, :is_magic, :is_known, :true_name, :true_type, :true_desc # Item constructor # # @param name [String] The name of the item # @param type [String] The type (and subtype, where applicable) of the item # @param short_desc [String] The short description of the item # @param desc [String] The long description of the item # @param value [Float] The value (in gold pieces) of the item # @param weight [Float] The weight (in kilograms) of the item # @param is_magic [Boolean] Whether the item is magic or not # @param is_known [Boolean] Whether the item is known (as in the `Identify` spell) or not # @param true_name [String, nil] The true name of the item # @param true_type [String, nil] The true type (and possibly subtype) of the item # @param true_desc [String, nil] The true long description of the item # @return [Item] The Item object def initialize(name, type, short_desc, desc, value, weight, is_magic: false, is_known: true, true_name: nil, true_type: nil, true_desc: nil) @name = name.strip @type = type.strip @short_desc = short_desc.strip @desc = desc.strip @value = value.to_f @weight = weight.to_f @is_magic = is_magic ? true : false @is_known = is_known ? true : false @true_name = true_name.strip @true_type = true_type.strip @true_desc = true_desc.strip end end |
#weight ⇒ Float (readonly)
Returns The weight (in kilograms) of the item.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/radventure/item.rb', line 48 class Item attr_reader :name, :type, :short_desc, :desc, :value, :weight, :is_magic, :is_known, :true_name, :true_type, :true_desc # Item constructor # # @param name [String] The name of the item # @param type [String] The type (and subtype, where applicable) of the item # @param short_desc [String] The short description of the item # @param desc [String] The long description of the item # @param value [Float] The value (in gold pieces) of the item # @param weight [Float] The weight (in kilograms) of the item # @param is_magic [Boolean] Whether the item is magic or not # @param is_known [Boolean] Whether the item is known (as in the `Identify` spell) or not # @param true_name [String, nil] The true name of the item # @param true_type [String, nil] The true type (and possibly subtype) of the item # @param true_desc [String, nil] The true long description of the item # @return [Item] The Item object def initialize(name, type, short_desc, desc, value, weight, is_magic: false, is_known: true, true_name: nil, true_type: nil, true_desc: nil) @name = name.strip @type = type.strip @short_desc = short_desc.strip @desc = desc.strip @value = value.to_f @weight = weight.to_f @is_magic = is_magic ? true : false @is_known = is_known ? true : false @true_name = true_name.strip @true_type = true_type.strip @true_desc = true_desc.strip end end |