Sha256: 010691b81ec4c5bea66535aba9e13fe02af25d0d1141e1548f7aa7fec2f28231

Contents?: true

Size: 539 Bytes

Versions: 2

Compression:

Stored size: 539 Bytes

Contents

module Zelda
  # Abstract base class to provide common functionality of Zelda importer classes.
  # Every key in the hash is turned into a method, returning the value.
  class Base
    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
zelda-1.4.0 lib/zelda/base.rb
zelda-1.3.0 lib/zelda/base.rb