Class: UniProp::PropertyData

Inherits:
Object
  • Object
show all
Defined in:
lib/uniprop/metadata_processor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(property, positions, unihan, derived) ⇒ PropertyData

プロパティメタデータに含まれる、プロパティ1つあたりのデータ

Parameters:

  • property (Property)
  • positions (Array<Position>)
  • unihan (Boolean)
  • derived (Boolean)


628
629
630
631
632
633
634
# File 'lib/uniprop/metadata_processor.rb', line 628

def initialize(property, positions, unihan, derived)
  @property = property
  @version = @property.version
  @positions = positions
  @unihan = unihan
  @derived = derived
end

Instance Attribute Details

#positionsObject (readonly)

Returns the value of attribute positions.



621
622
623
# File 'lib/uniprop/metadata_processor.rb', line 621

def positions
  @positions
end

#propertyObject (readonly)

Returns the value of attribute property.



621
622
623
# File 'lib/uniprop/metadata_processor.rb', line 621

def property
  @property
end

#versionObject (readonly)

Returns the value of attribute version.



621
622
623
# File 'lib/uniprop/metadata_processor.rb', line 621

def version
  @version
end

Instance Method Details

#is_derived?Boolean

Returns:

  • (Boolean)


640
641
642
# File 'lib/uniprop/metadata_processor.rb', line 640

def is_derived?
  @derived
end

#is_unihan?Boolean

Returns:

  • (Boolean)


636
637
638
# File 'lib/uniprop/metadata_processor.rb', line 636

def is_unihan?
  @unihan
end

#positionPosition

プロパティの解析に最も適したPositionオブジェクトをを取得

Returns:



650
651
652
653
654
655
656
657
658
659
# File 'lib/uniprop/metadata_processor.rb', line 650

def position
  if is_derived?
    # Derivedファイルが存在する場合、使用

    return positions.find { _1.propfile.basename_prefix=~/Derived/ }
  else
    # Derivedファイルが存在しない場合、

    # 記述される列が最も小さいファイルが解析しやすいため使用

    return positions.sort { _1.columns.size }.first
  end
end

#property_value_groupPropertyValueGroup/UnihanValueGroup

propertyの情報を取得するのに最適なPropertyValueGroupオブジェクトを生成



663
664
665
666
667
668
669
670
671
# File 'lib/uniprop/metadata_processor.rb', line 663

def property_value_group
  return @property_value_group if @property_value_group

  if is_unihan?
    @property_value_group = version.unihanprop.unihan_value_group(property)
  else
    @property_value_group = PropertyValueGroup.new(position.propfile, property, position.block)
  end
end

#typeObject



644
645
646
# File 'lib/uniprop/metadata_processor.rb', line 644

def type
  property.property_value_type
end