Class: Honey::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/honey/builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username, password) ⇒ Builder

Returns a new instance of Builder.



5
6
7
8
# File 'lib/honey/builder.rb', line 5

def initialize(username, password)
  @username = username
  @password = password
end

Instance Attribute Details

#passwordObject (readonly)

Returns the value of attribute password.



3
4
5
# File 'lib/honey/builder.rb', line 3

def password
  @password
end

#usernameObject (readonly)

Returns the value of attribute username.



3
4
5
# File 'lib/honey/builder.rb', line 3

def username
  @username
end

Instance Method Details

#build(data) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/honey/builder.rb', line 10

def build(data)
  @data = Nokogiri::XML::Builder.new do |xml|
    xml.HPEnvelope do
      xml.username(username)
      xml.password(password)
      data.each_pair do |key, value|
        xml_pair(xml, key, value)
      end
    end
  end.to_xml.strip
end

#destruct(data) ⇒ Object



22
23
24
# File 'lib/honey/builder.rb', line 22

def destruct(data)
  Nokogiri::XML(data).to_hash
end