Class: Scrobbler::Shout

Inherits:
Base
  • Object
show all
Defined in:
lib/scrobbler/shout.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

api_key=, connection, get, maybe_streamable_attribute, maybe_streamable_node, post_request, request, sanitize, secret=

Constructor Details

#initialize(input = {}) ⇒ Shout



17
18
19
# File 'lib/scrobbler/shout.rb', line 17

def initialize(input={})
  populate_data(input)
end

Instance Attribute Details

#authorObject (readonly)

Returns the value of attribute author.



3
4
5
# File 'lib/scrobbler/shout.rb', line 3

def author
  @author
end

#bodyObject (readonly)

Returns the value of attribute body.



3
4
5
# File 'lib/scrobbler/shout.rb', line 3

def body
  @body
end

#dateObject (readonly)

Returns the value of attribute date.



3
4
5
# File 'lib/scrobbler/shout.rb', line 3

def date
  @date
end

Class Method Details

.new_from_libxml(xml) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/scrobbler/shout.rb', line 6

def new_from_libxml(xml)
  data={}
  xml.children.each do |child|
    data[:body] = child.content if child.name == 'body'
    data[:author] = Scrobbler::User.new(child.content) if child.name == 'author'
    data[:date] = Time.parse(child.content) if child.name == 'date'
  end
  Shout.new(data)
end