Class: Rfd::Preview::Request
- Inherits:
-
Object
- Object
- Rfd::Preview::Request
- Defined in:
- lib/rfd/preview/request.rb
Overview
Value object representing a preview generation request
Instance Attribute Summary collapse
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
-
#file_type ⇒ Object
readonly
Returns the value of attribute file_type.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id:, file_path:, file_type:, width:, height:) ⇒ Request
constructor
A new instance of Request.
- #to_h ⇒ Object
Constructor Details
#initialize(id:, file_path:, file_type:, width:, height:) ⇒ Request
Returns a new instance of Request.
9 10 11 12 13 14 15 16 |
# File 'lib/rfd/preview/request.rb', line 9 def initialize(id:, file_path:, file_type:, width:, height:) @id = id @file_path = file_path @file_type = file_type @width = width @height = height = Time.now.to_f end |
Instance Attribute Details
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
7 8 9 |
# File 'lib/rfd/preview/request.rb', line 7 def file_path @file_path end |
#file_type ⇒ Object (readonly)
Returns the value of attribute file_type.
7 8 9 |
# File 'lib/rfd/preview/request.rb', line 7 def file_type @file_type end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
7 8 9 |
# File 'lib/rfd/preview/request.rb', line 7 def height @height end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/rfd/preview/request.rb', line 7 def id @id end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
7 8 9 |
# File 'lib/rfd/preview/request.rb', line 7 def end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
7 8 9 |
# File 'lib/rfd/preview/request.rb', line 7 def width @width end |
Class Method Details
.from_hash(hash) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/rfd/preview/request.rb', line 29 def self.from_hash(hash) new( id: hash['id'], file_path: hash['path'], file_type: hash['file_type'] && hash['file_type'].to_sym, width: hash['width'], height: hash['height'] ) end |
Instance Method Details
#to_h ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rfd/preview/request.rb', line 18 def to_h { type: 'request', id: @id, path: @file_path, file_type: @file_type, width: @width, height: @height } end |