Class: Funky::Video
- Inherits:
-
Object
- Object
- Funky::Video
- Defined in:
- lib/funky/video.rb
Constant Summary collapse
Instance Attribute Summary collapse
-
#counters ⇒ Object
Returns the value of attribute counters.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Class Method Summary collapse
-
.find(video_id) ⇒ Funky::Video
Fetches the data from Facebook’s HTML and instantiates the data into a single Funky::Video object.
-
.where(id:) ⇒ Array<Funky::Video>
Fetches the data from Facebook’s APIs and instantiates the data into an Array of Funky::Video objects.
Instance Method Summary collapse
-
#comment_count ⇒ Integer
The total number of comments for the video.
-
#created_time ⇒ DateTime
The created time of the video.
-
#description ⇒ String
The description of the video.
-
#id ⇒ String
The video ID.
-
#initialize(data) ⇒ Video
constructor
A new instance of Video.
-
#length ⇒ Float
The length (duration) of the video.
-
#like_count ⇒ Integer
The total number of likes for the video.
-
#picture ⇒ String
The picture URL of the video.
-
#share_count ⇒ Integer
The total number of shares for the video.
-
#view_count ⇒ Integer
The total number of views for the video.
Constructor Details
#initialize(data) ⇒ Video
Returns a new instance of Video.
12 13 14 |
# File 'lib/funky/video.rb', line 12 def initialize(data) @data = data end |
Instance Attribute Details
#counters ⇒ Object
Returns the value of attribute counters.
7 8 9 |
# File 'lib/funky/video.rb', line 7 def counters @counters end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
6 7 8 |
# File 'lib/funky/video.rb', line 6 def data @data end |
Class Method Details
.find(video_id) ⇒ Funky::Video
Fetches the data from Facebook’s HTML and instantiates the data into a single Funky::Video object. It can accept one only video ID.
88 89 90 91 |
# File 'lib/funky/video.rb', line 88 def self.find(video_id) counters = @@html_parser.parse html: @@html_page.get(video_id: video_id) new counters.merge(id: video_id) end |
.where(id:) ⇒ Array<Funky::Video>
Fetches the data from Facebook’s APIs and instantiates the data into an Array of Funky::Video objects. It can accept one video ID or an array of multiple video IDs.
75 76 77 78 |
# File 'lib/funky/video.rb', line 75 def self.where(id:) return nil unless id instantiate_collection(fetch_and_parse_data Array(id)) end |
Instance Method Details
#comment_count ⇒ Integer
Returns the total number of comments for the video.
48 49 50 |
# File 'lib/funky/video.rb', line 48 def comment_count data[:comment_count] end |
#created_time ⇒ DateTime
Returns the created time of the video.
22 23 24 25 |
# File 'lib/funky/video.rb', line 22 def created_time datetime = data[:created_time] DateTime.parse datetime if datetime end |
#description ⇒ String
Returns the description of the video.
28 29 30 |
# File 'lib/funky/video.rb', line 28 def description data[:description] end |
#id ⇒ String
Returns the video ID.
17 18 19 |
# File 'lib/funky/video.rb', line 17 def id data[:id] end |
#length ⇒ Float
Returns the length (duration) of the video.
33 34 35 |
# File 'lib/funky/video.rb', line 33 def length data[:length] end |
#like_count ⇒ Integer
Returns the total number of likes for the video.
43 44 45 |
# File 'lib/funky/video.rb', line 43 def like_count data[:like_count] end |
#picture ⇒ String
Returns the picture URL of the video.
38 39 40 |
# File 'lib/funky/video.rb', line 38 def picture data[:picture] end |
#share_count ⇒ Integer
Returns the total number of shares for the video.
53 54 55 |
# File 'lib/funky/video.rb', line 53 def share_count data[:share_count] end |
#view_count ⇒ Integer
Returns the total number of views for the video.
58 59 60 |
# File 'lib/funky/video.rb', line 58 def view_count data[:view_count] end |