Class: YammerApi::Post

Inherits:
Base
  • Object
show all
Defined in:
lib/yammer_api/post.rb

Instance Attribute Summary

Attributes inherited from Base

#attrs

Instance Method Summary collapse

Methods inherited from Base

#[], #initialize, lazy_attr_reader

Constructor Details

This class inherits a constructor from YammerApi::Base

Instance Method Details

#attachmentObject

Returns Hashie::Mash.

Returns:

  • Hashie::Mash



7
8
9
10
11
12
13
14
15
16
# File 'lib/yammer_api/post.rb', line 7

def attachment
  attachment = @attrs['attachments'].first
  if attachment
    if attachment['type'] == "image"
      @attachment ||= Mash.new(type: "image", id: attachment["id"], image_url: attachment.fetch("image", {"url" => ""}).fetch("url"))
    else
      @attachment ||= Mash.new(type: attachment['type'], name: attachment['name'], id: attachment["id"], image_url: attachment["large_icon_url"], url: attachment["download_url"])
    end
  end
end

#posted_atObject

Returns Time.

Returns:

  • Time



19
20
21
22
# File 'lib/yammer_api/post.rb', line 19

def posted_at
  #puts @attrs['created_at']
  @posted_at ||= Time.parse(@attrs['created_at']).utc unless @attrs['created_at'].nil?
end

#recipientObject

Returns YammerApi::User.

Returns:

  • YammerApi::User



35
36
37
# File 'lib/yammer_api/post.rb', line 35

def recipient
  @recipient ||= YammerApi::User.new(@attrs['recipient']) if @attrs['recipient']
end

#textObject

Returns String.

Returns:

  • String



25
26
27
# File 'lib/yammer_api/post.rb', line 25

def text
  @text ||= @attrs['body']['plain'] if @attrs['body'] && @attrs['body']['plain']
end

#userObject

Returns YammerApi::User.

Returns:

  • YammerApi::User



30
31
32
# File 'lib/yammer_api/post.rb', line 30

def user
  @user ||= YammerApi::User.new(@attrs['sender']) if @attrs['sender']
end