Class: Mako::Article
- Inherits:
-
Object
- Object
- Mako::Article
- Defined in:
- lib/mako/article.rb
Instance Attribute Summary collapse
-
#published ⇒ Object
readonly
Returns the value of attribute published.
-
#summary ⇒ Object
readonly
Returns the value of attribute summary.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#formatted_published ⇒ String
Converts published Time object to formatted string.
-
#initialize(args) ⇒ Article
constructor
A new instance of Article.
-
#url ⇒ String
Converts URI object into string.
Constructor Details
#initialize(args) ⇒ Article
Returns a new instance of Article.
7 8 9 10 11 12 |
# File 'lib/mako/article.rb', line 7 def initialize(args) @title = args.fetch(:title, '') @published = args.fetch(:published) @uri = URI.parse(args.fetch(:url)) @summary = sanitize(args.fetch(:summary)) end |
Instance Attribute Details
#published ⇒ Object (readonly)
Returns the value of attribute published.
5 6 7 |
# File 'lib/mako/article.rb', line 5 def published @published end |
#summary ⇒ Object (readonly)
Returns the value of attribute summary.
5 6 7 |
# File 'lib/mako/article.rb', line 5 def summary @summary end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
5 6 7 |
# File 'lib/mako/article.rb', line 5 def title @title end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
5 6 7 |
# File 'lib/mako/article.rb', line 5 def uri @uri end |
Instance Method Details
#formatted_published ⇒ String
Converts published Time object to formatted string
17 18 19 |
# File 'lib/mako/article.rb', line 17 def formatted_published @published.strftime('%A, %d %B %Y at %I:%M %P') end |
#url ⇒ String
Converts URI object into string
24 25 26 |
# File 'lib/mako/article.rb', line 24 def url uri.to_s end |