Class: Snapcat::Media::Type
- Inherits:
-
Object
- Object
- Snapcat::Media::Type
- Defined in:
- lib/snapcat/media.rb
Constant Summary collapse
- IMAGE =
0
- VIDEO =
1
- VIDEO_NOAUDIO =
2
- FRIEND_REQUEST =
3
- FRIEND_REQUEST_IMAGE =
4
- FRIEND_REQUEST_VIDEO =
5
- FRIEND_REQUEST_VIDEO_NOAUDIO =
6
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
Instance Method Summary collapse
- #file_extension ⇒ Object
- #image? ⇒ Boolean
-
#initialize(options = {}) ⇒ Type
constructor
A new instance of Type.
- #video? ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ Type
Returns a new instance of Type.
43 44 45 |
# File 'lib/snapcat/media.rb', line 43 def initialize( = {}) @code = code_from([:code], [:data]) end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
41 42 43 |
# File 'lib/snapcat/media.rb', line 41 def code @code end |
Instance Method Details
#file_extension ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/snapcat/media.rb', line 47 def file_extension if image? 'jpg' elsif video? 'mp4' end end |
#image? ⇒ Boolean
55 56 57 |
# File 'lib/snapcat/media.rb', line 55 def image? [IMAGE, FRIEND_REQUEST_IMAGE].include? @code end |
#video? ⇒ Boolean
59 60 61 62 63 |
# File 'lib/snapcat/media.rb', line 59 def video? [ VIDEO, VIDEO_NOAUDIO, FRIEND_REQUEST_VIDEO, FRIEND_REQUEST_VIDEO_NOAUDIO ].include? @code end |