Class: Camdram::News

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

Instance Attribute Summary collapse

Attributes included from API

#http

Attributes inherited from Base

#id

Instance Method Summary collapse

Methods included from API

#update!

Constructor Details

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

Instantiate a new News object from a JSON hash

Parameters:

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

    A single JSON hash with symbolized keys.



15
16
17
18
19
20
21
# File 'lib/camdram/news.rb', line 15

def initialize(options = {})
  super(options)
  @entity = case @entity[:_type]
    when "society" then Organisation.new( @entity )
    when "venue" then Venue.new( @entity )
  end unless @entity.nil?
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



9
10
11
# File 'lib/camdram/news.rb', line 9

def body
  @body
end

#created_atObject

Returns the value of attribute created_at.



9
10
11
# File 'lib/camdram/news.rb', line 9

def created_at
  @created_at
end

#entityObject

Returns the value of attribute entity.



9
10
11
# File 'lib/camdram/news.rb', line 9

def entity
  @entity
end

#pictureObject

Returns the value of attribute picture.



9
10
11
# File 'lib/camdram/news.rb', line 9

def picture
  @picture
end

#posted_atObject

Returns the value of attribute posted_at.



9
10
11
# File 'lib/camdram/news.rb', line 9

def posted_at
  @posted_at
end

#remote_idObject

Returns the value of attribute remote_id.



9
10
11
# File 'lib/camdram/news.rb', line 9

def remote_id
  @remote_id
end

#sourceObject

Returns the value of attribute source.



9
10
11
# File 'lib/camdram/news.rb', line 9

def source
  @source
end

Instance Method Details

#infoHash

Return a hash of the news item's attributes

Returns:

  • (Hash)

    Hash with symbolized keys.



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

def info
  {
    id: id,
    entity: entity,
    remote_id: remote_id,
    source: source,
    picture: picture,
    body: body,
    posted_at: posted_at,
    created_at: created_at,
  }
end