Class: Agave::Local::FieldType::File
- Inherits:
-
Object
- Object
- Agave::Local::FieldType::File
- Defined in:
- lib/agave/local/field_type/file.rb
Instance Attribute Summary collapse
-
#alt ⇒ Object
readonly
Returns the value of attribute alt.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#image_host ⇒ Object
readonly
Returns the value of attribute image_host.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
- #file ⇒ Object
-
#initialize(path, format, size, alt, title, image_host) ⇒ File
constructor
A new instance of File.
- #to_hash(*_args) ⇒ Object
- #url(opts = {}) ⇒ Object
Constructor Details
#initialize(path, format, size, alt, title, image_host) ⇒ File
Returns a new instance of File.
32 33 34 35 36 37 38 39 |
# File 'lib/agave/local/field_type/file.rb', line 32 def initialize(path, format, size, alt, title, image_host) @path = path @format = format @size = size @image_host = image_host @alt = alt @title = title end |
Instance Attribute Details
#alt ⇒ Object (readonly)
Returns the value of attribute alt.
12 13 14 |
# File 'lib/agave/local/field_type/file.rb', line 12 def alt @alt end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
9 10 11 |
# File 'lib/agave/local/field_type/file.rb', line 9 def format @format end |
#image_host ⇒ Object (readonly)
Returns the value of attribute image_host.
13 14 15 |
# File 'lib/agave/local/field_type/file.rb', line 13 def image_host @image_host end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/agave/local/field_type/file.rb', line 8 def path @path end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
10 11 12 |
# File 'lib/agave/local/field_type/file.rb', line 10 def size @size end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
11 12 13 |
# File 'lib/agave/local/field_type/file.rb', line 11 def title @title end |
Class Method Details
.parse(upload_attributes, repo) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/agave/local/field_type/file.rb', line 15 def self.parse(upload_attributes, repo) return nil if !upload_attributes return nil if !upload_attributes[:path] upload = repo.entities_repo.find_entity( "upload", upload_attributes[:path] ) return nil if !upload new( upload.path, upload.format, upload.size, upload.alt, upload.title, repo.site.entity.image_host ) end |
Instance Method Details
#file ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/agave/local/field_type/file.rb', line 41 def file Imgix::Client.new( host: image_host, secure: true, include_library_param: false ).path(path) end |
#to_hash(*_args) ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/agave/local/field_type/file.rb', line 53 def to_hash(*_args) { format: format, size: size, alt: alt, title: title, url: url } end |
#url(opts = {}) ⇒ Object
49 50 51 |
# File 'lib/agave/local/field_type/file.rb', line 49 def url(opts = {}) file.to_url(opts) end |