Class: UniProp::PropertyManager
- Inherits:
-
Object
- Object
- UniProp::PropertyManager
- Defined in:
- lib/uniprop/unicode_manager.rb
Instance Attribute Summary collapse
-
#property ⇒ Object
readonly
Returns the value of attribute property.
-
#property_value_group ⇒ Object
readonly
Returns the value of attribute property_value_group.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
-
#version_metadata ⇒ Object
readonly
Returns the value of attribute version_metadata.
Instance Method Summary collapse
-
#initialize(property) ⇒ PropertyManager
constructor
propertyに関する情報を取得するためのオブジェクトを作成.
-
#missing_value(codepoint) ⇒ String
codepointのmissingを取得.
-
#raw_missing_value(codepoint) ⇒ String
codepointのmissingを取得。<codepoint>などの特殊な値もそのまま返される.
-
#same_value?(value1, value2) ⇒ Boolean
value1とvalue2が同じプロパティ値を表すエイリアスであるかを判定.
- #values_of(codepoint) ⇒ Set<String>
Constructor Details
#initialize(property) ⇒ PropertyManager
VersionまたはEfficientVersionはpropertyのProperty#versionが使用されるため、Version/EfficientVersionの使用したい方でPropertyオブジェクトを生成しpropertyとして使用する
propertyに関する情報を取得するためのオブジェクトを作成
205 206 207 208 209 210 |
# File 'lib/uniprop/unicode_manager.rb', line 205 def initialize(property) @property = property @version = @property.version @version_metadata = @version. @property_value_group = @version.prop_data..(@version).find_property_data(@property).property_value_group end |
Instance Attribute Details
#property ⇒ Object (readonly)
Returns the value of attribute property.
200 201 202 |
# File 'lib/uniprop/unicode_manager.rb', line 200 def property @property end |
#property_value_group ⇒ Object (readonly)
Returns the value of attribute property_value_group.
200 201 202 |
# File 'lib/uniprop/unicode_manager.rb', line 200 def property_value_group @property_value_group end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
200 201 202 |
# File 'lib/uniprop/unicode_manager.rb', line 200 def version @version end |
#version_metadata ⇒ Object (readonly)
Returns the value of attribute version_metadata.
200 201 202 |
# File 'lib/uniprop/unicode_manager.rb', line 200 def @version_metadata end |
Instance Method Details
#missing_value(codepoint) ⇒ String
codepointのmissingを取得
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/uniprop/unicode_manager.rb', line 227 def missing_value(codepoint) if codepoint.class==String codepoint = UniPropUtils::CodepointConverter.str_to_int(codepoint) end raw_missing_val = raw_missing_value(codepoint) case raw_missing_val when "<codepoint>" then codepoint.to_s(16).upcase when "<script>" then if @script || version.has_property?("Script") @script ||= PropertyManager.new(version.find_property("Script")) return @script.missing_value(codepoint) else return raw_missing_val end else raw_missing_val end end |
#raw_missing_value(codepoint) ⇒ String
codepointのmissingを取得。<codepoint>などの特殊な値もそのまま返される
250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
# File 'lib/uniprop/unicode_manager.rb', line 250 def raw_missing_value(codepoint) if codepoint.class==String codepoint = UniPropUtils::CodepointConverter.str_to_int(codepoint) end if .property_missing_defs(property) .property_missing_defs(property).reverse_each do |missing_def| if missing_def[:codepoint_range].include?(codepoint) return missing_def[:missing_value] end end end nil end |
#same_value?(value1, value2) ⇒ Boolean
value1とvalue2が同じプロパティ値を表すエイリアスであるかを判定
268 269 270 271 272 273 274 275 |
# File 'lib/uniprop/unicode_manager.rb', line 268 def same_value?(value1, value2) # Propertyがproperty_valuesを1つ以上持つとき、そのプロパティの値はPropertyValueAliasesに記述されており、エイリアスが存在する可能性がある if property.property_values.size >= 1 && property.has_property_value?(value1) && property.has_property_value?(value2) property.find_property_value(value1) == property.find_property_value(value2) else value1 == value2 end end |
#values_of(codepoint) ⇒ Set<String>
213 214 215 216 217 218 219 220 221 222 |
# File 'lib/uniprop/unicode_manager.rb', line 213 def values_of(codepoint) value = property_value_group.values_of(codepoint) if !value || value.empty? # 値が存在しない(nil)場合や、値が記述されていない(空文字列)の場合、missingを使用 missing_value(codepoint) else value end end |