Class: Warcraft::Character::AchievementFragment

Inherits:
Object
  • Object
show all
Defined in:
lib/warcraft/character/achievements.rb

Instance Method Summary collapse

Constructor Details

#initialize(client, data) ⇒ AchievementFragment

Returns a new instance of AchievementFragment.



40
41
42
43
# File 'lib/warcraft/character/achievements.rb', line 40

def initialize(client, data)
  @client = client
  @data = data
end

Instance Method Details

#child_criteriaArray<Hash>

Returns:

  • (Array<Hash>)


75
76
77
# File 'lib/warcraft/character/achievements.rb', line 75

def child_criteria
  has_child_criteria? ? @data.dig(:criteria, :child_criteria) : []
end

#child_criteria?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/warcraft/character/achievements.rb', line 70

def child_criteria?
  @data[:criteria].key? :child_criteria
end

#completed?Boolean

Returns:

  • (Boolean)


85
86
87
# File 'lib/warcraft/character/achievements.rb', line 85

def completed?
  @data.dig(:criteria, :is_completed)
end

#completed_atTime

Returns:

  • (Time)


90
91
92
# File 'lib/warcraft/character/achievements.rb', line 90

def completed_at
  ApiResponse.convert_time(@data[:completed_timestamp])
end

#criteriaHash

Returns:

  • (Hash)


65
66
67
# File 'lib/warcraft/character/achievements.rb', line 65

def criteria
  @data[:criteria]
end

#criteria_idInteger

Returns:

  • (Integer)


80
81
82
# File 'lib/warcraft/character/achievements.rb', line 80

def criteria_id
  @data.dig(:criteria, :id)
end

#full_achievementObject



60
61
62
# File 'lib/warcraft/character/achievements.rb', line 60

def full_achievement
  @client.get(url)
end

#idInteger

Returns:

  • (Integer)


46
47
48
# File 'lib/warcraft/character/achievements.rb', line 46

def id
  @data[:id]
end

#nameString

Returns:

  • (String)


51
52
53
# File 'lib/warcraft/character/achievements.rb', line 51

def name
  @data.dig(:achievement, :name)
end

#urlString

Returns:

  • (String)


56
57
58
# File 'lib/warcraft/character/achievements.rb', line 56

def url
  @data.dig(:achievement, :key, :href)
end