Method: Nelumba::Atom::Thread#initialize

Defined in:
lib/nelumba/atom/thread.rb

#initialize(o) ⇒ Thread

Returns a new instance of Thread.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/nelumba/atom/thread.rb', line 12

def initialize(o)
  case o
  when XML::Reader
    if current_node_is?(o, 'in-reply-to')
      parse(o, :once => true)
    else
      raise ArgumentError, "Thread created with node other than thr:in-reply-to: #{o.name}"
    end
  when Hash
    [:href, :ref, :type, :source].each do |attr|
      self.send("#{attr}=", o[attr])
    end
  else
    raise ArgumentError, "Don't know how to handle #{o}"
  end
end