Class: GamesRadar::Screenshot

Inherits:
Object
  • Object
show all
Defined in:
lib/games_radar/screenshot.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Screenshot

Initialize a new screenshot object and set the hash to its attributes.

GamesRadar::Screenshot.new(
  :url => "/some/url",
  :image => "/some/image.jpg"
)

35
36
37
38
39
# File 'lib/games_radar/screenshot.rb', line 35

def initialize(attrs = {})
  attrs.each do |name, value|
    instance_variable_set("@#{name}", value)
  end
end

Instance Attribute Details

#imageObject (readonly)

The large image url


10
11
12
# File 'lib/games_radar/screenshot.rb', line 10

def image
  @image
end

#published_atObject (readonly)

When the screenshot was published on GamesRadar


13
14
15
# File 'lib/games_radar/screenshot.rb', line 13

def published_at
  @published_at
end

#thumbnailObject (readonly)

The thumbnail url


7
8
9
# File 'lib/games_radar/screenshot.rb', line 7

def thumbnail
  @thumbnail
end

#urlObject (readonly)

The screenshot page on GamesRadar


4
5
6
# File 'lib/games_radar/screenshot.rb', line 4

def url
  @url
end

Class Method Details

.initialize_with_node(node) ⇒ Object

:nodoc:


15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/games_radar/screenshot.rb', line 15

def self.initialize_with_node(node) # :nodoc:
  thumbnail = node.at("thumbnail").text
  image = thumbnail.gsub(/screenshot_small\.jpg/, "screenshot_viewer_medium.jpg")

  new(
    {
      :url => node.at("url").text,
      :thumbnail => thumbnail,
      :image => image,
      :published_at => Time.parse(node.at("published_date").text)
    }
  )
end