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
3 4 5 |
# File 'lib/mw_dictionary_api/parsable.rb', line 3 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#initialize(**options) ⇒ Object
33 34 35 |
# File 'lib/mw_dictionary_api/parsable.rb', line 33 def initialize(**) @options = end |
#parse(data) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/mw_dictionary_api/parsable.rb', line 37 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 |