Class: PagecordCLI::ImageUploads
- Inherits:
-
Object
- Object
- PagecordCLI::ImageUploads
- Defined in:
- lib/pagecord_cli/image_uploads.rb
Constant Summary collapse
- MARKDOWN_IMAGE =
/!\[([^\]]*)\]\(([^)]+)\)/- OBSIDIAN_IMAGE =
/!\[\[([^\]]+)\]\]/- IMAGE_EXTENSIONS =
/\.(jpe?g|png|gif|webp)\z/i
Instance Attribute Summary collapse
-
#blog ⇒ Object
readonly
Returns the value of attribute blog.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
Instance Method Summary collapse
-
#initialize(content, file_path:, metadata:, blog:, client:) ⇒ ImageUploads
constructor
A new instance of ImageUploads.
- #process ⇒ Object
Constructor Details
#initialize(content, file_path:, metadata:, blog:, client:) ⇒ ImageUploads
Returns a new instance of ImageUploads.
13 14 15 16 17 18 19 |
# File 'lib/pagecord_cli/image_uploads.rb', line 13 def initialize(content, file_path:, metadata:, blog:, client:) @content = content @file_path = file_path @metadata = @blog = blog @client = client end |
Instance Attribute Details
#blog ⇒ Object (readonly)
Returns the value of attribute blog.
11 12 13 |
# File 'lib/pagecord_cli/image_uploads.rb', line 11 def blog @blog end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
11 12 13 |
# File 'lib/pagecord_cli/image_uploads.rb', line 11 def client @client end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
11 12 13 |
# File 'lib/pagecord_cli/image_uploads.rb', line 11 def content @content end |
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
11 12 13 |
# File 'lib/pagecord_cli/image_uploads.rb', line 11 def file_path @file_path end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
11 12 13 |
# File 'lib/pagecord_cli/image_uploads.rb', line 11 def @metadata end |
Instance Method Details
#process ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/pagecord_cli/image_uploads.rb', line 21 def process with_markdown_images = content.gsub(MARKDOWN_IMAGE) do |match| path = Regexp.last_match(2) local_path?(path) ? (path) : match end with_markdown_images.gsub(OBSIDIAN_IMAGE) do |match| path = Regexp.last_match(1) local_path?(path) ? (path) : match end end |