Class: Feedbook::Post
- Inherits:
-
Object
- Object
- Feedbook::Post
- Defined in:
- lib/feedbook/post.rb
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#feed_title ⇒ Object
readonly
Returns the value of attribute feed_title.
-
#published ⇒ Object
readonly
Returns the value of attribute published.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ NilClass
constructor
Initializes new Post from opts Hash.
-
#to_hash ⇒ Hash
(also: #to_h)
Returns hash with values from posts.
Constructor Details
#initialize(opts = {}) ⇒ NilClass
Initializes new Post from opts Hash
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
#author ⇒ Object (readonly)
Returns the value of attribute author.
4 5 6 |
# File 'lib/feedbook/post.rb', line 4 def @author end |
#feed_title ⇒ Object (readonly)
Returns the value of attribute feed_title.
4 5 6 |
# File 'lib/feedbook/post.rb', line 4 def feed_title @feed_title end |
#published ⇒ Object (readonly)
Returns the value of attribute published.
4 5 6 |
# File 'lib/feedbook/post.rb', line 4 def published @published end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
4 5 6 |
# File 'lib/feedbook/post.rb', line 4 def title @title end |
#url ⇒ Object (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_hash ⇒ Hash Also known as: to_h
Returns hash with values from posts.
21 22 23 24 25 26 27 28 29 |
# File 'lib/feedbook/post.rb', line 21 def to_hash { 'author' => , 'published' => published, 'url' => url, 'title' => title, 'feed_title' => feed_title } end |