Sha256: 7e42741a6744a9f5dbd0ead8a279a63a5f0b5c3002e22007b945b685e51dc0bf

Contents?: true

Size: 412 Bytes

Versions: 6

Compression:

Stored size: 412 Bytes

Contents

# frozen_string_literal: true
module PhoneSites
  class Base
    def initialize(data)
      parseable_fields.each do |name|
        public_send("#{name}=", parse(data, name))
      end
    end

    def parse(_, _)
      raise NotImplementedError
    end

    def self.parseable_attributes(*names)
      names.each { |name| attr_accessor name }
      define_method("parseable_fields") { names }
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
phone_sites-0.1.2 lib/phone_sites/base.rb
phone_sites-0.1.1 lib/phone_sites/base.rb
phone_sites-0.1.0 lib/phone_sites/base.rb
phone_sites-0.0.5 lib/phone_sites/base.rb
phone_sites-0.0.5a lib/phone_sites/base.rb
phone_sites-0.0.4 lib/phone_sites/base.rb