Class: UniProp::BasePropertyValueGroup
- Inherits:
-
Object
- Object
- UniProp::BasePropertyValueGroup
- Includes:
- ValueGroup
- Defined in:
- lib/uniprop/inspects.rb,
lib/uniprop/value_group.rb
Direct Known Subclasses
Instance Method Summary collapse
- #has_property?(property) ⇒ Boolean
- #inspect ⇒ Object
- #properties ⇒ Array<Property>
-
#string_value_including_codepoints(value) ⇒ Array<Integer>
valueをプロパティ値に持つコードポイントを取得.
-
#value_including_codepoints(value) ⇒ Array<Integer>
valueをプロパティ値に持つコードポイントを取得.
Methods included from ValueGroup
#codepoints, #values_of, #values_to_codepoints
Instance Method Details
#has_property?(property) ⇒ Boolean
130 131 132 |
# File 'lib/uniprop/value_group.rb', line 130 def has_property?(property) properties.include?(property) end |
#inspect ⇒ Object
91 92 93 |
# File 'lib/uniprop/inspects.rb', line 91 def inspect "#<#{self.class.name}>" end |
#properties ⇒ Array<Property>
125 126 127 |
# File 'lib/uniprop/value_group.rb', line 125 def properties @properties ||= [] end |
#string_value_including_codepoints(value) ⇒ Array<Integer>
Note:
プロパティ値のエイリアスは考慮せず、単なる文字列の一致を確かめる
valueをプロパティ値に持つコードポイントを取得
89 90 91 92 93 94 95 96 97 |
# File 'lib/uniprop/value_group.rb', line 89 def string_value_including_codepoints(value) result = [] values_to_codepoints.each do |values, codepoints| if values.include?(value) result.concat(codepoints) end end result end |
#value_including_codepoints(value) ⇒ Array<Integer>
Note:
プロパティ値のエイリアスも加味して探索
valueをプロパティ値に持つコードポイントを取得
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/uniprop/value_group.rb', line 103 def value_including_codepoints(value) # プロパティが列挙型の場合、プロパティ値の全エイリアスを確かめる pvs = [] properties.each { pvs<<_1.find_property_value(value) if _1.has_property_value?(value) } if pvs.empty? string_value_including_codepoints(value) else # propertiesのプロパティに結びつくPropertyValueのうち # valueをエイリアスに持つPropertyValueの全エイリアスに対し # string_value_including_codepointsを実行して和集合を取る result = [] pvs.each do |pv| result |= pv.uncanonicaled_aliases .map { string_value_including_codepoints(_1) } .reduce([], :|) end result end end |