Sha256: 5e13a4af93c935afeeab3fbf0e8ae33e4974436d9bddb27ba620a673d2d30545

Contents?: true

Size: 743 Bytes

Versions: 2

Compression:

Stored size: 743 Bytes

Contents

# frozen_string_literal: true
require_relative 'kktix_api'
require_relative 'event'

module KktixEvent
  # Single organization on KKTIX
  class Organization
    attr_reader :oid, :name, :uri, :events

    def initialize(organization_data, oid: nil)
      update_info(organization_data, oid)
    end

    def self.find(oid = nil)
      organization_data = KktixEvent::KktixApi.events(oid)
      new(organization_data, oid: oid)
    end

    private

    def update_info(entry, oid)
      unless oid.nil?
        author = entry.first['author']
        @oid = oid
        @name = author['name']
        @uri = author['uri']
      end
      @events = entry.map do |event_data|
        KktixEvent::Event.new(event_data)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kktix_api-0.1.1 lib/kktix-api/organization.rb
kktix_api-0.1.0 lib/kktix-api/organization.rb