Class: QiitaMatome::Article

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

Overview

QiitaMatome::Article

Constant Summary collapse

YMDHMS_DATETIME_FORMAT =
'%Y/%m/%d %H:%M:%S'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) {|_self| ... } ⇒ Article

rubocop:disable MethodLength

Yields:

  • (_self)

Yield Parameters:



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/models/article.rb', line 10

def initialize(options = {})
  @uuid = options['uuid']
  @user = options['user']
  @title = options['title']
  @uuid = options['uuid']
  c_at = options['created_at']
  u_at = options['updated_at']
  @created_at = DateTime.parse(c_at) unless c_at.nil?
  @updated_at = DateTime.parse(u_at) unless u_at.nil?
  @tags = options['tags']
  @stock_count = options['stock_count']
  yield(self) if block_given?
end

Instance Attribute Details

#created_atObject

rubocop:disable LineLength



7
8
9
# File 'lib/models/article.rb', line 7

def created_at
  @created_at
end

#stock_countObject

rubocop:disable LineLength



7
8
9
# File 'lib/models/article.rb', line 7

def stock_count
  @stock_count
end

#tagsObject

rubocop:disable LineLength



7
8
9
# File 'lib/models/article.rb', line 7

def tags
  @tags
end

#titleObject

rubocop:disable LineLength



7
8
9
# File 'lib/models/article.rb', line 7

def title
  @title
end

#updated_atObject

rubocop:disable LineLength



7
8
9
# File 'lib/models/article.rb', line 7

def updated_at
  @updated_at
end

#userObject

rubocop:disable LineLength



7
8
9
# File 'lib/models/article.rb', line 7

def user
  @user
end

#uuidObject

rubocop:disable LineLength



7
8
9
# File 'lib/models/article.rb', line 7

def uuid
  @uuid
end

Instance Method Details

#created_at_ymdhmsObject

rubocop:enable MethodLength



25
26
27
# File 'lib/models/article.rb', line 25

def created_at_ymdhms
  @created_at.strftime(YMDHMS_DATETIME_FORMAT)
end


33
34
35
36
# File 'lib/models/article.rb', line 33

def title_link
  url_name = user['url_name']
  "[#{title.gsub('|', '')}](http://qiita.com/#{url_name}/items/#{uuid})"
end

#updated_at_ymdhmsObject



29
30
31
# File 'lib/models/article.rb', line 29

def updated_at_ymdhms
  @updated_at.strftime(YMDHMS_DATETIME_FORMAT)
end