Class: UniProp::Property
- Inherits:
-
Object
- Object
- UniProp::Property
- Includes:
- Alias
- Defined in:
- lib/uniprop/unicode_elements.rb
Instance Attribute Summary collapse
-
#property_value_type ⇒ Object
Returns the value of attribute property_value_type.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Attributes included from Alias
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#actual_columns(propfile) ⇒ Array<Integer>
propfile中でプロパティが含まれる列を取得.
-
#actual_positions ⇒ Array<Position>
:nocov: versionに含まれるPropFileの中の、このプロパティが含まれる場所を取得.
-
#find_property_value(property_value_alias) ⇒ PropertyValue
property_value_aliasをエイリアスに持つPropertyValueをproperty_valuesの中から取得.
-
#has_property_value?(property_value_alias) ⇒ Boolean
:nocov: property_value_aliasをエイリアスに持つPropertyValueをproperty_valuesに持つか判定.
-
#initialize(version, *new_aliases) ⇒ Property
constructor
A new instance of Property.
-
#is_unihan_property? ⇒ Boolean
Unihanのプロパティか判定.
-
#miscellaneous_format ⇒ Symbol?
settings.rbのmiscellaneous_formats内のformat_typeを小文字のシンボルで取得。記述されていない場合はnil.
- #property_values ⇒ Array<PropertyValue>
-
#unique_threshold ⇒ Integer?/Float?
settings.rbのmiscellaneous_formats内のunique_thresholdを取得。記述されていない場合はnil.
Methods included from Alias
#add_alias, #aliases, canonical, #eql?, #has_alias?, #hash, #inspect, #uncanonicaled_aliases
Constructor Details
#initialize(version, *new_aliases) ⇒ Property
Returns a new instance of Property.
66 67 68 69 |
# File 'lib/uniprop/unicode_elements.rb', line 66 def initialize(version, *new_aliases) @version = version super(*new_aliases) end |
Instance Attribute Details
#property_value_type ⇒ Object
Returns the value of attribute property_value_type.
62 63 64 |
# File 'lib/uniprop/unicode_elements.rb', line 62 def property_value_type @property_value_type end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
62 63 64 |
# File 'lib/uniprop/unicode_elements.rb', line 62 def version @version end |
Instance Method Details
#==(other) ⇒ Object
99 100 101 102 103 104 105 106 107 108 |
# File 'lib/uniprop/unicode_elements.rb', line 99 def ==(other) # プロパティのエイリアスはバージョン更新時に増えることがあるため、versionの異なるPropertyを比較する場合には、プロパティが増えていてもtrueを返す if version > other.version return (other.aliases-aliases).empty? elsif version < other.version return (aliases-other.aliases).empty? else aliases==other.aliases end end |
#actual_columns(propfile) ⇒ Array<Integer>
プロパティがpropfileに含まれない場合、空の配列を返す
propfile中でプロパティが含まれる列を取得
151 152 153 154 155 |
# File 'lib/uniprop/unicode_elements.rb', line 151 def actual_columns(propfile) columns = [] actual_positions.each { columns<<_1.column if _1.propfile==propfile } columns end |
#actual_positions ⇒ Array<Position>
:nocov: versionに含まれるPropFileの中の、このプロパティが含まれる場所を取得
142 143 144 |
# File 'lib/uniprop/unicode_elements.rb', line 142 def actual_positions @actual_positions ||= version..property_to_actual_positions[self] end |
#find_property_value(property_value_alias) ⇒ PropertyValue
property_value_aliasをエイリアスに持つPropertyValueをproperty_valuesの中から取得
129 130 131 132 133 134 135 136 137 |
# File 'lib/uniprop/unicode_elements.rb', line 129 def find_property_value(property_value_alias) pv = property_values.find { _1.has_alias?(property_value_alias)} if pv return pv else raise(PropertyValueNotFoundError, "#{longest_alias} doesn't have #{property_value_alias} as value.") end end |
#has_property_value?(property_value_alias) ⇒ Boolean
:nocov: property_value_aliasをエイリアスに持つPropertyValueをproperty_valuesに持つか判定
118 119 120 121 122 |
# File 'lib/uniprop/unicode_elements.rb', line 118 def has_property_value?(property_value_alias) !!find_property_value(property_value_alias) rescue false end |
#is_unihan_property? ⇒ Boolean
Unihanのプロパティか判定
158 159 160 |
# File 'lib/uniprop/unicode_elements.rb', line 158 def is_unihan_property? version.unihan_properties.include?(self) end |
#miscellaneous_format ⇒ Symbol?
settings.rbのmiscellaneous_formats内のformat_typeを小文字のシンボルで取得。記述されていない場合はnil
89 90 91 |
# File 'lib/uniprop/unicode_elements.rb', line 89 def miscellaneous_format version.property_to_miscellaneous_formats.dig(self, :format_type)&.downcase&.to_sym end |
#property_values ⇒ Array<PropertyValue>
111 112 113 |
# File 'lib/uniprop/unicode_elements.rb', line 111 def property_values version.property_to_property_values[self] end |
#unique_threshold ⇒ Integer?/Float?
settings.rbのmiscellaneous_formats内のunique_thresholdを取得。記述されていない場合はnil
95 96 97 |
# File 'lib/uniprop/unicode_elements.rb', line 95 def unique_threshold version.property_to_miscellaneous_formats.dig(self, :unique_threshold) end |