Class: GameFaqs::FAQ
- Inherits:
-
Object
- Object
- GameFaqs::FAQ
- Defined in:
- lib/gamefaqs/faq.rb
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#game ⇒ Object
readonly
Returns the value of attribute game.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #homepage(refresh = false) ⇒ Object
-
#initialize(options = {}) ⇒ FAQ
constructor
A new instance of FAQ.
Constructor Details
#initialize(options = {}) ⇒ FAQ
Returns a new instance of FAQ.
5 6 7 8 |
# File 'lib/gamefaqs/faq.rb', line 5 def initialize(={}) raise ArgumentError.new("Need at least the game and the faq id") unless [:game] && [:id] @game, @id, @type, @title, @created_at, @author, @version, @size = [:game], [:id], [:type], [:title], [:created_at], [:author], [:size] end |
Instance Attribute Details
#author ⇒ Object (readonly)
Returns the value of attribute author.
3 4 5 |
# File 'lib/gamefaqs/faq.rb', line 3 def @author end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
3 4 5 |
# File 'lib/gamefaqs/faq.rb', line 3 def created_at @created_at end |
#game ⇒ Object (readonly)
Returns the value of attribute game.
3 4 5 |
# File 'lib/gamefaqs/faq.rb', line 3 def game @game end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/gamefaqs/faq.rb', line 3 def id @id end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
3 4 5 |
# File 'lib/gamefaqs/faq.rb', line 3 def size @size end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
3 4 5 |
# File 'lib/gamefaqs/faq.rb', line 3 def title @title end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
3 4 5 |
# File 'lib/gamefaqs/faq.rb', line 3 def type @type end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
3 4 5 |
# File 'lib/gamefaqs/faq.rb', line 3 def version @version end |
Instance Method Details
#homepage(refresh = false) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/gamefaqs/faq.rb', line 10 def homepage(refresh=false) cached_value("review-#{@id}-#{@game}", [], refresh) do |homepage| url = "#{@game.homepage.gsub(/game/, 'file').gsub('.html', '')}/#{@id}" doc = Hpricot(open(url)) doc.search("a[text()='View/Download Original File'") do |a| puts a.inner_html puts a['href'] homepage << a['href'] end end.first end |