Class: Camdram::Society

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

Instance Attribute Summary collapse

Attributes inherited from Base

#id

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Refreshable

#refresh!

Methods inherited from Base

#make_orphan

Constructor Details

#initialize(*args) ⇒ Camdram::Society

Instantiate a new Society object from a JSON hash

Parameters:

  • options (Hash)

    A single JSON hash with symbolized keys.


20
21
22
23
# File 'lib/camdram/society.rb', line 20

def initialize(*args)
  super(*args)
  @image = Image.new(@image, @client_instance) unless @image.nil?
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description


14
15
16
# File 'lib/camdram/society.rb', line 14

def description
  @description
end

#facebook_idObject

Returns the value of attribute facebook_id


14
15
16
# File 'lib/camdram/society.rb', line 14

def facebook_id
  @facebook_id
end

#imageObject

Returns the value of attribute image


14
15
16
# File 'lib/camdram/society.rb', line 14

def image
  @image
end

#nameObject

Returns the value of attribute name


14
15
16
# File 'lib/camdram/society.rb', line 14

def name
  @name
end

#short_nameObject

Returns the value of attribute short_name


14
15
16
# File 'lib/camdram/society.rb', line 14

def short_name
  @short_name
end

#slugObject

Returns the value of attribute slug


14
15
16
# File 'lib/camdram/society.rb', line 14

def slug
  @slug
end

#theme_colorObject

Returns the value of attribute theme_color


14
15
16
# File 'lib/camdram/society.rb', line 14

def theme_color
  @theme_color
end

#twitter_idObject

Returns the value of attribute twitter_id


14
15
16
# File 'lib/camdram/society.rb', line 14

def twitter_id
  @twitter_id
end

Class Method Details

.urlString

Returns the URL stub assocaited with all societies

Returns:

  • (String)

    The URL stub.


85
86
87
# File 'lib/camdram/society.rb', line 85

def self.url
  '/societies'
end

Instance Method Details

#diary(from = nil, to = nil) ⇒ Camdram::Diary

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

Returns:


65
66
67
68
69
70
71
72
73
# File 'lib/camdram/society.rb', line 65

def diary(from = nil, to = nil)
  url = "#{self.class.url}/#{slug}/diary.json"
  url += "?" if from || to
  url += "from=#{from}" if from
  url += "&" if from && to
  url += "to=#{to}" if to
  response = get(url)
  Diary.new(response, @client_instance)
end

#infoHash

Return a hash of the society's attributes

Returns:

  • (Hash)

    Hash with symbolized keys.


28
29
30
31
32
33
34
35
36
37
38
# File 'lib/camdram/society.rb', line 28

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 society's news items

Returns:

  • (Array)

    An array of News objects.


43
44
45
46
47
# File 'lib/camdram/society.rb', line 43

def news
  url = "#{self.class.url}/#{slug}/news.json"
  response = get(url)
  split_object(response, News)
end

#shows(from = nil, to = nil) ⇒ Array

Gets an array of the society's upcoming shows

Returns:

  • (Array)

    An array of Show objects.


52
53
54
55
56
57
58
59
60
# File 'lib/camdram/society.rb', line 52

def shows(from = nil, to = nil)
  url = "#{self.class.url}/#{slug}/shows.json"
  url += "?" if from || to
  url += "from=#{from}" if from
  url += "&" if from && to
  url += "to=#{to}" if to
  response = get(url)
  split_object(response, Show)
end

#url_slugString

Returns the URL+slug of the society

Returns:

  • (String)

    The full URL and slug.


78
79
80
# File 'lib/camdram/society.rb', line 78

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