Class: SocialNet::Byte::Models::Post

Inherits:
Object
  • Object
show all
Defined in:
lib/social_net/byte/models/post.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Post

Returns a new instance of Post.



21
22
23
# File 'lib/social_net/byte/models/post.rb', line 21

def initialize(attrs = {})
  attrs.each{|k, v| instance_variable_set("@#{k}", v) unless v.nil?}
end

Instance Attribute Details

#author_idObject (readonly)

Returns the value of attribute author_id.



8
9
10
# File 'lib/social_net/byte/models/post.rb', line 8

def author_id
  @author_id
end

#captionObject (readonly)

Returns the value of attribute caption.



8
9
10
# File 'lib/social_net/byte/models/post.rb', line 8

def caption
  @caption
end

#categoryObject (readonly)

Returns the value of attribute category.



8
9
10
# File 'lib/social_net/byte/models/post.rb', line 8

def category
  @category
end

#comment_countObject (readonly)

Returns the value of attribute comment_count.



8
9
10
# File 'lib/social_net/byte/models/post.rb', line 8

def comment_count
  @comment_count
end

#commentsObject (readonly)

Returns the value of attribute comments.



8
9
10
# File 'lib/social_net/byte/models/post.rb', line 8

def comments
  @comments
end

#dateObject (readonly)

Returns the value of attribute date.



8
9
10
# File 'lib/social_net/byte/models/post.rb', line 8

def date
  @date
end

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/social_net/byte/models/post.rb', line 8

def id
  @id
end

#like_countObject (readonly)

Returns the value of attribute like_count.



8
9
10
# File 'lib/social_net/byte/models/post.rb', line 8

def like_count
  @like_count
end

#loop_countObject (readonly)

Returns the value of attribute loop_count.



8
9
10
# File 'lib/social_net/byte/models/post.rb', line 8

def loop_count
  @loop_count
end

#mentionsObject (readonly)

Returns the value of attribute mentions.



8
9
10
# File 'lib/social_net/byte/models/post.rb', line 8

def mentions
  @mentions
end

#thumb_srcObject (readonly)

Returns the value of attribute thumb_src.



8
9
10
# File 'lib/social_net/byte/models/post.rb', line 8

def thumb_src
  @thumb_src
end

#video_srcObject (readonly)

Returns the value of attribute video_src.



8
9
10
# File 'lib/social_net/byte/models/post.rb', line 8

def video_src
  @video_src
end

Class Method Details

.find_by(params = {}) ⇒ SocialNet::Byte::Models::post?

Returns the existing Byte post matching the provided attributes or nil when the post is not found.

Parameters:

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

    the attributes to find a post by.

Options Hash (params):

  • :id (String)

    The Byte post’s id (case-insensitive).

Returns:

  • (SocialNet::Byte::Models::post)

    when the post is found.

  • (nil)

    when the post is not found.



33
34
35
36
37
# File 'lib/social_net/byte/models/post.rb', line 33

def self.find_by(params = {})
  find_by! params
rescue Errors::UnknownPost
  nil
end

.find_by!(params = {}) ⇒ SocialNet::Byte::Models::Post

Returns the existing Byte post matching the provided attributes or nil when the post is not found, and raises an error when the post is not found.

Parameters:

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

    the attributes to find a post by.

Options Hash (params):

  • :id (String)

    The Byte post id (case-sensitive).

Returns:

Raises:

  • (SocialNet::Errors::UnknownPost)

    if the post is unknown.



47
48
49
50
51
# File 'lib/social_net/byte/models/post.rb', line 47

def self.find_by!(params = {})
  if params[:id]
    find_by_id! params[:id]
  end
end