Class: Feedbook::Post

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ NilClass

Initializes new Post from opts Hash

Parameters:

  • opts (defaults to: {})

    {} [Hash] Hash with params required for Post creation



10
11
12
13
14
15
16
# File 'lib/feedbook/post.rb', line 10

def initialize(opts = {})
  @author     = opts.fetch(:author)
  @published  = opts.fetch(:published)
  @url        = opts.fetch(:url)
  @title      = opts.fetch(:title)
  @feed_title = opts.fetch(:feed_title)
end

Instance Attribute Details

#authorObject (readonly)

Returns the value of attribute author.



4
5
6
# File 'lib/feedbook/post.rb', line 4

def author
  @author
end

#feed_titleObject (readonly)

Returns the value of attribute feed_title.



4
5
6
# File 'lib/feedbook/post.rb', line 4

def feed_title
  @feed_title
end

#publishedObject (readonly)

Returns the value of attribute published.



4
5
6
# File 'lib/feedbook/post.rb', line 4

def published
  @published
end

#titleObject (readonly)

Returns the value of attribute title.



4
5
6
# File 'lib/feedbook/post.rb', line 4

def title
  @title
end

#urlObject (readonly)

Returns the value of attribute url.



4
5
6
# File 'lib/feedbook/post.rb', line 4

def url
  @url
end

Instance Method Details

#to_hashHash Also known as: to_h

Returns hash with values from posts.

Returns:

  • (Hash)

    Hash with post variables



21
22
23
24
25
26
27
28
29
# File 'lib/feedbook/post.rb', line 21

def to_hash
  {
    'author'     => author,
    'published'  => published,
    'url'        => url,
    'title'      => title,
    'feed_title' => feed_title
  }
end