Class: Hermitcraft::Video

Inherits:
Object
  • Object
show all
Defined in:
lib/hermitcraft/video.rb

Overview

This class wraps a video as represented by the Hermitcraft API.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Video

Returns a new instance of Video.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/hermitcraft/video.rb', line 9

def initialize(attributes)
  @id = attributes['id']
  @uploaded_at = Time.parse(attributes['uploaded'])

  # Sometimes, videos can show up with no uploader. I think this happens
  # when a Hermit has left Hermitcraft.
  @uploader = Uploader.new(attributes['uploader']) unless attributes['uploader'].nil?

  @title = attributes['title']
  @duration = attributes['duration']
  @like_count = attributes['likeCount'].to_i # hypno wat
  @view_count = attributes['viewCount']
  @comment_count = attributes['commentCount']
end

Instance Attribute Details

#comment_countObject (readonly)

Returns the value of attribute comment_count.



6
7
8
# File 'lib/hermitcraft/video.rb', line 6

def comment_count
  @comment_count
end

#durationObject (readonly)

Returns the value of attribute duration.



6
7
8
# File 'lib/hermitcraft/video.rb', line 6

def duration
  @duration
end

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/hermitcraft/video.rb', line 6

def id
  @id
end

#like_countObject (readonly)

Returns the value of attribute like_count.



6
7
8
# File 'lib/hermitcraft/video.rb', line 6

def like_count
  @like_count
end

#titleObject (readonly)

Returns the value of attribute title.



6
7
8
# File 'lib/hermitcraft/video.rb', line 6

def title
  @title
end

#uploaded_atObject (readonly)

Returns the value of attribute uploaded_at.



6
7
8
# File 'lib/hermitcraft/video.rb', line 6

def uploaded_at
  @uploaded_at
end

#uploaderObject (readonly)

Returns the value of attribute uploader.



6
7
8
# File 'lib/hermitcraft/video.rb', line 6

def uploader
  @uploader
end

#view_countObject (readonly)

Returns the value of attribute view_count.



6
7
8
# File 'lib/hermitcraft/video.rb', line 6

def view_count
  @view_count
end