Class: IGE_ISB_API::Category
- Inherits:
-
Object
- Object
- IGE_ISB_API::Category
- Defined in:
- lib/ige_isb_api/games.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
-
#description ⇒ Object
Returns the value of attribute description.
-
#games ⇒ Object
Returns the value of attribute games.
-
#icon ⇒ Object
Returns the value of attribute icon.
-
#id ⇒ Object
Returns the value of attribute id.
-
#language ⇒ Object
Returns the value of attribute language.
-
#name ⇒ Object
Returns the value of attribute name.
-
#parent ⇒ Object
Returns the value of attribute parent.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Category
constructor
A new instance of Category.
Constructor Details
#initialize ⇒ Category
Returns a new instance of Category.
391 392 393 394 395 |
# File 'lib/ige_isb_api/games.rb', line 391 def initialize() @children = [] @games = [] @language = IGE_ISB_API::Constants::DEFAULT_LANGUAGE end |
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
389 390 391 |
# File 'lib/ige_isb_api/games.rb', line 389 def children @children end |
#description ⇒ Object
Returns the value of attribute description.
389 390 391 |
# File 'lib/ige_isb_api/games.rb', line 389 def description @description end |
#games ⇒ Object
Returns the value of attribute games.
389 390 391 |
# File 'lib/ige_isb_api/games.rb', line 389 def games @games end |
#icon ⇒ Object
Returns the value of attribute icon.
389 390 391 |
# File 'lib/ige_isb_api/games.rb', line 389 def icon @icon end |
#id ⇒ Object
Returns the value of attribute id.
389 390 391 |
# File 'lib/ige_isb_api/games.rb', line 389 def id @id end |
#language ⇒ Object
Returns the value of attribute language.
389 390 391 |
# File 'lib/ige_isb_api/games.rb', line 389 def language @language end |
#name ⇒ Object
Returns the value of attribute name.
389 390 391 |
# File 'lib/ige_isb_api/games.rb', line 389 def name @name end |
#parent ⇒ Object
Returns the value of attribute parent.
389 390 391 |
# File 'lib/ige_isb_api/games.rb', line 389 def parent @parent end |
Class Method Details
.from_node(node, opts = {}) ⇒ Object
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 |
# File 'lib/ige_isb_api/games.rb', line 397 def self.from_node(node, opts = {}) c = Category.new c.id = node['id'].to_i c.icon = node['i'] c.name = node['n'] @language = opts[:language] unless opts[:language].nil? c.description = node['d'] node.xpath("c").each do |subcat| # puts "found subcat #{subcat['n']}" Category.from_node subcat, parent: c, language: @language end node.xpath("g").each do |game| c.games << Game.from_node(game, c, @language) end c.parent = opts[:parent] c.parent.children << c unless c.parent.nil? return c end |