Method: Lotus::Atom::Account#initialize

Defined in:
lib/lotus/atom/account.rb

#initialize(o = {}) {|_self| ... } ⇒ Account

Returns a new instance of Account.

Yields:

  • (_self)

Yield Parameters:



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/lotus/atom/account.rb', line 18

def initialize(o = {})
  case o
  when XML::Reader
    o.read
    parse(o)
  when Hash
    o.each do |k, v|
      if k.to_s.include? '_'
        k = k.to_s.gsub(/_(.)/){"#{$1.upcase}"}.intern
      end
      self.send("#{k.to_s}=", v)
    end
  else
    raise ArgumentError, "Got #{o.class} but expected a Hash or XML::Reader"
  end

  yield(self) if block_given?
end