Class: Rsteamshot::Screenshot
- Inherits:
-
Object
- Object
- Rsteamshot::Screenshot
- Defined in:
- lib/rsteamshot/screenshot.rb
Overview
Public: Represents an image that has been uploaded to Steam of a screenshot taken in a Steam app.
Instance Attribute Summary collapse
-
#comment_count ⇒ Object
readonly
Public: Returns Integer count of how many comments people have left on this screenshot.
-
#date ⇒ Object
readonly
Public: Returns the DateTime when this screenshot was uploaded.
-
#details_url ⇒ Object
readonly
Public: Returns String URL to the Steam page that shows details about this screenshot.
-
#file_size ⇒ Object
readonly
Public: Returns a String describing how large the screenshot is, e.g., 0.547 MB.
-
#full_size_url ⇒ Object
readonly
Public: Returns String URL to the full-size image.
-
#height ⇒ Object
readonly
Public: Returns Integer pixel height of the screenshot.
-
#like_count ⇒ Object
readonly
Public: Returns Integer count of how many people have voted for this screenshot.
-
#medium_url ⇒ Object
readonly
Public: Returns String URL to a medium-size version of the image.
-
#title ⇒ Object
readonly
Public: Returns a String of how the user described this screenshot, or nil.
-
#user_name ⇒ Object
readonly
Public: Returns String name of the Steam user who uploaded the screenshot.
-
#user_url ⇒ Object
readonly
Public: Returns String URL to the profile of the Steam user who uploaded the screenshot.
-
#width ⇒ Object
readonly
Public: Returns Integer pixel width of the screenshot.
Instance Method Summary collapse
-
#initialize(attrs = {}) ⇒ Screenshot
constructor
Public: Initialize a screenshot with the given attributes.
-
#inspect ⇒ Object
Public: A detailed representation of this screenshot.
-
#to_h ⇒ Object
Public: Get a hash representation of this screenshot.
-
#to_json ⇒ Object
Public: Get a JSON representation of this screenshot.
Constructor Details
#initialize(attrs = {}) ⇒ Screenshot
Public: Initialize a screenshot with the given attributes.
attrs - the Hash of attributes for this screenshot
:title - how the user described this screenshot
:details_url - URL to the Steam page that shows details about this screenshot
:full_size_url - URL to the full-size image
:medium_url - URL to a medium-size version of the image
:user_name - name of the Steam user who uploaded the screenshot
:user_url - URL to the profile of the Steam user who uploaded the screenshot
:date - the date and time when this screenshot was uploaded
:file_size - describes how large the screenshot is, e.g., 0.547 MB
:width - pixel width of the screenshot
:height - pixel height of the screenshot
:like_count - number of likes this screenshot has on Steam
:comment_count - number of comments this screenshot has received on Steam
56 57 58 59 60 |
# File 'lib/rsteamshot/screenshot.rb', line 56 def initialize(attrs = {}) attrs.each { |key, value| instance_variable_set("@#{key}", value) } fetch_details unless has_details? end |
Instance Attribute Details
#comment_count ⇒ Object (readonly)
Public: Returns Integer count of how many comments people have left on this screenshot.
39 40 41 |
# File 'lib/rsteamshot/screenshot.rb', line 39 def comment_count @comment_count end |
#date ⇒ Object (readonly)
Public: Returns the DateTime when this screenshot was uploaded.
24 25 26 |
# File 'lib/rsteamshot/screenshot.rb', line 24 def date @date end |
#details_url ⇒ Object (readonly)
Public: Returns String URL to the Steam page that shows details about this screenshot.
9 10 11 |
# File 'lib/rsteamshot/screenshot.rb', line 9 def details_url @details_url end |
#file_size ⇒ Object (readonly)
Public: Returns a String describing how large the screenshot is, e.g., 0.547 MB.
27 28 29 |
# File 'lib/rsteamshot/screenshot.rb', line 27 def file_size @file_size end |
#full_size_url ⇒ Object (readonly)
Public: Returns String URL to the full-size image.
12 13 14 |
# File 'lib/rsteamshot/screenshot.rb', line 12 def full_size_url @full_size_url end |
#height ⇒ Object (readonly)
Public: Returns Integer pixel height of the screenshot.
33 34 35 |
# File 'lib/rsteamshot/screenshot.rb', line 33 def height @height end |
#like_count ⇒ Object (readonly)
Public: Returns Integer count of how many people have voted for this screenshot.
36 37 38 |
# File 'lib/rsteamshot/screenshot.rb', line 36 def like_count @like_count end |
#medium_url ⇒ Object (readonly)
Public: Returns String URL to a medium-size version of the image.
15 16 17 |
# File 'lib/rsteamshot/screenshot.rb', line 15 def medium_url @medium_url end |
#title ⇒ Object (readonly)
Public: Returns a String of how the user described this screenshot, or nil.
6 7 8 |
# File 'lib/rsteamshot/screenshot.rb', line 6 def title @title end |
#user_name ⇒ Object (readonly)
Public: Returns String name of the Steam user who uploaded the screenshot.
18 19 20 |
# File 'lib/rsteamshot/screenshot.rb', line 18 def user_name @user_name end |
#user_url ⇒ Object (readonly)
Public: Returns String URL to the profile of the Steam user who uploaded the screenshot.
21 22 23 |
# File 'lib/rsteamshot/screenshot.rb', line 21 def user_url @user_url end |
#width ⇒ Object (readonly)
Public: Returns Integer pixel width of the screenshot.
30 31 32 |
# File 'lib/rsteamshot/screenshot.rb', line 30 def width @width end |
Instance Method Details
#inspect ⇒ Object
Public: A detailed representation of this screenshot.
Returns a String.
91 92 93 |
# File 'lib/rsteamshot/screenshot.rb', line 91 def inspect self.class.name + '<' + JSON.generate(to_h) + '>' end |
#to_h ⇒ Object
Public: Get a hash representation of this screenshot.
Returns a Hash.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/rsteamshot/screenshot.rb', line 65 def to_h result = { details_url: details_url } result[:title] = title if title result[:full_size_url] = full_size_url if full_size_url result[:medium_url] = medium_url if medium_url result[:user_name] = user_name if user_name result[:user_url] = user_url if user_url result[:date] = date if date result[:file_size] = file_size if file_size result[:width] = width if width result[:height] = height if height result[:like_count] = like_count if like_count result[:comment_count] = comment_count if comment_count result end |
#to_json ⇒ Object
Public: Get a JSON representation of this screenshot.
Returns a String.
84 85 86 |
# File 'lib/rsteamshot/screenshot.rb', line 84 def to_json JSON.pretty_generate(to_h) end |