Class: Fontist::Import::Google::MetadataAdapter::MessageWrapper
- Inherits:
-
Object
- Object
- Fontist::Import::Google::MetadataAdapter::MessageWrapper
- Defined in:
- lib/fontist/import/google/metadata_adapter.rb
Overview
Helper class to wrap hash as queryable message
Instance Method Summary collapse
- #find_field(name) ⇒ Object
- #find_fields(name) ⇒ Object
-
#initialize(hash) ⇒ MessageWrapper
constructor
A new instance of MessageWrapper.
Constructor Details
#initialize(hash) ⇒ MessageWrapper
Returns a new instance of MessageWrapper.
190 191 192 |
# File 'lib/fontist/import/google/metadata_adapter.rb', line 190 def initialize(hash) @fields_data = hash["fields"] || [] end |
Instance Method Details
#find_field(name) ⇒ Object
194 195 196 197 198 199 |
# File 'lib/fontist/import/google/metadata_adapter.rb', line 194 def find_field(name) field_data = @fields_data.find { |f| f["name"] == name } return nil unless field_data FieldWrapper.new(field_data) end |
#find_fields(name) ⇒ Object
201 202 203 204 205 |
# File 'lib/fontist/import/google/metadata_adapter.rb', line 201 def find_fields(name) @fields_data.select do |f| f["name"] == name end.map { |f| FieldWrapper.new(f) } end |