Module: MWDictionaryAPI::Parsable
- Included in:
- MWDictionaryAPI::Parsers::DefinitionParser, MWDictionaryAPI::Parsers::EntryParser, MWDictionaryAPI::Parsers::ResultParser
- Defined in:
- lib/mw_dictionary_api/parsable.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
5 6 7 |
# File 'lib/mw_dictionary_api/parsable.rb', line 5 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#initialize(**options) ⇒ Object
35 36 37 |
# File 'lib/mw_dictionary_api/parsable.rb', line 35 def initialize(**) @options = end |
#parse(data) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/mw_dictionary_api/parsable.rb', line 39 def parse(data) attributes = {} self.class.inherited_rules.each do |attr_name, rule| unless rule[:options][:hidden] = @options.merge(rule[:options]) attributes[attr_name] = rule[:block].call(data, ) end end attributes end |