Class: Beefdump::World::ObjectProperty

Inherits:
Object
  • Object
show all
Defined in:
lib/beefdump/world/object_property.rb

Constant Summary collapse

TYPES =
[:number, :string, :name_reference]

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/beefdump/world/object_property.rb', line 6

def name
  @name
end

#typeObject (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

Returns:

  • (Boolean)


19
20
21
# File 'lib/beefdump/world/object_property.rb', line 19

def mandatory?
  @mandatory
end