Class: Radian6::Topic

Inherits:
Object
  • Object
show all
Defined in:
lib/radian6/topic.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Topic

Returns a new instance of Topic.



5
6
7
8
9
10
# File 'lib/radian6/topic.rb', line 5

def initialize(params)
  params = {} unless params.is_a? Hash
  @name = params[:name] || ""
  @groups   = params[:groups] || ""
  @id       = params[:id] || ""
end

Instance Attribute Details

#groupsObject

Returns the value of attribute groups.



3
4
5
# File 'lib/radian6/topic.rb', line 3

def groups
  @groups
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/radian6/topic.rb', line 3

def id
  @id
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/radian6/topic.rb', line 3

def name
  @name
end

Class Method Details

.from_xml(xml) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/radian6/topic.rb', line 12

def self.from_xml(xml)
  xml_topics = Nokogiri::XML(xml).root.xpath('//topicFilters/topicFilter') rescue []
  topics = []
  xml_topics.each do |xml_topic|
    topics << parse_topic(xml_topic)
  end
  return topics
end