Class: KCNA::Article
- Inherits:
-
Object
- Object
- KCNA::Article
- Defined in:
- lib/kcna/article.rb
Overview
Represents an article.
Instance Attribute Summary collapse
-
#content ⇒ String
readonly
Content of the article.
-
#date ⇒ Date
readonly
Date of the article.
- #display_title ⇒ String readonly
-
#id ⇒ String
readonly
ID of the article.
-
#main_title ⇒ String
readonly
Main title of the article.
-
#movie_count ⇒ Integer
readonly
The number of movies related to the article.
-
#music_count ⇒ Integer
readonly
The number of musics related to the article.
-
#photo_count ⇒ Integer
readonly
The number of photos related to the article.
-
#sub_title ⇒ String
readonly
Subtitle of the article.
Instance Method Summary collapse
-
#initialize(id, **attrs) ⇒ Article
constructor
A new instance of Article.
-
#to_h ⇒ Hash
Convert the article to a hash table.
Constructor Details
#initialize(id, **attrs) ⇒ Article
Returns a new instance of Article.
48 49 50 51 52 |
# File 'lib/kcna/article.rb', line 48 def initialize(id, **attrs) raise "id is not a string" unless id.kind_of?(String) @id = id @attrs = attrs end |
Instance Attribute Details
#content ⇒ String (readonly)
Returns content of the article.
19 |
# File 'lib/kcna/article.rb', line 19 attr_reader_hash :content |
#date ⇒ Date (readonly)
Returns date of the article.
16 |
# File 'lib/kcna/article.rb', line 16 attr_reader_hash :date |
#display_title ⇒ String (readonly)
28 |
# File 'lib/kcna/article.rb', line 28 attr_reader_hash :display_title |
#id ⇒ String (readonly)
Returns ID of the article.
4 5 6 |
# File 'lib/kcna/article.rb', line 4 def id @id end |
#main_title ⇒ String (readonly)
Returns main title of the article.
22 |
# File 'lib/kcna/article.rb', line 22 attr_reader_hash :main_title |
#movie_count ⇒ Integer (readonly)
Returns the number of movies related to the article.
31 |
# File 'lib/kcna/article.rb', line 31 attr_reader_hash :movie_count, 0 |
#music_count ⇒ Integer (readonly)
Returns the number of musics related to the article.
37 |
# File 'lib/kcna/article.rb', line 37 attr_reader_hash :music_count, 0 |
#photo_count ⇒ Integer (readonly)
Returns the number of photos related to the article.
34 |
# File 'lib/kcna/article.rb', line 34 attr_reader_hash :photo_count, 0 |
#sub_title ⇒ String (readonly)
Returns subtitle of the article.
25 |
# File 'lib/kcna/article.rb', line 25 attr_reader_hash :sub_title |
Instance Method Details
#to_h ⇒ Hash
Convert the article to a hash table.
56 57 58 |
# File 'lib/kcna/article.rb', line 56 def to_h self.class.instance_variable_get(:@attribute_keys).map { |k| [k, self.send(k)] }.to_h end |