Class: IGE_ISB_API::Category

Inherits:
Object
  • Object
show all
Defined in:
lib/ige_isb_api/games.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCategory

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

#childrenObject

Returns the value of attribute children.



389
390
391
# File 'lib/ige_isb_api/games.rb', line 389

def children
  @children
end

#descriptionObject

Returns the value of attribute description.



389
390
391
# File 'lib/ige_isb_api/games.rb', line 389

def description
  @description
end

#gamesObject

Returns the value of attribute games.



389
390
391
# File 'lib/ige_isb_api/games.rb', line 389

def games
  @games
end

#iconObject

Returns the value of attribute icon.



389
390
391
# File 'lib/ige_isb_api/games.rb', line 389

def icon
  @icon
end

#idObject

Returns the value of attribute id.



389
390
391
# File 'lib/ige_isb_api/games.rb', line 389

def id
  @id
end

#languageObject

Returns the value of attribute language.



389
390
391
# File 'lib/ige_isb_api/games.rb', line 389

def language
  @language
end

#nameObject

Returns the value of attribute name.



389
390
391
# File 'lib/ige_isb_api/games.rb', line 389

def name
  @name
end

#parentObject

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