Class: AwarenessApi::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/awareness_api/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeResponse

Returns a new instance of Response.



6
7
8
# File 'lib/awareness_api/response.rb', line 6

def initialize
  @feeds = []
end

Instance Attribute Details

#codeObject

Returns the value of attribute code.



4
5
6
# File 'lib/awareness_api/response.rb', line 4

def code
  @code
end

#feedsObject

Returns the value of attribute feeds.



4
5
6
# File 'lib/awareness_api/response.rb', line 4

def feeds
  @feeds
end

#messageObject

Returns the value of attribute message.



4
5
6
# File 'lib/awareness_api/response.rb', line 4

def message
  @message
end

#statusObject

Returns the value of attribute status.



4
5
6
# File 'lib/awareness_api/response.rb', line 4

def status
  @status
end

Instance Method Details

#to_sObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/awareness_api/response.rb', line 10

def to_s
  output = []
  output << "Status: #{@status}"
  output << "Code: #{@code}" if @code
  output << "Message: #{@message}" if @message
  for feed in @feeds
    output << "-Feed"
    feed.attributes.each do |key,val|
      output << "  #{key}: #{val}"
    end
    for entry in feed.entries
      output << "  -Entry"
      entry.attributes.each do |key,val|
        output << "    #{key}: #{val}"
      end
      for item in entry.items
        output << "    -Item"
        item.attributes.each do |key,val|
          output << "      #{key}: #{val}"
        end
        for referer in item.referers
          output << "      -Referer"
          referer.attributes.each do |key,val|
            output << "        #{key}: #{val}"
          end
        end
      end
    end
  end

  return output.join("\n")
end