Class: JekyllImport::Importers::CSV::CSVPost
- Inherits:
-
Object
- Object
- JekyllImport::Importers::CSV::CSVPost
- Defined in:
- lib/jekyll-import/importers/csv.rb
Constant Summary collapse
- MissingDataError =
Class.new(RuntimeError)
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#markup ⇒ Object
readonly
Returns the value of attribute markup.
-
#permalink ⇒ Object
readonly
Returns the value of attribute permalink.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #filename ⇒ Object
-
#initialize(row) ⇒ CSVPost
constructor
Creates a CSVPost.
- #missing_data(message) ⇒ Object
- #published_at ⇒ Object
Constructor Details
#initialize(row) ⇒ CSVPost
Creates a CSVPost
row - Array of data, length of 4 or 5 with the columns:
1. title
2. permalink
3. body
4. published_at
5. markup (markdown, textile)
50 51 52 53 54 55 56 |
# File 'lib/jekyll-import/importers/csv.rb', line 50 def initialize(row) @title = row[0] || missing_data("Post title not present in first column.") @permalink = row[1] || missing_data("Post permalink not present in second column.") @body = row[2] || missing_data("Post body not present in third column.") @published_at = row[3] || missing_data("Post publish date not present in fourth column.") @markup = row[4] || "markdown" end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
37 38 39 |
# File 'lib/jekyll-import/importers/csv.rb', line 37 def body @body end |
#markup ⇒ Object (readonly)
Returns the value of attribute markup.
37 38 39 |
# File 'lib/jekyll-import/importers/csv.rb', line 37 def markup @markup end |
#permalink ⇒ Object (readonly)
Returns the value of attribute permalink.
37 38 39 |
# File 'lib/jekyll-import/importers/csv.rb', line 37 def permalink @permalink end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
37 38 39 |
# File 'lib/jekyll-import/importers/csv.rb', line 37 def title @title end |
Instance Method Details
#filename ⇒ Object
66 67 68 |
# File 'lib/jekyll-import/importers/csv.rb', line 66 def filename "#{published_at.strftime("%Y-%m-%d")}-#{File.basename(permalink, ".*")}.#{markup}" end |
#missing_data(message) ⇒ Object
70 71 72 |
# File 'lib/jekyll-import/importers/csv.rb', line 70 def missing_data() raise MissingDataError, end |
#published_at ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/jekyll-import/importers/csv.rb', line 58 def published_at if @published_at && !@published_at.is_a?(DateTime) @published_at = DateTime.parse(@published_at) else @published_at end end |