Sha256: 656afcc6a472eddac3fdc89bbed16697a24be080204f2295d19bf42430f1106f

Contents?: true

Size: 892 Bytes

Versions: 15

Compression:

Stored size: 892 Bytes

Contents

module Mida

  # Class used to describe a property
  class PropertyDesc
    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

    # 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
    def extract(*types)
      @types += types
    end

    # <b>DEPRECATED:</b> Please use +extract+ instead
    def types(*types)
      warn "[DEPRECATION] Mida::PropertyDesc#types is deprecated.  "+
           "Please use Mida::PropertyDesc#extract instead."
      extract *types
    end

    def to_h
      {num: @num, types: @types}
    end

  end

end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
mida-0.4.0 lib/mida/propertydesc.rb
mida-0.3.9 lib/mida/propertydesc.rb
mida_vocabulary-0.2.2 lib/mida_vocabulary/propertydesc.rb
mida_vocabulary-0.2 lib/mida_vocabulary/propertydesc.rb
mida-0.3.8 lib/mida/propertydesc.rb
mida-0.3.7 lib/mida/propertydesc.rb
mida-0.3.6 lib/mida/propertydesc.rb
mida_vocabulary-0.1.3 lib/mida_vocabulary/propertydesc.rb
mida_vocabulary-0.1.2 lib/mida_vocabulary/propertydesc.rb
mida_vocabulary-0.1.1 lib/mida_vocabulary/propertydesc.rb
mida_vocabulary-0.1 lib/mida_vocabulary/propertydesc.rb
mida-0.3.3 lib/mida/propertydesc.rb
mida-0.3.2 lib/mida/propertydesc.rb
mida-0.3.1 lib/mida/propertydesc.rb
mida-0.3.0 lib/mida/propertydesc.rb