Class: Markbridge::AST::Upload
- Defined in:
- lib/markbridge/ast/upload.rb
Overview
Represents a Discourse upload reference (image or file attachment). Uses the upload:// URL scheme.
Instance Attribute Summary collapse
-
#alt ⇒ String?
readonly
Alt text (for images).
-
#dimensions ⇒ String?
readonly
Dimensions string like “64x64” (for images).
-
#filename ⇒ String?
readonly
Original filename.
-
#raw ⇒ String?
readonly
The original raw Markdown.
-
#sha1 ⇒ String
readonly
The base62 SHA1 identifier from upload:// URL.
-
#size ⇒ String?
readonly
File size string like “502.1 KB” (for attachments).
-
#type ⇒ Symbol
readonly
Type of upload (:image or :attachment).
Instance Method Summary collapse
-
#initialize(sha1:, filename: nil, type: :image, alt: nil, dimensions: nil, size: nil, raw: nil) ⇒ Upload
constructor
Create a new Upload node.
Constructor Details
#initialize(sha1:, filename: nil, type: :image, alt: nil, dimensions: nil, size: nil, raw: nil) ⇒ Upload
Create a new Upload node.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/markbridge/ast/upload.rb', line 55 def initialize( sha1:, filename: nil, type: :image, alt: nil, dimensions: nil, size: nil, raw: nil ) @sha1 = sha1 @filename = filename @type = type @alt = alt @dimensions = dimensions @size = size @raw = raw end |
Instance Attribute Details
#alt ⇒ String? (readonly)
Returns alt text (for images).
35 36 37 |
# File 'lib/markbridge/ast/upload.rb', line 35 def alt @alt end |
#dimensions ⇒ String? (readonly)
Returns dimensions string like “64x64” (for images).
38 39 40 |
# File 'lib/markbridge/ast/upload.rb', line 38 def dimensions @dimensions end |
#filename ⇒ String? (readonly)
Returns original filename.
29 30 31 |
# File 'lib/markbridge/ast/upload.rb', line 29 def filename @filename end |
#raw ⇒ String? (readonly)
Returns the original raw Markdown.
44 45 46 |
# File 'lib/markbridge/ast/upload.rb', line 44 def raw @raw end |
#sha1 ⇒ String (readonly)
Returns the base62 SHA1 identifier from upload:// URL.
26 27 28 |
# File 'lib/markbridge/ast/upload.rb', line 26 def sha1 @sha1 end |
#size ⇒ String? (readonly)
Returns file size string like “502.1 KB” (for attachments).
41 42 43 |
# File 'lib/markbridge/ast/upload.rb', line 41 def size @size end |
#type ⇒ Symbol (readonly)
Returns type of upload (:image or :attachment).
32 33 34 |
# File 'lib/markbridge/ast/upload.rb', line 32 def type @type end |