Class: Beefdump::World::ObjectProperty
- Inherits:
-
Object
- Object
- Beefdump::World::ObjectProperty
- Defined in:
- lib/beefdump/world/object_property.rb
Constant Summary collapse
- TYPES =
[:number, :string, :name_reference]
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(name, type, mandatory = false) ⇒ ObjectProperty
constructor
A new instance of ObjectProperty.
- #mandatory? ⇒ Boolean
Constructor Details
#initialize(name, type, mandatory = false) ⇒ ObjectProperty
Returns a new instance of ObjectProperty.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/beefdump/world/object_property.rb', line 8 def initialize(name, type, mandatory = false) raise "Any object property need a name!" unless @name = name raise "Object property '#{@name}' has not type. Any property needs a type!" unless type type = type.to_sym raise "Object property type '#{type}' is not supported! Use one of: #{TYPES.join(',')}." unless TYPES.include?(type) @type = type @mandatory = !!mandatory end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/beefdump/world/object_property.rb', line 6 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/beefdump/world/object_property.rb', line 6 def type @type end |
Instance Method Details
#mandatory? ⇒ Boolean
19 20 21 |
# File 'lib/beefdump/world/object_property.rb', line 19 def mandatory? @mandatory end |