Class: Marti::MarticleParser

Inherits:
Object
  • Object
show all
Defined in:
lib/marti/services/marticle_parser.rb

Defined Under Namespace

Classes: LineResponse

Constant Summary collapse

CUT =
"--CUT--"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ MarticleParser

Returns a new instance of MarticleParser.



5
6
7
# File 'lib/marti/services/marticle_parser.rb', line 5

def initialize(file)
  @file = file
end

Instance Attribute Details

#articleObject (readonly)

Returns the value of attribute article.



3
4
5
# File 'lib/marti/services/marticle_parser.rb', line 3

def article
  @article
end

#fileObject (readonly)

Returns the value of attribute file.



3
4
5
# File 'lib/marti/services/marticle_parser.rb', line 3

def file
  @file
end

Instance Method Details

#parseObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/marti/services/marticle_parser.rb', line 9

def parse
  # clear article
  @article = Marticle.new
  set_article_time_from_file!

  content, extract = retrieve_content
  content = markdown.render(content.join("\n"))
  extract = markdown.render(extract.join("\n"))

  set('content', content)
  # Strip last \n from extract
  set('extract', extract.strip)
  article
end