Class: MediumExport::Content
- Inherits:
-
Object
- Object
- MediumExport::Content
- Defined in:
- lib/middleman-medium_export/content.rb
Defined Under Namespace
Classes: Image
Instance Attribute Summary collapse
-
#article ⇒ Object
readonly
Returns the value of attribute article.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
- #html ⇒ Object
-
#initialize(article:, template: nil) ⇒ Content
constructor
A new instance of Content.
- #local_images ⇒ Object
- #markdown ⇒ Object
- #tags ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(article:, template: nil) ⇒ Content
Returns a new instance of Content.
8 9 10 11 |
# File 'lib/middleman-medium_export/content.rb', line 8 def initialize(article:, template: nil) @article = article @template = template end |
Instance Attribute Details
#article ⇒ Object (readonly)
Returns the value of attribute article.
6 7 8 |
# File 'lib/middleman-medium_export/content.rb', line 6 def article @article end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
6 7 8 |
# File 'lib/middleman-medium_export/content.rb', line 6 def template @template end |
Instance Method Details
#html ⇒ Object
13 14 15 16 17 |
# File 'lib/middleman-medium_export/content.rb', line 13 def html @content ||= begin template ? body_with_template : article.body end end |
#local_images ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/middleman-medium_export/content.rb', line 31 def local_images @images ||= Nokogiri::HTML(html).search('img').map do |img| src = img.attributes['src'].value next if src.start_with?('http') Image.new(src, File.join(source_dir, src)) end.compact end |
#markdown ⇒ Object
19 20 21 |
# File 'lib/middleman-medium_export/content.rb', line 19 def markdown @markdown ||= File.read(article.source_file) end |
#tags ⇒ Object
27 28 29 |
# File 'lib/middleman-medium_export/content.rb', line 27 def article. end |
#title ⇒ Object
23 24 25 |
# File 'lib/middleman-medium_export/content.rb', line 23 def title article.title end |