Class: Camdram::News

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

Instance Attribute Summary collapse

Attributes inherited from Base

#id

Instance Method Summary collapse

Methods inherited from Base

#make_orphan

Constructor Details

#initialize(*args) ⇒ Camdram::News

Instantiate a new News object from a JSON hash

Parameters:

  • options (Hash)

    A single JSON hash with symbolized keys.


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

def initialize(*args)
  super(*args)
  @entity = case @entity[:_type]
    when "society" then Society.new(@entity, @client_instance)
    when "venue" then Venue.new(@entity, @client_instance)
  end unless @entity.nil?
  @posted_at = DateTime.parse(@posted_at) unless @posted_at.nil?
  @created_at = DateTime.parse(@created_at) unless @created_at.nil?
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body


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

def body
  @body
end

#created_atObject

Returns the value of attribute created_at


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

def created_at
  @created_at
end

#entityObject

Returns the value of attribute entity


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

def entity
  @entity
end

#pictureObject

Returns the value of attribute picture


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

def picture
  @picture
end

#posted_atObject

Returns the value of attribute posted_at


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

def posted_at
  @posted_at
end

#remote_idObject

Returns the value of attribute remote_id


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

def remote_id
  @remote_id
end

#sourceObject

Returns the value of attribute source


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

def source
  @source
end

Instance Method Details

#infoHash

Return a hash of the news item's attributes

Returns:

  • (Hash)

    Hash with symbolized keys.


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

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