Class: Camdram::Organisation

Inherits:
Base
  • Object
show all
Includes:
API
Defined in:
lib/camdram/organisation.rb

Instance Attribute Summary collapse

Attributes included from API

#http

Attributes inherited from Base

#id

Class Method Summary collapse

Instance Method Summary collapse

Methods included from API

#update!

Constructor Details

#initialize(options = {}) ⇒ Camdram::Organisation

Instantiate a new Organisation object from a JSON hash

Parameters:

  • options (Hash) (defaults to: {})

    A single JSON hash with symbolized keys.



17
18
19
20
# File 'lib/camdram/organisation.rb', line 17

def initialize(options = {})
  super(options)
  @image = Image.new( @image ) unless @image.nil?
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



11
12
13
# File 'lib/camdram/organisation.rb', line 11

def description
  @description
end

#facebook_idObject

Returns the value of attribute facebook_id.



11
12
13
# File 'lib/camdram/organisation.rb', line 11

def facebook_id
  @facebook_id
end

#imageObject

Returns the value of attribute image.



11
12
13
# File 'lib/camdram/organisation.rb', line 11

def image
  @image
end

#nameObject

Returns the value of attribute name.



11
12
13
# File 'lib/camdram/organisation.rb', line 11

def name
  @name
end

#short_nameObject

Returns the value of attribute short_name.



11
12
13
# File 'lib/camdram/organisation.rb', line 11

def short_name
  @short_name
end

#slugObject

Returns the value of attribute slug.



11
12
13
# File 'lib/camdram/organisation.rb', line 11

def slug
  @slug
end

#twitter_idObject

Returns the value of attribute twitter_id.



11
12
13
# File 'lib/camdram/organisation.rb', line 11

def twitter_id
  @twitter_id
end

Class Method Details

.urlString

Returns the URL stub assocaited with all organisations

Returns:

  • (String)

    The URL stub.



74
75
76
# File 'lib/camdram/organisation.rb', line 74

def self.url
  '/societies'
end

Instance Method Details

#diaryCamdram::Diary

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

Returns:



58
59
60
61
62
# File 'lib/camdram/organisation.rb', line 58

def diary()
  url = "#{self.class.url}/#{slug}/diary.json"
  response = get(url)
  Diary.new(response)
end

#infoHash

Return a hash of the organisation's attributes

Returns:

  • (Hash)

    Hash with symbolized keys.



25
26
27
28
29
30
31
32
33
34
35
# 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

#newsArray

Gets an array of the organisation's news items

Returns:

  • (Array)

    An array of News objects.



40
41
42
43
44
# 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

#showsArray

Gets an array of the organisation's upcoming shows

Returns:

  • (Array)

    An array of Show objects.



49
50
51
52
53
# 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_slugString

Returns the URL+slug of the organisation

Returns:

  • (String)

    The full URL and slug.



67
68
69
# File 'lib/camdram/organisation.rb', line 67

def url_slug
  "#{self.class.url}/#{slug}.json"
end