Class: Snafu::Models::Achievement

Inherits:
Object
  • Object
show all
Defined in:
lib/snafu/models/achievement.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Achievement



6
7
8
9
10
11
12
# File 'lib/snafu/models/achievement.rb', line 6

def initialize(options = {})
  @name = options["name"]
  @description = options["description"] || options["desc"]
  @url = options["url"]
  @image_60 = parse_image options["image_60"]
  @image_180  = parse_image options["image_180"]
end

Instance Attribute Details

#descriptionObject (readonly) Also known as: desc

Returns the value of attribute description



4
5
6
# File 'lib/snafu/models/achievement.rb', line 4

def description
  @description
end

#image_180Object (readonly)

Returns the value of attribute image_180



4
5
6
# File 'lib/snafu/models/achievement.rb', line 4

def image_180
  @image_180
end

#image_60Object (readonly)

Returns the value of attribute image_60



4
5
6
# File 'lib/snafu/models/achievement.rb', line 4

def image_60
  @image_60
end

#nameObject (readonly)

Returns the value of attribute name



4
5
6
# File 'lib/snafu/models/achievement.rb', line 4

def name
  @name
end

#urlObject (readonly)

Returns the value of attribute url



4
5
6
# File 'lib/snafu/models/achievement.rb', line 4

def url
  @url
end

Instance Method Details

#parse_image(image) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/snafu/models/achievement.rb', line 14

def parse_image(image)
  if image.is_a? String
    return GlitchImage.new(url: image)
  elsif image.is_a? GlitchImage
    return image
  end
  nil
end