Class: Zelda::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/zelda/base.rb

Overview

Abstract base class to provide common functionality of Zelda importer classes. Every key in the hash is turned into a method, returning the value.

Direct Known Subclasses

Aflevering, Omroep, Serie, Zender

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Base

Returns a new instance of Base.



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/zelda/base.rb', line 5

def initialize(attributes={})
  @attributes = attributes
  
  @attributes.each_pair do |key, value|
    self.class.send(:define_method, key) do
      if @attributes[key].is_a?(String)
        @attributes[key].force_encoding("UTF-8")
      else
        @attributes[key]
      end
    end
  end
end