Class: Mida::PropertyDesc
- Inherits:
-
Object
- Object
- Mida::PropertyDesc
- Defined in:
- lib/mida/propertydesc.rb
Overview
Class used to describe a property
Instance Method Summary collapse
-
#extract(*types) ⇒ Object
What to extract for this property.
-
#initialize(num, &block) ⇒ PropertyDesc
constructor
A new instance of PropertyDesc.
- #to_h ⇒ Object
-
#types(*types) ⇒ Object
DEPRECATED: Please use
extract
instead.
Constructor Details
#initialize(num, &block) ⇒ PropertyDesc
Returns a new instance of PropertyDesc.
5 6 7 8 9 10 11 12 13 |
# File 'lib/mida/propertydesc.rb', line 5 def initialize(num, &block) @num, @types = num, [] if block_given? instance_eval(&block) @types = [DataType::Text] unless @types.size >= 1 else @types = [DataType::Text] end end |
Instance Method Details
#extract(*types) ⇒ Object
What to extract for this property. This can be a datatype such as :text
or a Vocabulary
. The types should be supplied in order of preference. If you want to say any type, then use :any
as the class
19 20 21 |
# File 'lib/mida/propertydesc.rb', line 19 def extract(*types) @types += types end |
#to_h ⇒ Object
30 31 32 |
# File 'lib/mida/propertydesc.rb', line 30 def to_h {num: @num, types: @types} end |
#types(*types) ⇒ Object
DEPRECATED: Please use extract
instead
24 25 26 27 28 |
# File 'lib/mida/propertydesc.rb', line 24 def types(*types) warn "[DEPRECATION] Mida::PropertyDesc#types is deprecated. "+ "Please use Mida::PropertyDesc#extract instead." extract *types end |