Class: Mako::Article

Inherits:
Object
  • Object
show all
Defined in:
lib/mako/article.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#publishedObject (readonly)

Returns the value of attribute published.



5
6
7
# File 'lib/mako/article.rb', line 5

def published
  @published
end

#summaryObject (readonly)

Returns the value of attribute summary.



5
6
7
# File 'lib/mako/article.rb', line 5

def summary
  @summary
end

#titleObject (readonly)

Returns the value of attribute title.



5
6
7
# File 'lib/mako/article.rb', line 5

def title
  @title
end

#uriObject (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_publishedString

Converts published Time object to formatted string

Returns:

  • (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

#urlString

Converts URI object into string

Returns:

  • (String)


24
25
26
# File 'lib/mako/article.rb', line 24

def url
  uri.to_s
end