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

- (Achievement) initialize(options = {})



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

- (Object) description (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

- (Object) image_180 (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

- (Object) image_60 (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

- (Object) name (readonly)

Returns the value of attribute name



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

def name
  @name
end

- (Object) url (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

- (Object) parse_image(image)



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