Class: Trahald::Article
- Inherits:
-
Object
- Object
- Trahald::Article
- Defined in:
- lib/trahald/article.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, body, date) ⇒ Article
constructor
A new instance of Article.
- #to_h ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(name, body, date) ⇒ Article
Returns a new instance of Article.
7 8 9 10 11 |
# File 'lib/trahald/article.rb', line 7 def initialize(name, body, date) @name = name @body = body @date = date end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
6 7 8 |
# File 'lib/trahald/article.rb', line 6 def body @body end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
6 7 8 |
# File 'lib/trahald/article.rb', line 6 def date @date end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/trahald/article.rb', line 6 def name @name end |
Class Method Details
Instance Method Details
#to_h ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/trahald/article.rb', line 13 def to_h { :name => @name, :body => @body, :date => @date } end |
#to_json ⇒ Object
21 22 23 |
# File 'lib/trahald/article.rb', line 21 def to_json JSON.generate to_h end |