Class: GoGoodreads::Review

Inherits:
Object
  • Object
show all
Includes:
Resource
Defined in:
lib/go_goodreads/review.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Resource

included, #initialize

Instance Attribute Details

#userObject (readonly)

Returns the value of attribute user.



16
17
18
# File 'lib/go_goodreads/review.rb', line 16

def user
  @user
end

Class Method Details

.initialize_with_node(xml) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/go_goodreads/review.rb', line 18

def self.initialize_with_node(xml)
  attrs = to_attributes!(xml)
  review = new(attrs)
  review.initialize_user_with_node(xml.at('user'))
  review.initialize_shelves_with_nodes(xml.search('shelves > shelf'))
  review
end

Instance Method Details

#initialize_shelves_with_nodes(shelves_xml) ⇒ Object



30
31
32
33
34
# File 'lib/go_goodreads/review.rb', line 30

def initialize_shelves_with_nodes(shelves_xml)
  @shelves = shelves_xml.map do |xml|
    GoGoodreads::Shelf.initialize_with_node(xml)
  end
end

#initialize_user_with_node(xml) ⇒ Object



26
27
28
# File 'lib/go_goodreads/review.rb', line 26

def initialize_user_with_node(xml)
  @user = GoGoodreads::User.initialize_with_node(xml)
end