Sha256: 56c8f851a25c0dcba5bb7c132742d6b638154aeb457c33420634abec16e68326

Contents?: true

Size: 715 Bytes

Versions: 5

Compression:

Stored size: 715 Bytes

Contents

class Rollin::Article
  attr_reader :id, :title, :year, :month, :day

  def initialize(source_file)
    @source_file = source_file
    filename = File.basename(@source_file)
    @id = filename[0, filename.length - 3]
    @title = filename[11, filename.length - 11 - 3].gsub('_', ' ')
    @year = filename[0, 4].to_i
    @month = filename[5, 2].to_i
    @day = filename[8, 2].to_i
  end

  def date
    Date.new(@year, @month, @day)
  end

  def body
    redcarpet = Redcarpet::Markdown.new(Redcarpet::Render::HTML,
                            autolink: true,
                            space_after_headers: true,
                            hard_wrap: true)
    redcarpet.render(File.read(@source_file))
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rollin-0.0.16 lib/rollin/article.rb
rollin-0.0.15 lib/rollin/article.rb
rollin-0.0.14 lib/rollin/article.rb
rollin-0.0.13 lib/rollin/article.rb
rollin-0.0.12 lib/rollin/article.rb