Class: Pexels::Video
- Inherits:
-
Object
- Object
- Pexels::Video
- Defined in:
- lib/pexels/video.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#image ⇒ Object
readonly
Returns the value of attribute image.
-
#pictures ⇒ Object
readonly
Returns the value of attribute pictures.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
-
#initialize(attrs) ⇒ Video
constructor
A new instance of Video.
- #photo? ⇒ Boolean
- #type ⇒ Object
- #video? ⇒ Boolean
Constructor Details
#initialize(attrs) ⇒ Video
Returns a new instance of Video.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/pexels/video.rb', line 13 def initialize(attrs) @id = attrs.fetch('id') @height = attrs.fetch('height') @width = attrs.fetch('width') @url = attrs.fetch('url') @image = attrs.fetch('image') @duration = attrs.fetch('duration') @user = Pexels::User.new( id: attrs.fetch('user').fetch('id'), name: attrs.fetch('user').fetch('name'), url: attrs.fetch('user').fetch('url') ) @files = attrs.fetch('video_files', []).map { |vf| Pexels::Video::File.new(vf) } @pictures = attrs.fetch('video_pictures', []).map { |vp| Pexels::Video::Picture.new(vp) } rescue KeyError => exception raise Pexels::MalformedAPIResponseError.new(exception) end |
Instance Attribute Details
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
2 3 4 |
# File 'lib/pexels/video.rb', line 2 def duration @duration end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
2 3 4 |
# File 'lib/pexels/video.rb', line 2 def files @files end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
2 3 4 |
# File 'lib/pexels/video.rb', line 2 def height @height end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
2 3 4 |
# File 'lib/pexels/video.rb', line 2 def id @id end |
#image ⇒ Object (readonly)
Returns the value of attribute image.
2 3 4 |
# File 'lib/pexels/video.rb', line 2 def image @image end |
#pictures ⇒ Object (readonly)
Returns the value of attribute pictures.
2 3 4 |
# File 'lib/pexels/video.rb', line 2 def pictures @pictures end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
2 3 4 |
# File 'lib/pexels/video.rb', line 2 def url @url end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
2 3 4 |
# File 'lib/pexels/video.rb', line 2 def user @user end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
2 3 4 |
# File 'lib/pexels/video.rb', line 2 def width @width end |
Instance Method Details
#photo? ⇒ Boolean
39 40 41 |
# File 'lib/pexels/video.rb', line 39 def photo? false end |
#type ⇒ Object
35 36 37 |
# File 'lib/pexels/video.rb', line 35 def type 'Video' end |
#video? ⇒ Boolean
43 44 45 |
# File 'lib/pexels/video.rb', line 43 def video? true end |