Class: UniProp::MetaData
- Inherits:
-
Object
- Object
- UniProp::MetaData
- Defined in:
- lib/uniprop/inspects.rb,
lib/uniprop/metadata_processor.rb
Instance Attribute Summary collapse
-
#metadata_path ⇒ Object
readonly
Returns the value of attribute metadata_path.
-
#prop_data ⇒ Object
readonly
Returns the value of attribute prop_data.
-
#raw_metadata ⇒ Object
readonly
Returns the value of attribute raw_metadata.
Instance Method Summary collapse
-
#find_raw_version_metadata(version_name) ⇒ Hash<String,Object>
メタデータから、version_nameと同じweightのバージョンに関する記述を取得.
- #has_raw_version_metadata?(version_name) ⇒ Boolean
-
#initialize(prop_data, metadata_path) ⇒ MetaData
constructor
A new instance of MetaData.
- #inspect ⇒ Object
- #metadata_validator ⇒ MetaDataValidator
- #raw_version_metadatas ⇒ Array<Hash<String,Object>>
-
#version_names(update_metadata: false, confirm: false) ⇒ Array<String>
メタデータのversion_names項目の値を取得。メタデータにこの項目が記述されていない場合、Unicode.orgからバージョン一覧を取得.
Constructor Details
#initialize(prop_data, metadata_path) ⇒ MetaData
Returns a new instance of MetaData.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/uniprop/metadata_processor.rb', line 7 def initialize(prop_data, ) @prop_data = prop_data = if .exist? = JSON.parse(File.read()) else raise FileNotFoundError, "#{@metadata_path} is not found." end end |
Instance Attribute Details
#metadata_path ⇒ Object (readonly)
Returns the value of attribute metadata_path.
3 4 5 |
# File 'lib/uniprop/metadata_processor.rb', line 3 def end |
#prop_data ⇒ Object (readonly)
Returns the value of attribute prop_data.
3 4 5 |
# File 'lib/uniprop/metadata_processor.rb', line 3 def prop_data @prop_data end |
#raw_metadata ⇒ Object (readonly)
Returns the value of attribute raw_metadata.
3 4 5 |
# File 'lib/uniprop/metadata_processor.rb', line 3 def end |
Instance Method Details
#find_raw_version_metadata(version_name) ⇒ Hash<String,Object>
メタデータから、version_nameと同じweightのバージョンに関する記述を取得
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/uniprop/metadata_processor.rb', line 45 def (version_name) weight = Version.name_to_weight(version_name) result = .find { Version.name_to_weight(_1["version_name"])==weight } if result return result else raise MetaDataNotFoundError, "metadata for #{version_name} is not found." end end |
#has_raw_version_metadata?(version_name) ⇒ Boolean
57 58 59 60 61 |
# File 'lib/uniprop/metadata_processor.rb', line 57 def (version_name) !!(version_name) rescue false end |
#inspect ⇒ Object
49 50 51 |
# File 'lib/uniprop/inspects.rb', line 49 def inspect "#<#{self.class.name}>" end |
#metadata_validator ⇒ MetaDataValidator
64 65 66 67 |
# File 'lib/uniprop/metadata_processor.rb', line 64 def ||= MetaDataValidator.new(self) end |
#raw_version_metadatas ⇒ Array<Hash<String,Object>>
38 39 40 |
# File 'lib/uniprop/metadata_processor.rb', line 38 def ||= ["version_metadatas"].sort { Version.name_to_weight(_1["version_name"]) } end |
#version_names(update_metadata: false, confirm: false) ⇒ Array<String>
メタデータのversion_names項目の値を取得。メタデータにこの項目が記述されていない場合、Unicode.orgからバージョン一覧を取得
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/uniprop/metadata_processor.rb', line 22 def version_names(update_metadata: false, confirm: false) if confirm || ["version_names"].nil? || ["version_names"].empty? actual_version_names = UniPropUtils::DownloaderWrapper.get_version_names if ["version_names"] = actual_version_names prop_data.() end return actual_version_names else return ["version_names"] end end |