Class: Zakuro::Operation::AnnotationParser
- Inherits:
-
Object
- Object
- Zakuro::Operation::AnnotationParser
- Defined in:
- lib/zakuro/operation/month/parser.rb
Overview
AnnotationParser 注釈解析
Instance Attribute Summary collapse
-
#annotations ⇒ Hash<String, Annotation>
readonly
注釈.
-
#relations ⇒ Hash<String, String>
readonly
関連注釈の対応関係.
Class Method Summary collapse
-
.resolve_history(hash: {}, annotations: {}, relations: {}) ⇒ Object
月別履歴情報から注釈情報を取り出す.
Instance Method Summary collapse
-
#create ⇒ Object
注釈を生成する.
-
#initialize(yaml_hash: {}) ⇒ AnnotationParser
constructor
初期化.
-
#specify(id: '') ⇒ Array<Annotation>
注釈を特定する.
Constructor Details
#initialize(yaml_hash: {}) ⇒ AnnotationParser
初期化
231 232 233 234 235 |
# File 'lib/zakuro/operation/month/parser.rb', line 231 def initialize(yaml_hash: {}) @annotations = {} @relations = {} @yaml_hash = yaml_hash end |
Instance Attribute Details
#annotations ⇒ Hash<String, Annotation> (readonly)
Returns 注釈.
222 223 224 |
# File 'lib/zakuro/operation/month/parser.rb', line 222 def annotations @annotations end |
#relations ⇒ Hash<String, String> (readonly)
Returns 関連注釈の対応関係.
224 225 226 |
# File 'lib/zakuro/operation/month/parser.rb', line 224 def relations @relations end |
Class Method Details
.resolve_history(hash: {}, annotations: {}, relations: {}) ⇒ Object
月別履歴情報から注釈情報を取り出す
256 257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/zakuro/operation/month/parser.rb', line 256 def resolve_history(hash: {}, annotations: {}, relations: {}) id = hash['id'] annotations[id] = Annotation.new( id: id, description: Operation::TypeParser.text(str: hash['description']), note: Operation::TypeParser.text(str: hash['note']) ) relation_id = hash['relation_id'] return if Operation::TypeParser.invalid?(str: relation_id) relations[id] = relation_id end |
Instance Method Details
#create ⇒ Object
注釈を生成する
240 241 242 243 244 245 246 |
# File 'lib/zakuro/operation/month/parser.rb', line 240 def create @yaml_hash.each do |month| AnnotationParser.resolve_history( hash: month, annotations: annotations, relations: relations ) end end |
#specify(id: '') ⇒ Array<Annotation>
注釈を特定する
278 279 280 281 |
# File 'lib/zakuro/operation/month/parser.rb', line 278 def specify(id: '') ids = [id, relations.fetch(id, '')] specify_by_ids(ids: ids) end |