class Camdram::Organisation

Attributes

description[RW]
facebook_id[RW]
image[RW]
name[RW]
short_name[RW]
slug[RW]
twitter_id[RW]

Public Class Methods

new(options = {}) click to toggle source

Instantiate a new Organisation object from a JSON hash

@param options [Hash] A single JSON hash with symbolized keys. @return [Camdram::Organisation] The new Organisation object.

Calls superclass method Camdram::API::new
# File lib/camdram/organisation.rb, line 17
def initialize(options = {})
  super(options)
  @image = Image.new( @image ) unless @image.nil?
end
url() click to toggle source

Returns the URL stub assocaited with all organisations

@return [String] The URL stub.

# File lib/camdram/organisation.rb, line 74
def self.url
  '/societies'
end

Public Instance Methods

diary() click to toggle source

Gets a diary object which contains an array of upcoming calendar events for the organisation

@return [Camdram::Diary] A Diary object.

# File lib/camdram/organisation.rb, line 58
def diary()
  url = "#{self.class.url}/#{slug}/diary.json"
  response = get(url)
  Diary.new(response)
end
info() click to toggle source

Return a hash of the organisation's attributes

@return [Hash] Hash with symbolized keys.

# File lib/camdram/organisation.rb, line 25
def info
  {
    id: id,
    name: name,
    description: description,
    facebook_id: facebook_id,
    twitter_id: twitter_id,
    short_name: short_name,
    slug: slug,
  }
end
news() click to toggle source

Gets an array of the organisation's news items

@return [Array] An array of News objects.

# File lib/camdram/organisation.rb, line 40
def news
  news_url = "#{self.class.url}/#{slug}/news.json"
  response = get(news_url)
  split_object( response, News )
end
shows() click to toggle source

Gets an array of the organisation's upcoming shows

@return [Array] An array of Show objects.

# File lib/camdram/organisation.rb, line 49
def shows
  shows_url = "#{self.class.url}/#{slug}/shows.json"
  response = get(shows_url)
  split_object( response, Show )
end
url_slug() click to toggle source

Returns the URL+slug of the organisation

@return [String] The full URL and slug.

# File lib/camdram/organisation.rb, line 67
def url_slug
  "#{self.class.url}/#{slug}.json"
end