Class: TwicasStream::LiveThumbnail::GetLiveThumbnailImage
- Inherits:
-
Object
- Object
- TwicasStream::LiveThumbnail::GetLiveThumbnailImage
- Defined in:
- lib/twicas_stream/live_thumbnail.rb
Constant Summary collapse
- PREFIX_URL =
'users'
- INFIX_URL =
'live'
- SUFFIX_URL =
'thumbnail'
- DEFAULT_SIZE =
'small'
- SIZE_LIMITATION =
['large', 'small']
- DEFAULT_POSITION =
'latest'
- POSITION_LIMITATION =
['beginning', 'latest']
Instance Attribute Summary collapse
-
#filepath ⇒ Object
readonly
Returns the value of attribute filepath.
Instance Method Summary collapse
-
#initialize(path, user_id, size = DEFAULT_SIZE, position = DEFAULT_POSITION) ⇒ GetLiveThumbnailImage
constructor
A new instance of GetLiveThumbnailImage.
Constructor Details
#initialize(path, user_id, size = DEFAULT_SIZE, position = DEFAULT_POSITION) ⇒ GetLiveThumbnailImage
Returns a new instance of GetLiveThumbnailImage.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/twicas_stream/live_thumbnail.rb', line 23 def initialize path, user_id, size = DEFAULT_SIZE, position = DEFAULT_POSITION @filepath = '' param = Hash.new unless File.exists?(path) STDERR.puts "#{__FILE__}:#{__LINE__}:Error: no such file or directory - #{path}" return end unless File::ftype(path) == 'directory' STDERR.puts "#{__FILE__}:#{__LINE__}:Error: not directory - #{path}" return end unless SIZE_LIMITATION.include?(size) STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: out of limitation. support size are '#{SIZE_LIMITATION.join("' or '")}'." end unless POSITION_LIMITATION.include?(position) STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: out of limitation. support position are '#{POSITION_LIMITATION.join("' or '")}'." end param['size'] = size param['position'] = position url = [BASE_URL, PREFIX_URL, user_id, INFIX_URL, SUFFIX_URL].join('/') + TwicasStream.make_query_string(param) # => 'https://apiv2.twitcasting.tv/users/twitcasting_jp/live/thumbnail?size=small&position=latest' @filepath = TwicasStream.get_image(url, path) end |
Instance Attribute Details
#filepath ⇒ Object (readonly)
Returns the value of attribute filepath.
7 8 9 |
# File 'lib/twicas_stream/live_thumbnail.rb', line 7 def filepath @filepath end |